Skip to content
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

Dense array storage variants for i32 and f64 #3760

Merged
merged 5 commits into from
Mar 24, 2024
Merged

Dense array storage variants for i32 and f64 #3760

merged 5 commits into from
Mar 24, 2024

Conversation

HalidOdat
Copy link
Member

@HalidOdat HalidOdat commented Mar 23, 2024

This PR adds dense variants for array storage (i32 and f64) this is mostly a memory optimization, this optimization is also implemented by v8 (they have even more granular types like sparse i32 and f64 variants).

Storing number i32 numbers in a dense array now takes 6x less memory and 3x less memory for f64 (since JsValue is 24 bytes)

This PR also applies the changes in #3744 , because with this PR it complicates that fast path too much. Since the patch introduces a regression for setting new properties in arrays, this PR amortizes the regression, it's pretty much the same with the current performance in quickjs benchmarks.

Even though I implemented that fast path, I was never happy with it 😅 (because it has too much duplicate logic), it was a quick way to improve performance, but I think the better option is to improve the internal object methods, which should give overall better performance.

@HalidOdat HalidOdat added performance Performance related changes and issues memory PRs and Issues related to the memory management or memory footprint. Internal Category for changelog labels Mar 23, 2024
@HalidOdat HalidOdat changed the title Dense arrays Dense array storage variants for i32 and f64 Mar 23, 2024
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 50,268 50,268 0
Passed 42,776 42,777 +1
Ignored 1,391 1,391 0
Failed 6,101 6,100 -1
Panics 0 0 0
Conformance 85.10% 85.10% +0.00%
Fixed tests (1):
test/language/statements/for-in/head-lhs-let.js (previously Failed)

@HalidOdat HalidOdat added this to the v0.18.1 milestone Mar 23, 2024
Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice optimization!

@raskad raskad requested a review from a team March 23, 2024 23:26
Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I just have some suggestions which are just nitpicks, but I'm approving anyways since those aren't essential per se.

core/engine/src/object/property_map.rs Outdated Show resolved Hide resolved
core/engine/src/object/property_map.rs Outdated Show resolved Hide resolved
@raskad raskad added this pull request to the merge queue Mar 24, 2024
Merged via the queue into main with commit d3e5395 Mar 24, 2024
13 checks passed
@HalidOdat HalidOdat deleted the dense-arrays branch March 24, 2024 03:53
@raskad raskad modified the milestones: v0.18.1, v0.19.0 Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Category for changelog memory PRs and Issues related to the memory management or memory footprint. performance Performance related changes and issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants