Open CLIDragon opened 3 weeks ago
Patch set to replace lru_cache_t
with a plain std::unordered_map
. Performance seems to consistently improve from ~40% to ~37% CPU time, but there's too much noise to observe a measurable change in wall clock time.
has_potential_los
reduced from ~40% to ~5% using just a std::unordered_map
This is substantiated when using an lru_cache
, with the cache adding a 1% total time (~20%) overhead.
Describe the bug
npc_regen_ai_cache
callshas_potential_los
for each npc and each monster. This leads to $O(n^2 + nM)$ time, where $n$ is the number of npcs and $M$ is the number of monsters. In this case, there are 43 npcs and 62 creatures in total.Attach save file
N/A.
Steps to reproduce
|
- wait till next day.Expected behavior
Not taking this long?
Screenshots
Versions and configuration
Additional context
I'm not familiar enough with this part of the code to tell what needs to be changed. I suspect that
regen_ai_cache
should be called less often, though it is also possible thatskew_vision_cache
is doing extra work. Or possiblylru_cache_t
is just really poorly implemented.