Increase PathFinder maxRooms maximum to 64 #31
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some users have said that increasing this limit would be useful to them. Since any time the pathfinder enters a room it counts against maxRooms, you usually end up with a maximum path shorter than 16 rooms long.
With the existing code the highest we could bump the k_max_rooms constant to was 24, so I went through and audited and updated the data structures in use. This increases memory usage a little, but reduces CPU overhead a little bit too (by about 7%). The pathfinder is almost allocation-free which means that it allocates all the memory it could possibly need upfront and holds on to it for the program's lifetime. The old code would use ~49kb of memory per thread per k_max_rooms, plus about 74kb of other overhead. The new code uses ~84kb of memory per thread per k_max_rooms, plus the same overhead.
Assuming a 4 thread server, before this patch the pathfinder will hold onto ~3.63mb of memory. After this patch it will hold onto 17.27mb of memory. I don't think that number is unreasonable by any measure but I did want to make sure to communicate the exact cost of this change. And like I mentioned it is 7% faster, at least on my system and probably most 64-bit systems.
This also includes the fix for the "Max heap" issue we discussed a couple days ago. It'll automatically adjust the heap size to the correct capacity based on k_max_rooms.