perf(allocator/vec2): reorder RawVec fields#11050
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. |
CodSpeed Instrumentation Performance ReportMerging #11050 will not alter performanceComparing Summary
|
67d4c03 to
f2e5a99
Compare
RawVec fields
9a30fb7 to
25c0469
Compare
7c5d8af to
c60382d
Compare
There was a problem hiding this comment.
Pull Request Overview
This pull request reorders the RawVec fields to optimize performance by placing the most frequently accessed field (len) immediately after the pointer.
- Updated the field offset constant in the raw transfer generator to reflect the new layout.
- Reordered the struct fields in
RawVecso thatlennow directly follows the pointer.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tasks/ast_tools/src/generators/raw_transfer.rs | Updated the constant offset for Vec's length field to match the new field ordering in RawVec. |
| crates/oxc_allocator/src/vec2/raw_vec.rs | Reordered RawVec fields from the previous order to a new order (ptr, len, cap, a) to improve performance. |
Comments suppressed due to low confidence (2)
tasks/ast_tools/src/generators/raw_transfer.rs:30
- The VEC_LEN_FIELD_OFFSET value is updated to 8 to reflect the new field order in RawVec. Please verify that the adjusted offset aligns with all expected memory layout assumptions, especially regarding pointer size across architectures.
const VEC_LEN_FIELD_OFFSET: usize = 8;
crates/oxc_allocator/src/vec2/raw_vec.rs:70
- Reordering the RawVec fields so that 'len' is placed immediately after the pointer should enhance performance. Confirm that this reordering is consistently reflected in all related code that relies on the struct layout.
cap: u32,
Merge activity
|
According to `len` is more commonly used than `cap` and `a` is used less than any other field, reorder `RawVec` fields to get the best performance. <img width="721" alt="image" src="https://github.com/user-attachments/assets/c044e134-2d28-45a4-8d8d-91ec5166612f" /> I've tried putting `cap` before `len`, the performance is not as good as the current order, see #11050 (comment)
25c0469 to
5dcd0f1
Compare


According to
lenis more commonly used thancapandais used less than any other field, reorderRawVecfields to get the best performance.I've tried putting
capbeforelen, the performance is not as good as the current order, see #11050 (comment)