devtools icon indicating copy to clipboard operation
devtools copied to clipboard

slow performance when taking a heap snapshot

Open kenzieschmoll opened this issue 3 years ago • 7 comments

we should batch work so we don't freeze the ui while a snapshot is being taken and the data is being processed.

kenzieschmoll avatar Nov 21 '22 18:11 kenzieschmoll

I just encountered this action taking 30+ seconds to finish. It took so long that the Chrome "this page has become unresponsive" message popped up: Screenshot 2023-01-18 at 9 35 35 AM

Raising the priority of this, as 30 seconds is a pretty poor experience. The loading spinner froze, so that means we likely need to split the work up into batches in addition to improving the overall performance of the operation.

kenzieschmoll avatar Jan 18 '23 17:01 kenzieschmoll

raising the priority of this. I just tried to take a heap snapshot from a dart command line application (the web-test app that @CoderDake uses), and it took over a minute. The second snapshot took more than 2 minutes.

I was running DevTools in profile mode on the web flutter run -d chrome --profile, and the test app was a dart cli app.

kenzieschmoll avatar Mar 23 '23 19:03 kenzieschmoll

The performance of taking a snapshot is still very slow. I'm running gallery on an iOS simulator and it took 20 seconds to take a snapshot. This work is hogging the UI thread and stalling the DevTools UI. We need to find a way to optimize this. Maybe we can look into using flutter compute if it can now return non primitive types: https://api.flutter.dev/flutter/foundation/compute.html

kenzieschmoll avatar Jul 21 '23 17:07 kenzieschmoll

It is not possible to do on flutter web: https://github.com/flutter/flutter/issues/33577 So, I suggest to postpone this till resolution of the issue. Reducing priority to P2 for now.

polina-c avatar Aug 22 '23 18:08 polina-c

This is still worth investigating to see if there is any way we can improve the performance without using compute. 30+ seconds is really long to ask users to wait.

kenzieschmoll avatar Aug 22 '23 18:08 kenzieschmoll

Sometimes it's much longer. I took a snapshot earlier; probably took more than 5 minutes. I'm right now waiting for a second snapshot; it's been going for like 5, maybe 15 minutes.

Erhannis avatar Oct 03 '23 17:10 Erhannis

Via https://github.com/flutter/devtools/issues/5944, I ran devtools as a native app. I did manage to get two snapshots, though maybe I was just faster to click the snapshot button and my app didn't have as much time to build up references. One thing I notice, though, is that taking snapshots and exporting a CSV diff can cause devtool's memory usage to swell rapidly out of control - like 25GB (maxing out my system) in a minute or two. My app only uses like, a few hundred MB. Devtools says the snapshots are ~100MB.

Erhannis avatar Oct 03 '23 21:10 Erhannis