-
Notifications
You must be signed in to change notification settings - Fork 28
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
Speedup #81
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
- Run python sandbox/break.py --time-it --load sandbox/timing.msgpack --no-viz
- These are called like 13k times during a break shot, and a noticeable amount of time is saved by caching them
- This is 10X faster, although I dont't think it's very significant in the grand scheme of things
- Pretty significant speedup (0.66 -> 0.53) - I think it's fair to say this is the responsibility of the caller to do
- Creating an event should be cheap, since we make candidate events all the time throughout the shot evolution algorithm
- This was 3% of continuize
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.
This PR is concerned with speed.
Since the large refactor that transformed System, Cue, Table, and Ball and their delegate objects into dataclasses, pooltool has been kind of slow. After profiling the code with pprofile, I was able to make some changes all in the name of speed.
I tested tracked the speed progress on two test cases: (1) a simple shot involving 3 balls, a pocket, and a couple of cushions and (2) a 9-ball break.
Here is how the following commits speed up the simple shot:
And here is how they sped up the 9-ball break:
Another important speed is how fast the ball animations are built. This is substantial, especially when the shot is played in half speed / quarter speed (which doubles / quadruples the time taken). I wrote
sandbox/continuize_and_render_timer.py
so that this can be compared to the time to simulate and continuize shots.Using that script, the current state of affairs is:
And the break shot:
If I were to increase the speed further, I would avoid storing
Ball.history_cts
as aBallHistory
object. Instead, I would create aVectorizedBallHistory
object that simply stores the arraysrvws
,ss
, andts
. I think this would make continuize and ball animations significantly faster by avoiding interconversion from arrays to BallHistory sequences.