profiler icon indicating copy to clipboard operation
profiler copied to clipboard

"Traced running time" is incorrect and meaningless on merged threads

Open mstange opened this issue 3 years ago • 7 comments
trafficstars

Profile: https://share.firefox.dev/3ptwJzF

In this merged thread, for CFRunLoopRunSpecific the sidebar shows "Traced running time: 138ms" and "Running samples: 2677".

This does not make much sense.

mstange avatar Dec 06 '21 02:12 mstange

My guess is that the interleaved samples are causing this issue.

gregtatum avatar Dec 06 '21 14:12 gregtatum

How would you compute this value in threads with interleaved samples?

mstange avatar Dec 06 '21 20:12 mstange

I guess you would need to add another array for the TID of the sample in the merged thread.

Thread { ..., tid?: TID[] }

Then in the for loop computing traced timing, look up the last call node index for that given thread, and accumulate that thread's timing.

gregtatum avatar Dec 07 '21 16:12 gregtatum

Oh, interesting.

mstange avatar Dec 07 '21 16:12 mstange

I believe this is related to https://github.com/firefox-devtools/profiler/issues/2783

julienw avatar Dec 08 '21 11:12 julienw

Well, somewhat - with a tid you could draw separate stack charts, maybe split the stack chart vertically into N horizontal bands, one band for each thread. The tid would also let us draw a more accurate CPU usage graph on a merged thread.

mstange avatar Dec 08 '21 15:12 mstange

It might be worth to break out these tid ideas into separate issues, as they all seem pretty useful to me.

gregtatum avatar Dec 09 '21 22:12 gregtatum