mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

Improve performance of CClientObjectManager::UpdateLimitInfo

Open Merlin opened this issue 2 years ago • 0 comments

This improves the performance of CClientObjectManager::UpdateLimitInfo. I measured with SharedUtil::GetTimeUs and it consistently took 212 microseconds for these 3 calls. It is called every frame and also whenever a object is streamed in or out.

Instead of calling these functions I hooked the pool functions that add and remove entries to the pool and now keep track of the amount of used spaces in a separate variable.

Now it only takes 0-1 microseconds.

Merlin avatar Aug 09 '22 21:08 Merlin

I don't think that will work, because sometimes the delete operator is inlined. Although, you could paralellize it, see https://en.cppreference.com/w/cpp/algorithm/count ExceutionPolicy

Pirulax avatar Aug 15 '22 21:08 Pirulax

I also patched all places that got inlined. There is also some test code left in a comment for whoever reviews this that can be used to check if the values match.

Merlin avatar Aug 16 '22 02:08 Merlin