Open Aivean opened 3 years ago
Some of the relevant discord discussion:
BrettD:
event_multiset &stats_tracker::get_events( event_type type ) { return data.emplace( type, event_multiset( type ) ).first->second; }
stats_tracker.cpp line 226 Feels like it's constructing a event_multiset every time it's called
Aivean: changing
stats_tracker::get_events
to lookup first didn't help, as jbtw predicted, and the offender method didn't change, I think it means that get_events actually inserts elements more often than not. And the real problem is somewhere up the stack
OK, I've figured out two reasons why this was so slow:
value_constraint::permits
can be used to constrain a particular value to equal some statistic. Currently it recomputes the value of that statistic every time it compares against it, which is unnecessarily expensive.Working on fixes now.
Note that all the slowness is due to achievement_return_to_first_omt
, because that involves a constraint against a value of a statistic which is expensive to compute.
Describe the bug
Working on the savefile from #45822 I noticed that
achievements_tracker::deserialize
takes 40% of save loading time, or ≈13 seconds on my machine:The culprit seems to be
unordered_map
constructor:full signature
```cpp std::__1::unordered_mapSteps To Reproduce
Expected behavior
The serialized json form for achievement tracking is not that big, so I suspect some inefficiency in the implementation.
Versions and configuration