<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5833240877872020905</id><updated>2011-04-21T22:25:41.943-07:00</updated><title type='text'>Paul's blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://paul-pach.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5833240877872020905/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://paul-pach.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Paul</name><uri>http://www.blogger.com/profile/05118763270998458090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://bp0.blogger.com/_6EDGtMo8jsQ/SAjjhii8LYI/AAAAAAAAACs/764rstWQ7LQ/S220/paul.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5833240877872020905.post-4070086011014872294</id><published>2008-04-16T19:08:00.000-07:00</published><updated>2008-12-09T08:18:42.264-08:00</updated><title type='text'>Teaching kde how to share</title><content type='html'>First post seemed to have been well received, so I will try keep it up.&lt;br /&gt;&lt;br /&gt;Part of the advantage of using KDE is all the libraries and framework available for your program. By using a few shared libraries, you get for free a ton of functionality. The shared libraries can be shared between multiple processes, so memory consumption also goes down.&lt;br /&gt;&lt;br /&gt;... or so you would think.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.berthels.co.uk/exmap/"&gt;Exmap&lt;/a&gt; can list memory consumption by shared library (what a wonderful tool), so I can quickly verify whether they are being efficiently shared by multiple processes.&lt;br /&gt;&lt;br /&gt;So here it is:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6EDGtMo8jsQ/SAazoSi8LVI/AAAAAAAAACc/L1708PfrjOs/s1600-h/libGLcore.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_6EDGtMo8jsQ/SAazoSi8LVI/AAAAAAAAACc/L1708PfrjOs/s400/libGLcore.png" alt="" id="BLOGGER_PHOTO_ID_5190033125345602898" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The number one library that consumes more memory is libGLcore. As you can see from the screenshot, there are 4 processes using it. Each and every single one of them is making an almost full copy of the library in memory. The biggest section in the library ".text" is 6.3 MB big, and it is being completely duplicated between all 4 processes.&lt;br /&gt;&lt;br /&gt;This does not seem to be limited with kde, I tried with mplayer and glxgears with same results.  It does not share a single byte in the .text entry even with other similar processes.&lt;br /&gt;&lt;br /&gt;If I had to guess, and that is all I can do since it is just a binary blob,  could be wrong, but it is probably the way the library is compiled, my guess: not using PIC (position independent code). This causes all of the function calls to be relocated when the library is loaded, and make it impossible for the system to share the code since each copy has been modified by the relocation process.&lt;br /&gt;&lt;br /&gt;This library is part of the nvidia binary drivers, so there is not much to do there. If the library was compiled in such a way that it could be shared between processes, it could save about 18 MB of ram by not duplicating the code.&lt;br /&gt;&lt;br /&gt;I would love to hear from someone to try with intel drivers, do they present the same problem?&lt;br /&gt;&lt;br /&gt;So... the score:&lt;br /&gt;&lt;table border="1" width="100%"&gt;&lt;br /&gt;&lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;&lt;th&gt;Change&lt;/th&gt;&lt;br /&gt;&lt;th&gt;Potential memory savings&lt;br /&gt;&lt;/th&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;&lt;a href="http://paul-pach.blogspot.com/2008/03/finding-bloat-in-kde4.html"&gt;Change phonon backend from xine to something else&lt;/a&gt;&lt;/td&gt;&lt;br /&gt;&lt;td&gt;22 MB&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;Avoid nvidia binary drivers&lt;/td&gt;&lt;br /&gt;&lt;td&gt;18 MB (guesstimate) &lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5833240877872020905-4070086011014872294?l=paul-pach.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paul-pach.blogspot.com/feeds/4070086011014872294/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5833240877872020905&amp;postID=4070086011014872294' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5833240877872020905/posts/default/4070086011014872294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5833240877872020905/posts/default/4070086011014872294'/><link rel='alternate' type='text/html' href='http://paul-pach.blogspot.com/2008/04/teaching-kde-how-to-share.html' title='Teaching kde how to share'/><author><name>Paul</name><uri>http://www.blogger.com/profile/05118763270998458090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://bp0.blogger.com/_6EDGtMo8jsQ/SAjjhii8LYI/AAAAAAAAACs/764rstWQ7LQ/S220/paul.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_6EDGtMo8jsQ/SAazoSi8LVI/AAAAAAAAACc/L1708PfrjOs/s72-c/libGLcore.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5833240877872020905.post-7711863945737958176</id><published>2008-03-25T07:17:00.000-07:00</published><updated>2008-12-09T08:18:43.992-08:00</updated><title type='text'>Finding bloat in KDE4</title><content type='html'>KDE 4.x is a terrific piece of code. Provided you speak C++, the code is easy to understand and clean.&lt;br /&gt;&lt;br /&gt;However, as good as the code is, there are issues that cause &lt;a href="http://www.jarzebski.pl/read/kde-3-5-vs-4-0-round-two.so"&gt;kde 4 to eats up more memory that kde3&lt;/a&gt;. This blog is dedicated to finding some low hanging fruits in memory consumption.&lt;br /&gt;&lt;br /&gt;My machine is an AMD Athlon(tm) 64 Processor 3400+, with 1GB ram. It is running Kubuntu 7.10, and I compiled kde from svn revision 795377 with debug enabled.&lt;br /&gt;&lt;br /&gt;To start with, I ran kde4 and profiled system memory with &lt;a href="http://www.berthels.co.uk/exmap/"&gt;exmap&lt;/a&gt;. Here is the result:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6EDGtMo8jsQ/R_lM84roMlI/AAAAAAAAAB4/KQQ2OJNSbFs/s1600-h/total.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_6EDGtMo8jsQ/R_lM84roMlI/AAAAAAAAAB4/KQQ2OJNSbFs/s400/total.png" alt="" id="BLOGGER_PHOTO_ID_5186261054785073746" border="0" /&gt;&lt;/a&gt;As you can see the memory consumption on my machine is about 169MB.&lt;br /&gt;&lt;br /&gt;The single process that consumes more memory here is knotify4. Knotify is a kde daemon that sits there waiting for events to happen. Once an event happens, it receives a message via dbus, and may notify the user via a sound, a popup window or other mecanisms. It is the process that is responsible for playing a sound when you maximize, minimize windows, log in, log out, etc.&lt;br /&gt;&lt;br /&gt;For such a simple task, it seems strange that it needs 30MB of memory, so I dug deeper.&lt;br /&gt;&lt;br /&gt;Going to the details of knotify4:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6EDGtMo8jsQ/SADFB810tSI/AAAAAAAAACA/ctNgRV0hhJA/s1600-h/knotify4.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_6EDGtMo8jsQ/SADFB810tSI/AAAAAAAAACA/ctNgRV0hhJA/s400/knotify4.png" alt="" id="BLOGGER_PHOTO_ID_5188363408033232162" border="0" /&gt;&lt;/a&gt;Between the heap and anon pages (I am not sure what the difference is) it consumes about 25Mb.&lt;br /&gt;&lt;br /&gt;So I ran knotify4 under a heap profiler, namely valgrind --tool=massif and the results are pretty self explanatory:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6EDGtMo8jsQ/SADHHM10tTI/AAAAAAAAACI/TD3lUL4ezZM/s1600-h/massif.2004.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_6EDGtMo8jsQ/SADHHM10tTI/AAAAAAAAACI/TD3lUL4ezZM/s400/massif.2004.png" alt="" id="BLOGGER_PHOTO_ID_5188365697250800946" border="0" /&gt;&lt;/a&gt;Playing sounds with xine seems to be eating up all the memory. I tested other xine based players, and I got the same results. It seems to me that xine library just sucks up a ton of memory for playing vorbis files.&lt;br /&gt;&lt;br /&gt;I tried playing the same vorbis files with mplayer, and the result is very different, it uses 1MB for heap + anon.&lt;br /&gt;&lt;br /&gt;To verify audio is the problem, I disabled sound notifications in the System Settings -&gt; Notifications. This is what the memory consumption looks like with no audio notifications:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6EDGtMo8jsQ/SADIUc10tUI/AAAAAAAAACQ/yQQbl-23GKo/s1600-h/knotify_nosound.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_6EDGtMo8jsQ/SADIUc10tUI/AAAAAAAAACQ/yQQbl-23GKo/s400/knotify_nosound.png" alt="" id="BLOGGER_PHOTO_ID_5188367024395695426" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Now knotify4 uses 2MB effective memory. It is no longer a blip in the radar. And kde as a whole &lt;span style="font-weight: bold;"&gt;now uses about 22MB less memory&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;It is worth noticing that phonon was designed so that back end can be replaced. Switching to a more efficient back end than xine can make a significant improvement in kde4 memory consumption, kudos to the phonon team to make such transition easy. Of course, the other way to fix the issue is fixing xine library itself. Being written in C and looking at the code, it is clear that is something I do not want to debug.&lt;br /&gt;&lt;br /&gt;I will be posting more articules pinpointing low hanging fruits in kde memory consumption, so I will keep the score in a table as I find stuff:&lt;br /&gt;&lt;br /&gt;&lt;table width="100%" border="1"&gt;&lt;br /&gt;&lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;&lt;th&gt;Change&lt;/th&gt;&lt;br /&gt;&lt;th&gt;Potential memory savings (aprox) &lt;/th&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;Change phonon backend from xine to something else&lt;/td&gt;&lt;br /&gt;&lt;td&gt;22 MB&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5833240877872020905-7711863945737958176?l=paul-pach.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://paul-pach.blogspot.com/feeds/7711863945737958176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5833240877872020905&amp;postID=7711863945737958176' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5833240877872020905/posts/default/7711863945737958176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5833240877872020905/posts/default/7711863945737958176'/><link rel='alternate' type='text/html' href='http://paul-pach.blogspot.com/2008/03/finding-bloat-in-kde4.html' title='Finding bloat in KDE4'/><author><name>Paul</name><uri>http://www.blogger.com/profile/05118763270998458090</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://bp0.blogger.com/_6EDGtMo8jsQ/SAjjhii8LYI/AAAAAAAAACs/764rstWQ7LQ/S220/paul.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_6EDGtMo8jsQ/R_lM84roMlI/AAAAAAAAAB4/KQQ2OJNSbFs/s72-c/total.png' height='72' width='72'/><thr:total>4</thr:total></entry></feed>
