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(core): do not mix UNIX and performance API timestamps in profiles #18497

Conversation

hristozov
Copy link

Current Behavior

TaskProfilingLifeCycle calculates profile timestamps and durations based on a mix of performance timestamps (coming from performance.now()) and UNIX ones (coming from tasks).

The problem comes when the two types of values are mixed - e.g. perfStart comes from the task and perfEnd comes from the performance API, or vice-versa. Since performance timestamps are relative to the process start and UNIX timestamps are relative to the UNIX epoch, such cases would result in wrong calculations - e.g. an enormous negative value if perfStart is a UNIX timestamps and perfEnd is a performance timestamp.

Expected Behavior

TaskProfilingLifeCycle should produce profiles with correct durations.

Change overview

Do not store UNIX timestamps at all. Instead, use only performance ones for the calculations.

Related Issue(s)

Fixes #18388

`TaskProfilingLifeCycle` calculates profile timestamps and durations based
on a mix of performance timestamps (coming from `performance.now()`) and
UNIX ones (coming from tasks).

The problem comes when the two types of values are mixed - e.g.
`perfStart` comes from the task and `perfEnd` comes from the performance
API, or vice-versa. Since performance timestamps are relative to the
process start and UNIX timestamps are relative to the UNIX epoch, such
cases would result in wrong calculations - e.g. an enormous negative
value if `perfStart` is a UNIX timestamps and `perfEnd` is a performance
timestamp.

Closes nrwl#18388
@hristozov hristozov requested a review from a team as a code owner August 4, 2023 16:37
@vercel
Copy link

vercel bot commented Aug 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 4, 2023 4:41pm

@AgentEnder
Copy link
Member

Hey @hristozov 👋, thanks for the PR. I've discussed this with @barbados-clemens and determined that we should go the other way. This implementation misses some specifics when batch mode is enabled.

Can you try out #18595 and make sure it resolves the issue for you?

@AgentEnder AgentEnder closed this Aug 11, 2023
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sometimes profiles have negative durations
2 participants