mirror of
https://github.com/IAmTomShaw/f1-race-replay.git
synced 2026-05-09 08:25:56 +02:00
[PR #213] [MERGED] Optimize closest point search using KD-Tree to reduce CPU usage #222
Labels
No labels
bug
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/f1-race-replay#222
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/IAmTomShaw/f1-race-replay/pull/213
Author: @LRxDarkDevil
Created: 2/2/2026
Status: ✅ Merged
Merged: 2/5/2026
Merged by: @IAmTomShaw
Base:
main← Head:feature/kd-tree-optimization📝 Commits (1)
3462872Optimize closest point search using KD-Tree to reduce CPU usage📊 Changes
1 file changed (+12 additions, -9 deletions)
View changed files
📝
src/interfaces/race_replay.py(+12 -9)📄 Description
I noticed that the replay viewer was running pretty heavy on my CPU (hitting 100% usage even on simple replays).
I found out that the app calculates the "closest track point" for every car by scanning all ~4,000 track points every single frame. This adds up to millions of calculations per second just to draw the driver labels.
I swapped that search loop out for a cKDTree (using Scipy). It does the exact same math but is basically instant (
O(\log N)instead ofO(N)).Result: The visuals and accuracy are identical, but it uses drastically less CPU and runs smoother.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.