-
Notifications
You must be signed in to change notification settings - Fork 1
Optimizing Vector3 for everyone #4
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
Comments
I'm not sure if that will help, but it's worth a shot! |
This has been added in v0.13.1 - but also, I more meant to use something like numpy for vector ops |
Complete with https://github.com/VirxEC/rlbot_flatbuffers_py/releases/tag/v0.13.2 I've pulled out all the stops with this latest release. I've done a 180 from optimizing for pack/unpack speed to optimizing for runtime performance. I measured a 21% improvement between v0.13.1 and 0.13.2. Because of that, unpack speed has suffered due to the shear number of objects it needs to create, especially for the ball prediction (it now takes ~250 microseconds). Experiments will have to be done, and will require more work and likely some additional (non-breaking) changes to the Python interface. |
On what did you measure the 21% improvement? |
The time to run this code: def find_slice_at_time(ball_prediction: flat.BallPrediction, game_time: float):
"""
This will find the future position of the ball at the specified time. The returned
Slice object will also include the ball's velocity, etc.
"""
start_time = ball_prediction.slices[0].game_seconds
approx_index = int(
(game_time - start_time) * 120
) # We know that there are 120 slices per second.
if 0 <= approx_index < len(ball_prediction.slices):
return ball_prediction.slices[approx_index]
return None
li = []
for t in range(1, 301):
ball_in_future = find_slice_at_time(ballPred, t / 60)
li.append(ball_in_future) Went from ~70 micros to ~55micros. This average was taken after running the loop 50,000 times and I measured the same result multiple times. |
In RLBot/python-interface#12 we briefly mentioned optimizations of
Vector3
.Would it be possible to add
__slots__
to the generatedVector3
?Other tricks may also be possible.
The text was updated successfully, but these errors were encountered: