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

fix: performance.timeOrigin #26787

Merged
merged 1 commit into from
Nov 8, 2024
Merged

fix: performance.timeOrigin #26787

merged 1 commit into from
Nov 8, 2024

Conversation

devsnek
Copy link
Member

@devsnek devsnek commented Nov 8, 2024

performance.timeOrigin was being set from when JS started executing, but op_now measures from an std::time::Instant stored in OpState, which is created at a completely different time. This caused performance.timeOrigin to be very incorrect. This PR corrects the origin and also cleans up some of the timer code.

Compared to Date.now(), performance's time origin is now consistently within 5us (0.005ms) of system time.

image

@devsnek devsnek requested a review from bartlomieju November 8, 2024 09:10
Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

LGTM

@devsnek devsnek merged commit 73fbd61 into main Nov 8, 2024
17 checks passed
@devsnek devsnek deleted the fix-perf-origin branch November 8, 2024 22:20
littledivy pushed a commit that referenced this pull request Nov 10, 2024
`performance.timeOrigin` was being set from when JS started executing,
but `op_now` measures from an `std::time::Instant` stored in `OpState`,
which is created at a completely different time. This caused
`performance.timeOrigin` to be very incorrect. This PR corrects the
origin and also cleans up some of the timer code.

Compared to `Date.now()`, `performance`'s time origin is now
consistently within 5us (0.005ms) of system time.


![image](https://github.com/user-attachments/assets/0a7be04a-4f6d-4816-bd25-38a2e6136926)
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.

2 participants