-
Notifications
You must be signed in to change notification settings - Fork 41
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
Optimize governors #2312
Merged
jwrober
merged 7 commits into
longturn:master
from
lmoureaux:feature/optimize-governors
Jul 15, 2024
Merged
Optimize governors #2312
jwrober
merged 7 commits into
longturn:master
from
lmoureaux:feature/optimize-governors
Jul 15, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Profiling governors showed that finding them amounted to 10% of the runtime. Factoring this out slightly up in the stack reduces the number of calls.
Time from entering password to a responsive client decreased from ~1m30s using the master to ~35s using this PR. |
lmoureaux
force-pushed
the
feature/optimize-governors
branch
from
July 6, 2024 21:22
53d4abf
to
569bacd
Compare
Profiling has shown city_tile_iterate to be expensive, with the governors spending 20% of their time in it. They are used in a double loop with output types. Swap the two loops to have the expensive one outside, speeding up governors by about 15% in LTT.
lmoureaux
force-pushed
the
feature/optimize-governors
branch
from
July 6, 2024 21:56
569bacd
to
263b439
Compare
The code had the concept of "free worked tiles" but the only such tile has only ever been the city center. Remove this from the code and just refer to the city center.
This reduces the number of calls to city_tile_output and speeds up finding the results.
This speeds things up by reducing the frequency at which we evaluate effects.
Evaluating waste-related effects was found to represent half of the governors' runtime. Cache them to speed things up. This optimization breaks if waste depends on the celebration status, but governors are generally broken in this regard (they also don't understand how tile outputs might change).
lmoureaux
force-pushed
the
feature/optimize-governors
branch
from
July 7, 2024 03:22
82fbb72
to
059db33
Compare
This avoids a large number of effect evaluations, speeding things up significantly.
Code Factor not happy. Correction needed? |
It's unhappy because I modified a complex function without simplifying it. |
Ok Sounds good. |
jwrober
approved these changes
Jul 15, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to improve performance for me.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Profiling has shown a few low hanging fruits to speed up governors. This implements them.