Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Aug 16, 2025

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.

@github-actions github-actions bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Aug 16, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@overlookmotel overlookmotel marked this pull request as ready for review August 16, 2025 14:48
Copilot AI review requested due to automatic review settings August 16, 2025 14:48
Copy link
Contributor

Copilot AI left a 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.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Aug 16, 2025
Copy link
Member Author

overlookmotel commented Aug 16, 2025

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.
@graphite-app graphite-app bot force-pushed the 08-16-perf_napi_parser_raw_transfer_reduce_maths_complexity branch from 52a3e1e to ecc9c60 Compare August 16, 2025 17:16
@graphite-app graphite-app bot merged commit ecc9c60 into main Aug 16, 2025
17 checks passed
@graphite-app graphite-app bot deleted the 08-16-perf_napi_parser_raw_transfer_reduce_maths_complexity branch August 16, 2025 17:21
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants