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

gc performance entries report incorrect startTime #43062

Closed
amilajack opened this issue May 11, 2022 · 0 comments · Fixed by #43066
Closed

gc performance entries report incorrect startTime #43062

amilajack opened this issue May 11, 2022 · 0 comments · Fixed by #43066
Labels
perf_hooks Issues and PRs related to the implementation of the Performance Timing API.

Comments

@amilajack
Copy link
Contributor

Version

v17.9.0

Platform

Darwin Amilas-MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

All performance entries' startTime should be relative to performance.timeOrigin.

repro:

import { PerformanceObserver } from "perf_hooks";

const formatTime = (ms) => new Date(ms).toLocaleString();

console.log(`time origin: ${formatTime(performance.timeOrigin)}`);

// observe mark and gc entries
const observer = new PerformanceObserver((list) => {
  list.getEntries().forEach(({ entryType, startTime }) => {
    // gc performance entries aren't relative to timeOrigin
    console.log(entryType, formatTime(startTime + performance.timeOrigin));
  });
});
observer.observe({
  entryTypes: ["mark", "gc"],
});

// Mark entries are relative to timeOrigin
performance.mark("foo");

// Create some objects
setInterval(() => {
  const arr = new Array(1_000_000).fill(0);
  for (let i = 0; i < arr.length; i++) {
    arr[i] += 1;
  }
}, 1_000);

output:

time origin: 5/11/2022, 11:07:35 AM # correct
mark 5/11/2022, 11:07:35 AM            # correct
gc 5/20/2022, 10:23:36 AM              # incorrect
gc 5/20/2022, 10:23:36 AM              # incorrect
gc 5/20/2022, 10:23:37 AM              # incorrect
gc 5/20/2022, 10:23:38 AM              # incorrect
gc 5/20/2022, 10:23:39 AM              # incorrect

I've created a repl.it reproducing the bug.

How often does it reproduce? Is there a required condition?

I can reproduce it 100% of the time.

What is the expected behavior?

All performance entries' startTime should be relative to performance.timeOrigin. This isn't the case for the gc entry.

What do you see instead?

the startTime of gc performance entries are off by hours (see example output)

Additional information

No response

@meixg meixg added the perf_hooks Issues and PRs related to the implementation of the Performance Timing API. label May 12, 2022
theanarkh added a commit to theanarkh/node that referenced this issue May 12, 2022
theanarkh added a commit to theanarkh/node that referenced this issue May 12, 2022
aduh95 pushed a commit that referenced this issue Jun 17, 2022
PR-URL: #43066
Fixes: #43062
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Jul 12, 2022
PR-URL: #43066
Fixes: #43062
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Jul 18, 2022
PR-URL: #43066
Fixes: #43062
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Jul 31, 2022
PR-URL: #43066
Fixes: #43062
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
guangwong pushed a commit to noslate-project/node that referenced this issue Oct 10, 2022
PR-URL: nodejs/node#43066
Fixes: nodejs/node#43062
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf_hooks Issues and PRs related to the implementation of the Performance Timing API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants