wagoodman / dive

A tool for exploring each layer in a docker image
MIT License
47.45k stars 1.79k forks source link

Stuck when analyzing large image #393

Open Ironeie opened 2 years ago

Ironeie commented 2 years ago

My machine has memory of 32G, and can analyze tiny image normally using dive. But when I analyze an image of 20G, I can barely control the cursor with pressing up and down on the keyboard (long delay), and it will be stucked when the cursor moves to the bottom or the top, where I can't see any message of Image Details (blocked by layer info). Sinece the memory is not run out, is there any bug when analyzing large image?

mark2185 commented 2 years ago

I'm 99% sure your problems would be fixed if the filetree wasn't updated with each cursor move. Is that an option for you, or is the filetree the thing you'd want to inspect?

rodrigobdz commented 2 years ago

@mark2185 Hiding the filetree would be an option for me. How can I hide it? I didn't find any CLI option to do so or any documentation in the readme.

This issue might be also related to https://github.com/wagoodman/dive/issues/393.

mark2185 commented 2 years ago

@rodrigobdz there isn't an option for that, I was thinking more in the lines of disabling it in the code and building it locally. I'll take a look today to aid you what to comment out.

This issue might be also related to https://github.com/wagoodman/dive/issues/393.

This is #393, though?

rodrigobdz commented 2 years ago

You're right, I meant https://github.com/wagoodman/dive/issues/288. Thanks, Mark

mark2185 commented 2 years ago

@rodrigobdz sorry for the late reply.

Here's the patch:

diff --git a/runtime/ui/controller.go b/runtime/ui/controller.go
index 964fb83..3eedb56 100644
--- a/runtime/ui/controller.go
+++ b/runtime/ui/controller.go
@@ -85,10 +85,10 @@ func (c *Controller) onLayerChange(selection viewmodel.LayerSelection) error {
    c.views.Details.SetCurrentLayer(selection.Layer)

    // update the filetree
-   err := c.views.Tree.SetTree(selection.BottomTreeStart, selection.BottomTreeStop, selection.TopTreeStart, selection.TopTreeStop)
-   if err != nil {
-       return err
-   }
+   // err := c.views.Tree.SetTree(selection.BottomTreeStart, selection.BottomTreeStop, selection.TopTreeStart, selection.TopTreeStop)
+   // if err != nil {
+   //  return err
+   // }

    if c.views.Layer.CompareMode() == viewmodel.CompareAllLayers {
        c.views.Tree.SetTitle("Aggregated Layer Contents")

This will stop the tree from updating.

Feel free to apply it on top of #399 , it should make dive a bit more pleasant to use. (the hashes are different so here's the new patch)

diff --git a/runtime/ui/controller.go b/runtime/ui/controller.go
index bc76423..26ba3ff 100644
--- a/runtime/ui/controller.go
+++ b/runtime/ui/controller.go
@@ -85,10 +85,10 @@ func (c *Controller) onLayerChange(selection viewmodel.LayerSelection) error {
    c.views.LayerDetails.CurrentLayer = selection.Layer

    // update the filetree
-   err := c.views.Tree.SetTree(selection.BottomTreeStart, selection.BottomTreeStop, selection.TopTreeStart, selection.TopTreeStop)
-   if err != nil {
-       return err
-   }
+   // err := c.views.Tree.SetTree(selection.BottomTreeStart, selection.BottomTreeStop, selection.TopTreeStart, selection.TopTreeStop)
+   // if err != nil {
+   //  return err
+   // }

    if c.views.Layer.CompareMode() == viewmodel.CompareAllLayers {
        c.views.Tree.SetTitle("Aggregated Layer Contents")
rodrigobdz commented 2 years ago

@mark2185 Wow, thank you very much for helping out! 💯

mark2185 commented 2 years ago

No problem, glad to have helped!

aburgel commented 1 year ago

@mark2185 thanks for the tip on how to speed this up!

is it possible to turn your patch into a config option? seems like it would be pretty useful for others who are analyzing large images.

mark2185 commented 1 year ago

Well, it disabled the treeview completely so I wouldn't have that as a config option (unless you can toggle it back on during runtime).

Would you like to try and give it a shot? :)

I.e. a launch flag to run dive with the treeview disabled, and then toggle the treeview during runtime.

Thinkscape commented 6 months ago

Can we get some 👁️ on this please? ❤️ The whole point of dive is to analyse large images -- running it on 7GB image (lots of small files from node_modules) makes a 16 core machine come to a crawl with every keystroke, making the tool unusable. It fits in around 10GB of RAM (all physical) but the CPU is crying at 100% usage.

Maybe it's the tree implementation? Maybe it's re-rendering unnecessarily outside of the viewport?

theAkito commented 4 months ago

I was about to open an issue regarding dive not working at all, after analysing an image, as all user input is seemingly ignored by the application. This issue made me check and realise, that it's only related to the image size. I have an image of over 2GB and dive is absolutely useless, because all user input is being ignored.

Since this tool is mainly supposed to be used with larger images, it kind of doesn't make sense, that it doesn't work at all, with an image, that is over 2GB in size.

Thinkscape commented 4 months ago

Since this tool is mainly supposed to be used with larger images, it kind of doesn't make sense, that it doesn't work at all, with an image, that is over 2GB in size.

💯

Running Dive on my 2.2GB image eats up 10GB of RAM and 100% cpu on each keystroke for like 30s.