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

Combine HasProperty and Get operations when possible #3883

Merged
merged 1 commit into from
Jun 30, 2024

Conversation

raskad
Copy link
Member

@raskad raskad commented Jun 29, 2024

This PR creates a new object operation that combines the HasProperty and Get operations.

In some cases in the spec HasProperty and Get are called on an object, with the same arguments, directly following each other. Both operations boil down to (in most cases) [[GetOwnProperty]], just that HasProperty does not return the value. To avoid duplicating the exact same operations we can combine both operations.

I have some Flame Graphs from a GetName operation to visualize the benefit:

Before:
image
After:
image

I also ran the benchmarks:

Before:

RESULT Richards 54.3
RESULT DeltaBlue 58.2
RESULT Crypto 68.4
RESULT RayTrace 186
RESULT EarleyBoyer 170
RESULT RegExp 58.6
RESULT Splay 195
RESULT NavierStokes 159
SCORE 103

After:

RESULT Richards 55.1
RESULT DeltaBlue 59.6
RESULT Crypto 68.1
RESULT RayTrace 187
RESULT EarleyBoyer 176
RESULT RegExp 58.5
RESULT Splay 195
RESULT NavierStokes 160
SCORE 104

@raskad raskad added performance Performance related changes and issues execution Issues or PRs related to code execution labels Jun 29, 2024
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 50,213 50,213 0
Passed 42,981 42,981 0
Ignored 1,411 1,411 0
Failed 5,821 5,821 0
Panics 0 0 0
Conformance 85.60% 85.60% 0.00%

@raskad raskad requested a review from a team June 29, 2024 18:56
@jedel1043
Copy link
Member

jedel1043 commented Jun 29, 2024

Really nice optimization! I'm seeing that all our usages of the new method are made internally, so I was curious if we could set up inline caching manually to optimise the calls even more.

EDIT: cc @HalidOdat

@HalidOdat
Copy link
Member

Yeah that was one of the things that could be optimized, though I didn't find a good way of doing it, one potentially viable idea I had was to have a global hash table on the context (with limited entries).

Copy link
Member

@HalidOdat HalidOdat 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! :)

@HalidOdat HalidOdat added this pull request to the merge queue Jun 30, 2024
Merged via the queue into main with commit 9738d44 Jun 30, 2024
13 checks passed
@HalidOdat HalidOdat deleted the optimization-try-get branch June 30, 2024 09:40
@raskad raskad modified the milestones: v0.18.1, v0.19.0 Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
execution Issues or PRs related to code execution performance Performance related changes and issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants