Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field enumeration perf #31686

Merged
merged 2 commits into from
Jun 23, 2019

Conversation

kevingranade
Copy link
Member

@kevingranade kevingranade commented Jun 21, 2019

Summary

SUMMARY: Performance "Build bitmap cache of field locations."

Purpose of change

Continuing with profile guided optimization, simply enumerating submaps with active fields (even when there are no fields!) was taking ~7.5% of execution time while waiting on an empty map.

Describe the solution

Created a bitmap of submaps containing an active field in addition to the submap field_count field. Used this bitmap to determine whether a submap needs field processing, dropping execution time in my test to 1.1%.

Describe alternatives you've considered

Could have been a sparse tripoint set instead of a bitmap, but we frequently expect a lot of fields on the map, and if the map grows larger than the bitmap, the map loses hard, so I feel a bitmap is a much more performant option here.
The code that re-syncs submaps with the cache after a submap with fields is processed is pretty bad, it visits each adjacent submap and forcibly syncs the value of field_count to the cache, this works and considering we just did a probably very expensive field update, it's probably inconsequential, but I'd love a better option.
Also the code that updates the new cache is pretty gross, I'd appreciate suggestions for cleaning it up.

Additional context

Take a fairly close look at running around and doing strange things while fields are updating, I shook out a bunch of bugs this had and I can no longer break it, but there might be something I missed.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. labels Jun 21, 2019
@ZhilkinSerg ZhilkinSerg self-assigned this Jun 21, 2019
@ZhilkinSerg ZhilkinSerg merged commit dc3475c into CleverRaven:master Jun 23, 2019
@ZhilkinSerg
Copy link
Contributor

I didn't catch anything strange, so let's wait for players responses.

@ZhilkinSerg ZhilkinSerg removed their assignment Jun 23, 2019
@kevingranade kevingranade deleted the field-enumeration-perf branch December 16, 2019 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) Fields / Furniture / Terrain / Traps Objects that are part of the map or its features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants