Skip to contentSkip to conversation

Too much memory consumption by powertop

Powertop Thomas Renninger 4 participants 4 messages Apr 28, 2015

lore
Share & tools
lore

Thomas Renninger

author
#0 lore raw

As powertop list is for subscribers only, here Takashi's findings concerning a big memory waste fowarded:

---------- Forwarded Message ----------

Subject: Too much memory consumption by powertop
Date: Tuesday, April 28, 2015, 05:32:41 PM
From: Takashi Iwai <tiwai(a)suse.de>
To: powertop(a)lists.01.org
CC: trenn(a)suse.de

Hi,

I noticed that powertop consumes way too much memory than needed. It constantly takes over 170MB RES, sometimes over 200MB.

Then I looked at profile, and it showed that most of memory is allocated for newpad_sp(). Indeed, the current code allocates a pad of the fixed size of 1000x1000 (!) for each tab, and we have five tabs, so five times of that. No wonder that such a small neat CUI program is so hungry.

For example, a hack like below already reduces the memory footprint to around 20MB, 90% cut. Not bad.

src/display.cpp +1 -1
@@ -48,7 +48,7 @@ void create_tab(const string &name, cons
        if (!w)
                w = new(class tab_window);
 
-       w->win = newpad(1000,1000);
+       w->win = newpad(80,160); // XXX FIXME XXX
        tab_names.push_back(name);
        tab_windows[name] = w;
        tab_translations[name] = translation;

Can anyone look into this and give a better / smarter solution?

thanks,

Takashi
-----------------------------------------

#1 lore raw
Quoted 41 lines

As powertop list is for subscribers only, here Takashi's findings concerning a big memory waste fowarded:

---------- Forwarded Message ----------

Subject: Too much memory consumption by powertop
Date: Tuesday, April 28, 2015, 05:32:41 PM
From: Takashi Iwai <tiwai(a)suse.de>
To: powertop(a)lists.01.org
CC: trenn(a)suse.de

Hi,

I noticed that powertop consumes way too much memory than needed. It constantly takes over 170MB RES, sometimes over 200MB.

Then I looked at profile, and it showed that most of memory is allocated for newpad_sp(). Indeed, the current code allocates a pad of the fixed size of 1000x1000 (!) for each tab, and we have five tabs, so five times of that. No wonder that such a small neat CUI program is so hungry.

For example, a hack like below already reduces the memory footprint to around 20MB, 90% cut. Not bad.

src/display.cpp +1 -1
@@ -48,7 +48,7 @@ void create_tab(const string &name, cons
        if (!w)
                w = new(class tab_window);
 
-       w->win = newpad(1000,1000);
+       w->win = newpad(80,160); // XXX FIXME XXX
        tab_names.push_back(name);
        tab_windows[name] = w;
        tab_translations[name] = translation;

Can anyone look into this and give a better / smarter solution?

Quoted 9 lines

thanks,

Takashi
-----------------------------------------
_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop

To avoid the high memory consumption on testing run it on HTML mode so that the powertop.html report is generated in the background.

Thank you,
Alexandra.

#2 lore raw
Quoted 38 lines · Alexandra Yates
Quoted 38 lines

As powertop list is for subscribers only, here Takashi's findings concerning a big memory waste fowarded:

---------- Forwarded Message ----------

Subject: Too much memory consumption by powertop
Date: Tuesday, April 28, 2015, 05:32:41 PM
From: Takashi Iwai <tiwai(a)suse.de>
To: powertop(a)lists.01.org
CC: trenn(a)suse.de

Hi,

I noticed that powertop consumes way too much memory than needed. It constantly takes over 170MB RES, sometimes over 200MB.

Then I looked at profile, and it showed that most of memory is allocated for newpad_sp(). Indeed, the current code allocates a pad of the fixed size of 1000x1000 (!) for each tab, and we have five tabs, so five times of that. No wonder that such a small neat CUI program is so hungry.

For example, a hack like below already reduces the memory footprint to around 20MB, 90% cut. Not bad.

src/display.cpp +1 -1
@@ -48,7 +48,7 @@ void create_tab(const string &name, cons
        if (!w)
                w = new(class tab_window);
 
-       w->win = newpad(1000,1000);
+       w->win = newpad(80,160); // XXX FIXME XXX
        tab_names.push_back(name);
        tab_windows[name] = w;
        tab_translations[name] = translation;
Quoted 4 lines
Quoted 1 line

Can anyone look into this and give a better / smarter solution?

To avoid the high memory consumption on testing run it on HTML mode so that the powertop.html report is generated in the background.

Right, but if you do want to run it in a terminal, 80x160 would limit the size of the viewport to just a standard 80cols worth, which isn't very wide.

Maybe a more sensible 250x250 size would be a good default, as I seem to be able to fill a 1080p screen with just under 250 columns, and it would give some scrolling overhead?

that's at least a 16x reduction already compared to 1000x1000.

You could dynamically calculate the number based on the terminal properties, but that would likely break on terminal resizes.

Cheers,

Auke

#3 lore raw
Quoted 5 lines

Maybe a more sensible 250x250 size would be a good default, as I seem to be able to fill a 1080p screen with just under 250 columns, and it would give some scrolling overhead?

that's at least a 16x reduction already compared to 1000x1000.

You could dynamically calculate the number based on the terminal properties, but that would likely break on terminal resizes.

it;s a bit more subtle

this is the canvas on which the text gets put, your terminal is just a viewport into that canvas.

the number of cpus etc determines how big that canvas needs to be, not the width of our terminal