flutter / devtools

Performance tools for Flutter
https://flutter.dev/docs/development/tools/devtools/
BSD 3-Clause "New" or "Revised" License
1.58k stars 324 forks source link

Performance improvements to CPU profile code #7917

Open mkustermann opened 3 months ago

mkustermann commented 3 months ago

After having taken a look at the cpu profiling code in DevTools, we found:

It seems there's too many conversions from one data structure to another and the representations used for encoding this profiling information doesn't seem very efficient either.

kenzieschmoll commented 3 months ago

CC @bkonyi

mkustermann commented 3 months ago

Another thing is that I believe loading CPU profiles can freeze the UI for a while - most likely due to all this work happening synchronously without any yields to the event loop. I have observed 80 MB of json to be loaded for cpu profile, which may result in quite a bit more of in-memory json (consumed by maps, lists, etc - which aren't as compact as in the encoded form) - possibly 100s of MBs it's churning through synchronously several times.

kevmoo commented 3 months ago

Could we make this function async? Then we can batch the processing and avoid janking frames...

mkustermann commented 1 month ago

Friendly ping. @kenzieschmoll @bkonyi Are there plans on improving this in the short/mid term?

kenzieschmoll commented 1 month ago

@mkustermann thanks for the performance analysis. It sounds like all of your recommendations would be great improvements. In practice, this isn't something we have the cycles to work on in the short term, but are more than happy to accept & review contributions if you'd like to take a stab at any of these.