-
-
Notifications
You must be signed in to change notification settings - Fork 722
perf(napi/parser): raw transfer: reduce maths complexity #13145
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
perf(napi/parser): raw transfer: reduce maths complexity #13145
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Optimizes mathematical operations in raw transfer parsing by reorganizing constant calculations to reduce runtime complexity. The change moves RAW_METADATA_SIZE subtraction outside of the saturating_sub operation to enable more compile-time optimization.
- Reorganizes arithmetic in data size calculation to reduce runtime operations
- Maintains identical functional behavior while improving performance
- Enhances potential 32-bit system compatibility
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Merge activity
|
Tiny perf optimization. Reduce complexity of maths by doing as much calculation as possible using consts. Shaves off 1 operation! https://godbolt.org/z/5h4hzznxs This change does not alter the result. `data_offset + RAW_METADATA_SIZE` couldn't overflow because `data_offset` was derived from a `u32`, and this code (raw transfer) is only run on 64-bit systems, so there's plenty of headroom in `usize`. But it does make it easier to support 32-bit in future.
52a3e1e to
ecc9c60
Compare

Tiny perf optimization.
Reduce complexity of maths by doing as much calculation as possible using consts.
Shaves off 1 operation! https://godbolt.org/z/5h4hzznxs
This change does not alter the result.
data_offset + RAW_METADATA_SIZEcouldn't overflow becausedata_offsetwas derived from au32, and this code (raw transfer) is only run on 64-bit systems, so there's plenty of headroom inusize. But it does make it easier to support 32-bit in future.