perf: mathematical optimization pass - eliminate redundant calculations#2
Open
crunchy4159 wants to merge 1 commit intoouch3994:mainfrom
Open
perf: mathematical optimization pass - eliminate redundant calculations#2crunchy4159 wants to merge 1 commit intoouch3994:mainfrom
crunchy4159 wants to merge 1 commit intoouch3994:mainfrom
Conversation
Mathematical Optimization Pass Eliminated redundant calculations in the rendering pipeline. Main focus was drawsubhasesroutine() which was recalculating (Marker * opticPercent * 180 / scaling) about 200 times per frame. Added a simple pre-computation: scale_factor = opticPercent * 180 / scaling, then just multiply each marker by that. Saves roughly 600 floating-point operations per frame. Also pulled out conversion constants that were being recalculated repeatedly: This eliminates ~14 divisions per frame and makes the code more readable. Other quick changes: math.hypot(x, y) instead of manual sqrt calculation (2 places) 2 ** exp instead of pow(2, exp) (faster, optimized by interpreter) Pre-computed EMA_BETA = 0.85 constant Expected gain: ~622 fewer floating-point ops per frame = +3 to 5 FPS (35 → 38-40 FPS) I'm working on getting my own setup for this, but until then I need you to test these upgrades! I plan to get your suggested improvements done as well but I think a higher framerate and overall efficiency is a good place to start. Testing: Run on your setup and verify FPS improvement. Baseline seemed to be about 35 FPS stable. Target is 38-40 FPS sustained with no visual artifacts or calculation errors. Monitor scope accuracy at various zoom levels.
This file contains hidden or 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
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.
Mathematical Optimization Pass
Eliminated redundant calculations in the rendering pipeline. Main focus was drawsubhasesroutine() which was recalculating (Marker * opticPercent * 180 / scaling) about 200 times per frame. Added a simple pre-computation: scale_factor = opticPercent * 180 / scaling, then just multiply each marker by that. Saves roughly 600 floating-point operations per frame.
Also pulled out conversion constants that were being recalculated repeatedly:
This eliminates ~14 divisions per frame and makes the code more readable.
Other quick changes:
math.hypot(x, y) instead of manual sqrt calculation (2 places) 2 ** exp instead of pow(2, exp) (faster, optimized by interpreter) Pre-computed EMA_BETA = 0.85 constant
Expected gain: ~622 fewer floating-point ops per frame = +3 to 5 FPS (35 → 38-40 FPS)
I'm working on getting my own setup for this, but until then I need you to test these upgrades! I plan to get your suggested improvements done as well but I think a higher framerate and overall efficiency is a good place to start.
Testing: Run on your setup and verify FPS improvement. Baseline seemed to be about 35 FPS stable. Target is 38-40 FPS sustained with no visual artifacts or calculation errors. Monitor scope accuracy at various zoom levels.