discoveryjs / cpupro

Rethinking of CPU profile analysis
https://discoveryjs.github.io/cpupro/
MIT License
464 stars 7 forks source link

Hairy CPU profile stalls out UI #5

Closed paulirish closed 6 months ago

paulirish commented 6 months ago

Hey Roman! cpupro is badass. :D nice work I just came across the project today. I'm excited to dig in and learn quite a few things.


But first thing I did was drag in a particularly heavy CPU profile. The tab gets totally hung (at least for 30sec).

Here's the repro: large-profile.cpuprofile.zip

I figured you'd want these cases. :)

You'll probably hear from me again soon. Cheers!

lahmatiy commented 6 months ago

@paulirish Thank you for your feedback and report. I appreciate it!

Yes, I'm very interested in such cases. This way, neither you, the users, nor I will encounter problems when analyzing any profile :)

I took a look at your profile. It uses parent instead of children for the call tree nodes. I've never seen such a structure in profiles from the V8 CPU profiler (.cpuprofile files), only in the Chromium Performance Profile files (as far as I can tell, CPP may contain children, parent, or both in ProfileChunks depending on the Chromium version, so cpupro supports all the cases). Therefore, cpupro expects children for .cpuprofile files, and the logic to transform parent into children is located only in CPP file processing. It seems that applying this logic to .cpuprofile as well files fixes the problem.

A patch is on the way.

lahmatiy commented 6 months ago

@paulirish The issue has been resolved. Please try your profile now. It takes only 0.4s for me.

I also discovered another issue with your profile. For some reason, the time from the last sample until endTime is significant. I suspect it's the time needed to conclude the profiling session or adjustments from excluding idle samples at the end. Regardless, this time is now excluded from the "Profiling time" used to compute time percentages. I've also updated the hint content to explain this:

image