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

[Merged by Bors] - Fast path for static property keys #2604

Closed
wants to merge 2 commits into from

Conversation

tunz
Copy link
Contributor

@tunz tunz commented Feb 18, 2023

When a rust string literal is given for a property key, boa checks if it can be parsed as an index and converts the string into a utf16 slice. This PR rewrites each hard-coded property key as a utf16 slice so that we can bypass those conversions at runtime.

This improves QuickJS benchmark score 5% on average.
Richards: 35.4 -> 37.0
DeltaBlue: 35.0 -> 38.1
Crypto: 57.6 -> 59.6
RayTrace: 137 -> 146
EarleyBoyer: 131 -> 138
Splay: 98.3 -> 104
NavierStokes: 10.2 -> 10.2

@codecov
Copy link

codecov bot commented Feb 18, 2023

Codecov Report

Merging #2604 (45e1e12) into main (f538cb2) will increase coverage by 0.10%.
The diff coverage is 60.46%.

@@            Coverage Diff             @@
##             main    #2604      +/-   ##
==========================================
+ Coverage   49.17%   49.28%   +0.10%     
==========================================
  Files         386      385       -1     
  Lines       38843    38989     +146     
==========================================
+ Hits        19102    19214     +112     
- Misses      19741    19775      +34     
Impacted Files Coverage Δ
boa_engine/src/builtins/intl/date_time_format.rs 3.22% <0.00%> (-0.19%) ⬇️
boa_engine/src/builtins/intl/list_format/mod.rs 5.00% <0.00%> (-0.06%) ⬇️
boa_engine/src/builtins/intl/locale/utils.rs 50.34% <0.00%> (+0.34%) ⬆️
boa_engine/src/builtins/intl/options.rs 0.00% <ø> (ø)
.../src/builtins/iterable/async_from_sync_iterator.rs 4.61% <0.00%> (ø)
boa_engine/src/builtins/promise/mod.rs 22.91% <0.00%> (-0.19%) ⬇️
boa_engine/src/builtins/proxy/mod.rs 9.67% <0.00%> (ø)
boa_engine/src/builtins/weak_map/mod.rs 14.63% <0.00%> (ø)
boa_engine/src/builtins/weak_set/mod.rs 14.28% <0.00%> (ø)
boa_engine/src/object/builtins/jsmap.rs 0.00% <0.00%> (ø)
... and 64 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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 optimization!

Copy link
Member

@nekevss nekevss left a comment

Choose a reason for hiding this comment

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

Looks good to me 😄

@nekevss nekevss added this to the v0.17.0 milestone Feb 18, 2023
@nekevss
Copy link
Member

nekevss commented Feb 18, 2023

bors r+

bors bot pushed a commit that referenced this pull request Feb 18, 2023
When a rust string literal is given for a property key, boa checks if it can be parsed as an index and converts the string into a utf16 slice. This PR rewrites each hard-coded property key as a utf16 slice so that we can bypass those conversions at runtime.

This improves QuickJS benchmark score 5% on average.
Richards: 35.4 -> 37.0
DeltaBlue: 35.0 -> 38.1
Crypto: 57.6 -> 59.6
RayTrace: 137 -> 146
EarleyBoyer: 131 -> 138
Splay: 98.3 -> 104
NavierStokes: 10.2 -> 10.2
@bors
Copy link

bors bot commented Feb 18, 2023

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Fast path for static property keys [Merged by Bors] - Fast path for static property keys Feb 18, 2023
@bors bors bot closed this Feb 18, 2023
bors bot pushed a commit that referenced this pull request Feb 19, 2023
Similar to #2604, `GetPropertyByName`/`SetPropertyByName` has only string property key. So, we can skip index and utf16 conversions.

This improves QuickJS benchmark score 5.8% on average.
Richards: 37.0 -> 41.2
DeltaBlue: 38.1 -> 41.4
Crypto: 59.6 -> 59.8
RayTrace: 146 -> 159
EarleyBoyer: 138 -> 142
Splay: 104 -> 106
NavierStokes: 10.2 -> 10.3
bors bot pushed a commit that referenced this pull request Feb 19, 2023
Similar to #2604, `GetPropertyByName`/`SetPropertyByName` has only string property key. So, we can skip index and utf16 conversions.

This improves QuickJS benchmark score 5.8% on average.
Richards: 37.0 -> 41.2
DeltaBlue: 38.1 -> 41.4
Crypto: 59.6 -> 59.8
RayTrace: 146 -> 159
EarleyBoyer: 138 -> 142
Splay: 104 -> 106
NavierStokes: 10.2 -> 10.3
@tunz tunz deleted the tunz/property-key-fast branch July 18, 2023 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants