-
-
Notifications
You must be signed in to change notification settings - Fork 158
perf(runtime): lean Map/Set lookup lanes; empty-array pop fast path; single-pass length-0 re-arm (ECS round 4, +5.6%) #8934
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
Merged
proggeramlug
merged 5 commits into
PerryTS:main
from
proggeramlug:perf/ecs-r4-collections
Aug 28, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
94238e0
perf(runtime): Map lookups run a lean numeric lane before the general…
840faa7
perf(runtime): small-Set lookups scan the members before the side-table
9bf5aff
perf(runtime): pop on an empty plain array answers from the header fa…
fc5e9ae
tests(array): split the pop/push tests into a sibling file for the 20…
3f04b69
changelog: fragment for #8934
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - **runtime:** `Map` lookups run an always-inlined numeric lane (small-map bit-identity scan or the dense integer range table) ahead of the outlined general `find_key_index`; small `Set` (≤ 8) number lookups scan the members before the two-hash side-table; `pop()` on an empty plain array answers from the header fast path; `length = 0` on an all-pointer array re-arms its layout in one registry pass. `codehz/ecs` "5k entities: 3 commands each + sync": +3.3%, +1.8%, +0.5% (15/15 paired runs each). |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| //! `pop` / `push` unit tests — split from `array/tests.rs` for the | ||
| //! 2000-line file-size gate (extract a cohesive group into a sibling file, | ||
| //! wire it with an explicit `mod`). No logic change. | ||
|
|
||
| use super::*; | ||
|
|
||
| /// `pop()` on an empty plain array is answered from the header fast path: | ||
| /// `undefined`, length untouched — the drained pool's `pool.pop() ?? []`. | ||
| #[test] | ||
| fn pop_on_an_empty_plain_array_is_undefined_from_the_fast_path() { | ||
| let arr = js_array_alloc(4); | ||
| assert_eq!( | ||
| js_array_pop_f64(arr).to_bits(), | ||
| crate::value::TAG_UNDEFINED, | ||
| "fresh empty array" | ||
| ); | ||
| assert_eq!(js_array_length(arr), 0); | ||
|
|
||
| let arr = js_array_push_f64(arr, 1.0); | ||
| assert_eq!(js_array_pop_f64(arr), 1.0); | ||
| assert_eq!( | ||
| js_array_pop_f64(arr).to_bits(), | ||
| crate::value::TAG_UNDEFINED, | ||
| "emptied by a pop" | ||
| ); | ||
| assert_eq!(js_array_length(arr), 0); | ||
| // The slot the pop retired reads as a hole for a later length extension, | ||
| // exactly as before: nothing on the empty arm touches the payload. | ||
| js_array_set_length(arr, 1.0); | ||
| assert_eq!( | ||
| array_spec_get(arr, 0).to_bits(), | ||
| crate::value::TAG_UNDEFINED | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_array_pop_and_push() { | ||
| let arr = js_array_alloc(4); | ||
| let arr = js_array_push_f64(arr, 1.0); | ||
| let arr = js_array_push_f64(arr, 2.0); | ||
| let arr = js_array_push_f64(arr, 3.0); | ||
|
|
||
| let popped = js_array_pop_f64(arr); | ||
| assert_eq!(popped, 3.0); | ||
| assert_eq!(js_array_length(arr), 2); | ||
|
|
||
| let arr = js_array_push_f64(arr, 4.0); | ||
| assert_eq!(js_array_length(arr), 3); | ||
| assert_eq!(js_array_get_f64(arr, 2), 4.0); | ||
| } |
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.