noggit3 icon indicating copy to clipboard operation
noggit3 copied to clipboard

scoped_***_reference constructor/destructor triggered multiple times

Open skarndev opened this issue 5 years ago • 1 comments

scoped_***_reference after creating are being passed between various functions using std::move semantics. That triggers destruction and subsequent construction on each move. That results into many repeating search operations on noggit::async_multimap_with_normalized_key by calling emplace() and erase() methods. This leads to a significant slowdown in loading performance. World::add_model_instance() is the example of this happening, but happens multiple times throughout the code for textures, models and WMOs.

skarndev avatar Nov 13 '20 19:11 skarndev

It seems that the issue is that it is not using move semantics? When moving a scoped reference, the moved from is set to be !_valid, and the dtor doesn't call erase (and the ctor doesn't call emplace) in that case.

It appears that there is something wrong with move vs copy somewhere but on a quick look I was unable to find it. ModelInstance also appears to be fine, so I'm slightly at a loss here. Probably needs some backtrace logging to find out where exactly those calls are happening and with what arguments, …

bloerwald avatar Nov 17 '20 20:11 bloerwald