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

DevTools reports 100% CPU while doing nothing #21620

Open
alexgleason opened this issue Dec 17, 2023 · 6 comments
Open

DevTools reports 100% CPU while doing nothing #21620

alexgleason opened this issue Dec 17, 2023 · 6 comments
Labels
debugger Chrome DevTools inspector/debugger integration upstream Changes in upstream are required to solve these issues

Comments

@alexgleason
Copy link
Contributor

Version: Deno 1.39.0
Chromium: 120.0.6099.71

I created a simple reproduction script, gg.ts:

while (true) {
  await new Promise((resolve) => setTimeout(resolve, 1000));
}

Running it with deno run --inspect gg.ts and then viewing it in Chromium DevTools, the histogram at the top shows 100% CPU usage.

image

You can check my results in your DevTools here: CPU-20231217T142344.cpuprofile

This started happening recently, and I don't know why. The CPU itself is not close to 100% on any core when viewed with htop. The problem does not occur when profiling a normal webpage in the same browser, just when inspecting Deno.

@bartlomieju
Copy link
Member

bartlomieju commented Dec 17, 2023

I believe this diagram doesn't show actual CPU usage, but show percentage of time the program spents in CPU. The (program) you see on your flamegraph is Devtools way of saying that it's running native code (the timer implementation) and the actual JavaScript code (all the function below eventLoopTick take 0ms - which is timer firing). So if anything I guess it's poor representation from Devtools perspective.

As a side note: timers are known to have poor performance: #20356 and there's ongoing work to speed them up: #20428

@alexgleason
Copy link
Contributor Author

I was able to dig up an old screenshot from some Deno profiling I did on November 20th:

Screenshot from 2023-11-20 19-21-32

The CPU chart at the top looks correct in this version.

I tried reverting my codebase to an old version (and downgrading to Deno 1.36), and I'm still having the problem in this issue. So that suggests to me something changed in Chromium rather than Deno, that makes Deno profiling a lot less useful.

@bartlomieju
Copy link
Member

I tried reverting my codebase to an old version (and downgrading to Deno 1.36), and I'm still having the problem in this issue. So that suggests to me something changed in Chromium rather than Deno, that makes Deno profiling a lot less useful.

I agree, IIRC a couple months back (program) was colored in gray and didn't count towards "Scripting" category (which it does now).

Chrome DevTools devs asked for feedback on this panel, which appears to just been closed: ChromeDevTools/rfcs#2 I suggest to open an issue with them. I'll be happy to coordinate on that.

@alexgleason
Copy link
Contributor Author

Thanks @bartlomieju, opened an issue here: https://bugs.chromium.org/p/chromium/issues/detail?id=1512463

@littledivy littledivy added upstream Changes in upstream are required to solve these issues debugger Chrome DevTools inspector/debugger integration labels Dec 18, 2023
@june07
Copy link
Contributor

june07 commented Aug 9, 2024

See #24877 (comment) for a workaround/fix that is just as applicable to this issue.

@alexgleason
Copy link
Contributor Author

This issue is still occurring on Deno 2.0 and Chromium 129 (the latest version). The people on the Chromium issue tracker didn't want to install Deno to test it. 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debugger Chrome DevTools inspector/debugger integration upstream Changes in upstream are required to solve these issues
Projects
None yet
Development

No branches or pull requests

4 participants