Guard time_spent_in/out_isr
with MULTISTEPPING_LIMIT > 1
#27147
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.
Description
Guard
time_spent_in_isr
andtime_spent_out_isr
withMULTISTEPPING_LIMIT > 1
since the values are not actually used/useful in this case. The compiler doesn't do it for us especially since it won't optimize away even reads on anyvolatile
variables.Benefits
Small speedup in max theoretically achievable stepping speed since there's less computation in the ISR. Example from LPC1769 with 80steps/mm: ~5400mm/s to ~6100mm/s (though note it was pre-optimized locally with
-flto
build option - for better inlining - and a spattering of[[gnu::section(".ramcode")]]
to make sure the stepper ISR code was contained in microcontroller RAM).Before, looking at the step/dir pins with a logic analyzer (at 16Mhz capture rate):
![guard-isr-ticks-before](https://private-user-images.githubusercontent.com/299015/335913095-590593d5-a263-499b-86d5-8fa57389a541.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU1NTcwODEsIm5iZiI6MTcyNTU1Njc4MSwicGF0aCI6Ii8yOTkwMTUvMzM1OTEzMDk1LTU5MDU5M2Q1LWEyNjMtNDk5Yi04NmQ1LThmYTU3Mzg5YTU0MS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjI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