<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bloggy &#187; Programming</title>
	<atom:link href="http://www.purinchu.net/wp/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.purinchu.net/wp</link>
	<description>The answer to life, the universe, and everything</description>
	<lastBuildDate>Sat, 12 Nov 2011 01:19:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>2 new kdesrc-build releases</title>
		<link>http://www.purinchu.net/wp/2011/09/22/2-new-kdesrc-build-releases/</link>
		<comments>http://www.purinchu.net/wp/2011/09/22/2-new-kdesrc-build-releases/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 00:24:19 +0000</pubDate>
		<dc:creator>mpyne</dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[kdesvn-build]]></category>
		<category><![CDATA[kdesrc-build]]></category>
		<category><![CDATA[kdesrc-build release]]></category>

		<guid isPermaLink="false">http://www.purinchu.net/wp/?p=702</guid>
		<description><![CDATA[So after 6 months of work I released kdesrc-build 1.14 with quite a few changes/fixes. 4 days later I released 1.14.1 (mostly to help mitigate an effect of a change in 1.14 which I&#8217;ll cover at the end). Without further ado, I&#8217;ll list some of the important changes. You&#8217;ve probably already noticed, but the &#8220;qt-kde&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>So after 6 months of work I released kdesrc-build 1.14 with quite a few changes/fixes. 4 days later I released <a href="http://kdesrc-build.kde.org/releases/kdesrc-build-1.14.1.php">1.14.1</a> (mostly to help mitigate an effect of a change in 1.14 which I&#8217;ll cover at the end). Without further ado, I&#8217;ll list some of the important changes.</p>
<ul>
<li>You&#8217;ve probably already noticed, but the &#8220;qt-kde&#8221; module on git.kde.org is no more, and has been moved to be &#8220;qt&#8221;, a simple clone of Nokia&#8217;s Qt 4.8 (and prior) codebase (there&#8217;s no mirror of the upcoming even-more-split Qt 5 in development yet). What this means for kdesrc-build users is that they need to adjust their qt-copy module. Unfortunately the module used to build Qt must still be called qt-copy to avoid breaking things.</li>
<li>
<p>The on-disk layout for source and build directories for modules that come from the KDE project database (i.e. <code>repository kde-projects</code>) has changed. Now the destination directory uses the same path that is present in the hierarchy on projects.kde.org. As an example, kdelibs would be in $src-or-builddir/kde/kdelibs, kdesrc-build would be in $src-or-builddir/extragear/utils/kdesrc-build, etc. This should make it easier to manage the increased number of modules resulting from the move to git.kde.org.</p>
<ul>
<li>To make this easier, kdesrc-build will move your old source and build directories (if they&#8217;re detected) when this happens, so you shouldn&#8217;t have to waste all your bandwidth or spend an inordinate amount of time rebuilding modules.</li>
<li>One problem that was noted with this new arrangement is that it&#8217;s possible to have git checkouts nested in other git checkouts (for instance, konsole fits in kde/kde-baseapps, but kde-baseapps is a separate git module). This is not a problem by itself, but can interfere with older checkouts of kde-baseapps. So 1.14.1 introduced the ability to delete existing source directories if they would be in the way of a git-clone. You must pass <code><em>--delete-my-patches</em></code> to enable this due to the obvious hazard of losing uncommitted work.</li>
</ul>
</li>
<li>A manpage was added, which might prove useful if you don&#8217;t have a web browser handy, Internet connection to docs.kde.org, etc. The catch is that the manpage is generated using the KDE docs infrastructure from kdelibs, which might not be present yet when you first run kdesrc-build! ;) Don&#8217;t forget to have your <tt>MANPATH</tt> set to include your KDE <tt>man</tt> directory.</li>
<li>As pointed out in an email by Aaron Seigo to kde-buildsystem some time ago, it really could be easier to setup kdesrc-build on initial run. To that end, a script called <code>kdesrc-build-setup</code> is included. It&#8217;s generated config is *very* simplistic at this point but it&#8217;s better than what was there before. To allow for bootstrapping a GUI without having KDE installed the setup script uses the console just like kdesrc-build.</li>
<li>kdesrc-build makes the <tt>kde:</tt> Git alias (which is <a href="http://community.kde.org/Sysadmin/GitKdeOrgManual#Let_Git_rewrite_URL_prefixes">recommended by git.kde.org</a> admins) available if you haven&#8217;t set it up yet.</li>
<li>The use of git snapshots is supported for git-clone now, but only for modules from the KDE project database. My understanding is that this should save CPU load on the git.kde.org infrastructure (although not much in the way of bandwidth). Resuming of aborted downloads is not supported yet unfortunately. If this causes problems use <tt>‑‑no‑snapshots</tt> to disable (as of 1.14.1, where that option works again&#8230;).</li>
<li>You can include other files in your configuration file, for those who actually use the kdesrc-build feature supporting different configurations depending on what your current directory is.</li>
<li>
<p>As a final excerpt, it is possible to ask for all modules <em>under</em> a given KDE project module to be built. This is actually required for kdegraphics (at least when I implemented this) since kdegraphics supports a SuperBuild-style repository which will check out all of its dependent submodules and build it for you. You can also build the submodules individually, so to keep people from accidentally building them both the kdegraphic base repo is marked as inactive in the database which prevents automated tools (including kdesrc-build) from processing it.</p>
<p>By using something like:</p>
<pre>module-set graphics
    repository kde-projects
    use-modules kdegraphics/libs kdegraphics/*
end module-set</pre>
<p>you can for kdesrc-build to build all &#8220;active&#8221; modules under kdegraphics, even if kdegraphics is itself marked inactive. (The <code>kdegraphics/libs</code> part is to force kdesrc-build to build that first, kdesrc-build will skip duplicate modules so you don&#8217;t need to worrk about <code>kdegraphics/*</code> trying to build <code>/libs</code> twice).</p>
</li>
<li>There&#8217;s actually a few more minor things but this post is already too long!</li>
</ul>
<p>There&#8217;s fewer &#8220;pure bugfixes&#8221; than I expected, but environment variable handling support is improved somewhat, and the KDE project database is actually downloaded in pretend mode when it&#8217;s needed (just like the prompt had been saying was happening&#8230;).</p>
<p>There has been a fairly substantial refactoring/code reorganization to get to this point. The test suite does pass, but if you&#8217;re a heavy user of the <code>kde-languages</code> option you may want to wait until I&#8217;ve verified that the l10n building still works (unfortunately cloning such modules makes testing that option more difficult than I&#8217;d like).</p>
<p>Other than that I hope you all will be happy with the capabilities of <a href="http://kdesrc-build.kde.org/releases/kdesrc-build-1.14.1.php">the latest version</a>. I&#8217;ll try to release more frequently than every 6 months in the future, that might be a bit easier to achieve at my new duty station near Washington, DC.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purinchu.net/wp/2011/09/22/2-new-kdesrc-build-releases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl hijinks</title>
		<link>http://www.purinchu.net/wp/2011/04/10/perl-hijinks/</link>
		<comments>http://www.purinchu.net/wp/2011/04/10/perl-hijinks/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 03:57:45 +0000</pubDate>
		<dc:creator>mpyne</dc:creator>
				<category><![CDATA[Computing Troubles]]></category>
		<category><![CDATA[kdesvn-build]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[kdesrc-build]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[prototypes]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.purinchu.net/wp/?p=686</guid>
		<description><![CDATA[So I&#8217;ve been trying to modularize my kdesrc-build Perl script (i.e. actually split it into logical objects/modules) and yet still retain it all into one script, the idea being to get the logic into a more understandable state where possible and overall make the codebase less brittle. I achieved a large milestone today in finally [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve been trying to modularize my kdesrc-build Perl script (i.e. actually split it into logical objects/modules) and yet still retain it all into one script, the idea being to get the logic into a more understandable state where possible and overall make the codebase less brittle.</p>
<p>I achieved a large milestone today in finally managing to group together the debugging methods in a way which remains compatible with the rest of the script.</p>
<p>What I mean by this is that I used the <a href="http://perldoc.perl.org/perlsub.html#Prototypes">prototypes</a> feature of Perl subroutines to allow for methods like:</p>
<pre><code>return 1 if pretending;</code></pre>
<p> (Notice how there are no parentheses after the <code>pretending</code> call), and</p>
<pre><code>info "\tPerforming source update for g[$module]";</code></pre>
<p> (Likewise no parentheses for the info method call).</p>
<p>Now, in retrospect I probably should have simply not used prototypes, at least for the output methods which would not be significantly less readable with parentheses. All the same however, prototypes were interfering with grouping these debugging routines into their own module.</p>
<p>This is because subroutine prototypes actually affect the Perl parser itself, and these prototypes are not exported by the normal Perl routines for exporting subroutines out of classes, i.e. a subroutine <code>Debug::pretending()</code> (with a prototype that is completely empty) would get exported to main as <code>main::pretending</code> (with no prototype at all). This would break code that used the <code>pretending</code> routine without parentheses since the Perl parser doesn&#8217;t know it is supposed to accept no arguments.</p>
<p>After beating my head on this problem off-and-on for awhile it finally occurred to me today that Perl is a &#8220;dynamic language&#8221;: Why couldn&#8217;t I just manually feed the appropriate declaration into the parser on-the-fly when necessary?</p>
<p>After some prototyping I came up with an <code>import</code> method that seemed to work:</p>
<pre>my $pkg = shift;
my $caller = caller;
my @exports = qw(debug pretending); # etc...

# This loop is only slightly "magical". Basically to import functions
# into a different package in Perl, we can use something like:
# *PACKAGE::FUNCTION = \&#038;SOURCE_PACKAGE::FUNCTION;
# where the *PACKAGE modifies the symbol table for that package.
#
# The extra part, which requires using eval, is to predeclare the
# subroutine with a prototype first.
# "sub foo($old_prototype);"

for my $fn (@exports) {
    my $prototype = prototype($fn);
    eval "sub ${caller}::${fn}(${prototype});\n" .
         "*${caller}::${fn} = \\&#038;${pkg}::${fn};";
}</pre>
<p>All that I&#8217;m really doing is reading in the prototype for each function that is exported by using the built-in <code>prototype</code> method, and then <code>eval</code>-ing a string the predeclares the exported subroutine with the appropriate prototype, and then assigns the implementation of that subroutine to the existing package&#8217;s implementation.</p>
<p>This exports the prototype information when the import method is *run*, but the Perl parser will parse as much of the file as possible before starting execution. So if we want the parser to be updated as well, we must force the new <code>import</code> method to be run as soon as possible, which can be done using the standard Perl <code>BEGIN { ... }</code> block, which runs the code inside of it as soon as it is encountered.</p>
<p>So in kdesrc-build, instead of having &#8220;<code>use ksb::Debug;</code>&#8220;, I have:</p>
<pre>BEGIN {
    ksb::Debug->import();
}</pre>
<p>And now everything is parsed (and run) just as before! I&#8217;ll likely still convert the code to not need this circumlocution at some point, but I thought it was at least technically interesting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purinchu.net/wp/2011/04/10/perl-hijinks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>May you live in interesting times&#8230;.</title>
		<link>http://www.purinchu.net/wp/2011/01/19/may-you-live-in-interesting-times/</link>
		<comments>http://www.purinchu.net/wp/2011/01/19/may-you-live-in-interesting-times/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 05:09:42 +0000</pubDate>
		<dc:creator>mpyne</dc:creator>
				<category><![CDATA[kdesvn-build]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git migration]]></category>
		<category><![CDATA[kdesrc-build]]></category>
		<category><![CDATA[kdesrc-build release]]></category>
		<category><![CDATA[kshareddatacache]]></category>
		<category><![CDATA[module-set]]></category>

		<guid isPermaLink="false">http://www.purinchu.net/wp/?p=673</guid>
		<description><![CDATA[So, given the accelerating rate of KDE project migration to git.kde.org, I felt it was prudent to finally make a kdesrc-build release, for those who don&#8217;t follow kdesrc-build development in trunk. So, kdesrc-build 1.12.1 is upon us (the link may be broken, I&#8217;ve just committed everything to svn, it should update within a few minutes [...]]]></description>
			<content:encoded><![CDATA[<p>So, given the accelerating rate of KDE project migration to git.kde.org, I felt it was prudent to <em>finally</em> make a kdesrc-build release, for those who don&#8217;t follow kdesrc-build development in trunk.</p>
<p>So, <a href="http://kdesrc-build.kde.org/releases/kdesrc-build-1.12.1.php">kdesrc-build 1.12.1</a> is upon us (the link may be broken, I&#8217;ve just committed everything to svn, it should update within a few minutes of that). I probably shouldn&#8217;t have made it a mere +0.0.1 release, as it contains one notable large new feature, and several minor improvements besides the normal bugfixes.</p>
<p>The big deal is the <a href="/wp/2010/12/07/everyone-is-moving-to-git-kde-org/">module-set feature I discussed</a> a couple of months ago. This allows for easy declaration of git-based modules in your .kdesrc-buildrc (which is good, as old Subversion modules are being migrated quickly now that 4.6 has been branched off of trunk).</p>
<p>However, it is not a long-term (or even a good medium-term) solution. To that end, the KDE sysadmins have been working hard on making a database of the projects available on git.kde.org, including what groups each repository falls under. Besides being needed to migrate some of the tools that we currently use with Subversion, it will be useful for allowing build scripts (such as kdesrc-build) to take a command to build e.g. &#8220;kdepim&#8221;, and figure out the full list of git repositories contained in the &#8220;kdepim&#8221; grouping.</p>
<p>The groups can themselves be contained within groups (in theory you&#8217;d be able to build all of extragear with a single command, although I&#8217;ll probably block groupings that large like kdesrc-build currently does to avoid users accidentally DoS-ing KDE resources).</p>
<p>That will be the next thing I start on. Hopefully finding good Perl libraries for parsing XML doesn&#8217;t take too long. ;)</p>
<p>The <em>other</em> thing I will be doing is migrating to git.kde.org myself. I&#8217;m not exactly sure when, but I already have the rules mostly written. Perhaps I&#8217;ll wrap everything up this weekend and move to git.kde.org myself.</p>
<p>Either way, let me know if there are issues with the new release (it&#8217;s been brewing for about a week so don&#8217;t say I didn&#8217;t give trunk users time to test! ;)</p>
<p>Happy building!</p>
<p><em>PS:</em> Special side note, if you&#8217;ve been receiving messages about KSharedDataCache saying that &#8220;This cache is probably corrupt&#8221;, update kdelibs to either 4.6 branch or trunk, that bug should be fixed now&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purinchu.net/wp/2011/01/19/may-you-live-in-interesting-times/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Everyone is moving to git.kde.org</title>
		<link>http://www.purinchu.net/wp/2010/12/07/everyone-is-moving-to-git-kde-org/</link>
		<comments>http://www.purinchu.net/wp/2010/12/07/everyone-is-moving-to-git-kde-org/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 05:55:42 +0000</pubDate>
		<dc:creator>mpyne</dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[kdesvn-build]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[kdesrc-build]]></category>
		<category><![CDATA[module-set]]></category>

		<guid isPermaLink="false">http://www.purinchu.net/wp/?p=670</guid>
		<description><![CDATA[Except me that is&#8230; but only due to lack of rule-writing time. But in the meantime, I&#8217;ve written some code to allow you to at least quickly declare KDE git modules to build. I&#8217;ve just committed it to trunk kdesrc-build (in kdesdk/scripts). This feature adds two options: git-repository-base, which declares an alias name for a [...]]]></description>
			<content:encoded><![CDATA[<p>Except me that is&#8230; but only due to lack of rule-writing time.</p>
<p>But in the meantime, I&#8217;ve written some code to allow you to at least quickly declare KDE git modules to build. I&#8217;ve just committed it to trunk kdesrc-build (in kdesdk/scripts). This feature adds two options:</p>
<ol>
<li>git-repository-base, which declares an alias name for a new git repository, and assigns it a URL. This is needed for a concept I&#8217;m calling &#8220;module-set&#8221; for now.</li>
<li>use-modules, which is used in a given module-set to name the git modules that you want to build at that point in the .kdesrc-buildrc, in order.</li>
</ol>
<p>Simple example:</p>
<p><code>global<br />
...<br />
   git-repository-base kde-git git://anongit.kde.org/<br />
end global</p>
<p>module qt-copy<br />
...<br />
end module</p>
<p>module-set kde-git # Note this is not the name of the module-set, but the repo to use<br />
    # 5 git module declarations in one line...<br />
    use-modules automoc attica soprano cagibi akonadi<br />
end module-set</p>
<p># Need to set options for attica? Just declare it manually and set the options after the<br />
# module-set. It still gets built before soprano though.<br />
module attica<br />
    cmake-options ....<br />
end module</code></p>
<p>Hopefully this makes managing the large numbers of individual git projects that are popping up much more reasonable. Another long-term measure is that some motivated git-transition types are working on a module-grouping XML format, which will be usable by kdesrc-build (among other software) to quickly group related git modules under a single name.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purinchu.net/wp/2010/12/07/everyone-is-moving-to-git-kde-org/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>kdesrc-build update for Git migration</title>
		<link>http://www.purinchu.net/wp/2010/10/26/kdesrc-build-update-for-git-migration/</link>
		<comments>http://www.purinchu.net/wp/2010/10/26/kdesrc-build-update-for-git-migration/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 03:31:05 +0000</pubDate>
		<dc:creator>mpyne</dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[kdesvn-build]]></category>
		<category><![CDATA[git migration]]></category>
		<category><![CDATA[kdesrc-build]]></category>
		<category><![CDATA[module group spec]]></category>

		<guid isPermaLink="false">http://www.purinchu.net/wp/?p=660</guid>
		<description><![CDATA[So this morning kde-core-devel was emailed to notify that a few projects that used to be hosted in kdesupport have moved to git.kde.org. What this means for you if you use kdesrc-build is that you should probably update your ~/.kdesrc-buildrc to add the projects separately since they will no longer be built as part of [...]]]></description>
			<content:encoded><![CDATA[<p>So this morning kde-core-devel was emailed to notify that a few projects that used to be hosted in kdesupport have moved to <a href="http://projects.kde.org/">git.kde.org</a>.</p>
<p>What this means for you if you use <a href="http://kdesrc-build.kde.org/">kdesrc-build</a> is that you should probably update your ~/.kdesrc-buildrc to add the projects separately since they will no longer be built as part of kdesupport.</p>
<p>Affected are Akonadi (the underlying PIM layer, which might be required for kdelibs, I forget), Attica (&#8220;Implements the Open Collaboration Services API&#8221;, I assume this means it&#8217;s required as well) and Soprano (C++ RDF framework, used for Nepomuk. I believe Soprano is required even if Nepomuk is not being used, but that could also be wrong).</p>
<p>My recommendation is to add the following modules after your existing kdesupport module, before any other modules:</p>
<pre>module soprano
    repository git://git.kde.org/soprano.git
end module

module attica
    repository git://git.kde.org/attica.git
end module

module akonadi
    repository git://git.kde.org/akonadi.git
end module</pre>
<p>Naturally if you will be doing development on these repositories and not simply checking out a read-only copy for build purposes you should use the git@git.kde.org:foo.git form of the repository URL.</p>
<p>This migration to git has the potential to get annoying for end-users, especially as we modularize more and more. To that end, the KDE Sysadmin team is working on a specification for grouping related modules together, which kdesrc-build will support, that way you could just do something like:</p>
<pre>kde-module-group kdeplatform
    # References known XML module grouping
end kde-module-group</pre>
<p>and things would Automagically Work. Stay tuned&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purinchu.net/wp/2010/10/26/kdesrc-build-update-for-git-migration/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Speed up!</title>
		<link>http://www.purinchu.net/wp/2010/09/13/speed-up/</link>
		<comments>http://www.purinchu.net/wp/2010/09/13/speed-up/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 03:32:11 +0000</pubDate>
		<dc:creator>mpyne</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Useful Tricks]]></category>
		<category><![CDATA[kiconloader]]></category>
		<category><![CDATA[kshareddatacache]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[qstringbuilder]]></category>

		<guid isPermaLink="false">http://www.purinchu.net/wp/?p=651</guid>
		<description><![CDATA[So. Matthias Fuchs of “Speeding up KGet with Callgrind” fame pointed out to me on IRC the other day that KIconLoader seemed to still be using a lot of time to load icon image data, even when the icon should have already been cached. I managed to confirm the issue. Turns out that when I [...]]]></description>
			<content:encoded><![CDATA[<p>So. Matthias Fuchs of “<a href="http://mat69.wordpress.com/2010/09/11/speeding-up-kget-using-callgrind/">Speeding up KGet with Callgrind</a>” fame pointed out to me on IRC the other day that KIconLoader seemed to still be using a lot of time to load icon image data, even when the icon should have already been cached.</p>
<p>I managed to confirm the issue. Turns out that when I ported KIconLoader to use KSharedDataCache, I didn&#8217;t employ KIconLoader&#8217;s <em>other</em> cache (a pixmap cache [1]) in all the instances where it made sense. Specifically, the pixmap cache only had things added when an entry was also added to the KSharedDataCache.</p>
<p>But this doesn&#8217;t always make sense. The KSharedDataCache is shared across all KDE Platform-based processes, but there&#8217;s a different pixmap cache for every KIconLoader. So, it&#8217;s perfectly possible to have many processes never have to <em>add</em> an icon to the KSharedDataCache.</p>
<p>Now, new pixmaps that are read from a KSharedDataCache are added to a KIconLoader&#8217;s own personal pixmap cache to avoid trying to search the KSharedDataCache next time. This has the potential to significantly speedup icon-based operations, especially in situations where an application uses the same pixmaps over and over. This speedup is in trunk (future 4.6) and will also be released with KDE Platform 4.5.2.</p>
<p>Matthias (and Ingo Klöcker) provided another speedup, by converting some slow QString-based operations to use a QStringBuilder class introduced in Qt 4.6. This gave an 8% speedup on an icon microbenchmark, so not insignificant. This one will only be in KDE Platform 4.6 at this point, although I wouldn&#8217;t feel horrible if it were to be backported also.</p>
<p>Incidentally, this was the first I&#8217;d heard of regarding QStringBuilder, so it&#8217;s something I&#8217;d recommend brushing up on if you haven&#8217;t heard of it yet. The QStringBuilder documentation is part of the <a href="http://doc.qt.nokia.com/latest/qstring.html">QString API reference</a> (search for &#8220;More Efficient String Construction&#8221;).</p>
<p>[1] Every KIconLoader instance also has its own pixmap cache, which holds QPixmaps, while KIconLoader&#8217;s KSharedDataCache holds QImages.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purinchu.net/wp/2010/09/13/speed-up/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Big update collection</title>
		<link>http://www.purinchu.net/wp/2010/07/30/big-update-collection/</link>
		<comments>http://www.purinchu.net/wp/2010/07/30/big-update-collection/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 23:05:05 +0000</pubDate>
		<dc:creator>mpyne</dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[kdesvn-build]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[car repair]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[juk]]></category>
		<category><![CDATA[kdesrc-build]]></category>
		<category><![CDATA[name change]]></category>
		<category><![CDATA[qt3support]]></category>

		<guid isPermaLink="false">http://www.purinchu.net/wp/?p=646</guid>
		<description><![CDATA[Unfortunately I haven&#8217;t made any blog updates in awhile. I&#8217;ve been very busy between work and school (and I will likely spend this weekend working on a 20 page project that I&#8217;ve written 0 pages for ;). That doesn&#8217;t mean I have nothing to report though&#8230; First off, I have renamed kdesvn-build to kdesrc-build to [...]]]></description>
			<content:encoded><![CDATA[<p>Unfortunately I haven&#8217;t made any blog updates in awhile. I&#8217;ve been very busy between work and school (and I will likely spend this weekend working on a 20 page project that I&#8217;ve written 0 pages for ;). That doesn&#8217;t mean I have nothing to report though&#8230;</p>
<p>First off, I have renamed kdesvn-build to <a href="http://kdesrc-build.kde.org/">kdesrc-build</a> to reflect the fact that it builds from <a href="http://gitscm.org/">Git</a>-based software repositories. In conjunction I released <a href="http://kdesrc-build.kde.org/releases/kdesrc-build-1.12.php">kdesrc-build 1.12</a> which has various minor improvements, including a few Git improvements.</p>
<p>I&#8217;ve <a href="/wp/2010/07/06/timing-belts/">complained</a> about my car breaking down. It&#8217;s fixed, although I will be selling it now (my wife and I were debating the merits of getting an improved car for awhile before, this incident sealed the decision).</p>
<p>Just today I&#8217;ve committed a new feature to JuK, the sadly neglected KDE Software Compilation music manager. Now you can use the scroll wheel in the track announcement popup to quickly switch tracks without having to use the Next/Prev buttons. It&#8217;s probably already in every other media player with a playlist, but it&#8217;s at least in JuK now. Note that this is a 4.<em>6</em> new feature, not 4.5.</p>
<p>I&#8217;ve also been &#8220;reviewing&#8221; a patch to further remove Qt3 support code from JuK, which I will try to clean up and get comitted this release cycle. The big thing I still need to do is to finally convert from K3ListView to a real Model/View architecture to finally be rid of Qt3Support. Help is always appreciated btw =D</p>
<p>Burkhard Lück, the documentation super-hero, has been improving JuK documentation for me, but I still need to make some changes that he&#8217;s requested to bring the docs closer to 2008-era (let alone 2010) :(</p>
<p>That&#8217;s another good &#8220;intro to KDE Platform&#8221; kind of job by the way, it&#8217;s how I got introducing into coding for JuK myself. ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purinchu.net/wp/2010/07/30/big-update-collection/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Another transition for kdesvn-build</title>
		<link>http://www.purinchu.net/wp/2010/06/24/another-transition-for-kdesvn-build/</link>
		<comments>http://www.purinchu.net/wp/2010/06/24/another-transition-for-kdesvn-build/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 03:00:12 +0000</pubDate>
		<dc:creator>mpyne</dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[kdesvn-build]]></category>
		<category><![CDATA[amarok]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[kdecvs-build]]></category>
		<category><![CDATA[konversation]]></category>
		<category><![CDATA[name change]]></category>

		<guid isPermaLink="false">http://www.purinchu.net/wp/?p=636</guid>
		<description><![CDATA[So if you have been looking at Planet KDE or the kde-scm-interest mailing list recently you will have noticed that some of our intrepid sysadmins have started setup the systems that will be needed to migrate the KDE source code to . Konversation and Amarok have already switched. kdesvn-build has already supported git (and the [...]]]></description>
			<content:encoded><![CDATA[<p>So if you have been looking at <a href="http://planetkde.org/">Planet KDE</a> or the kde-scm-interest mailing list recently you will have noticed that some of our intrepid sysadmins have started setup the systems that will be needed to migrate the KDE source code to <a href="http://www.git-scm.org/">. Konversation and Amarok have </a><a href="http://konversation.kde.org/">already</a> <a href="http://blog.lydiapintscher.de/2010/06/19/lets-move-that-source-code-so-it-doesnt-get-lazy/">switched</a>.</p>
<p>kdesvn-build has already supported git (and the upcoming 1.12 release has some git improvements), so building and installing konversation and amarok is as simple as fixing your kdesvn-buildrc to refer to the correct git repository. For Amarok and Konversation this means changing gitorious.org to git.kde.org for most users using the read-only clone URL (like git://gitorious.org/amarok/amarok.git). Read-write access occurs with a separate URL, lookup the TechBase entry for more info.</p>
<p><em>If you have already built a gitorious version of Amarok or Konversation</em> then you have two options to correct the downloaded source:</p>
<ol>
<li>Remove the source directory, and kdesvn-build will clone it again from the updated repository, or</li>
<li>Use the a manual git remote URL updating command as described on the <a href="http://konversation.kde.org/">Konversation homepage</a>.</li>
</ol>
<p>It has been awhile since a release of kdesvn-build, and the kdesvn-build <a href="http://kdesvn-build.kde.org/">website</a> was recently effectively offline due to an IP address change, so I&#8217;ll probably move to more stable KDE-hosted servers if possible. With all that in mind, it&#8217;s probably time to change the name again! (Who remembers <a href="http://cia.vc/stats/project/kde/kdenonbeta/kdecvs-build">kdecvs-build</a>? ;)</p>
<p>My initial plan for the name is kdesrc-build. I figure there&#8217;s no way this one won&#8217;t be future-proof (and besides, svn will still be supported for some time probably). ;) If anyone has better ideas for a name that is descriptive, relatively future-proof, and catchy, please leave me a suggestion in the comments.</p>
<p>While I&#8217;m polling the audience, I&#8217;ve been thinking about the design of kdesvn-build. Right now it is a 217 KiB single-file Perl script, with no external dependencies required aside from Perl 5.8. This is mainly to make it as easy to install and upgrade as possible. Does this ease of upgrading actually make a big difference for you all? It hasn&#8217;t been very difficult keeping the script in one file (I even managed to get Perl&#8217;s weird object orientation to work in one file) so I can keep that going if it&#8217;s worth it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purinchu.net/wp/2010/06/24/another-transition-for-kdesvn-build/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Implementing a shared cache: Part 4</title>
		<link>http://www.purinchu.net/wp/2010/05/20/implementing-a-shared-cache-part-4/</link>
		<comments>http://www.purinchu.net/wp/2010/05/20/implementing-a-shared-cache-part-4/#comments</comments>
		<pubDate>Fri, 21 May 2010 01:21:10 +0000</pubDate>
		<dc:creator>mpyne</dc:creator>
				<category><![CDATA[Implementing KSharedDataCache]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[kshareddatacache]]></category>
		<category><![CDATA[series]]></category>

		<guid isPermaLink="false">http://www.purinchu.net/wp/?p=628</guid>
		<description><![CDATA[Almost two weeks since I posted Part 3, which means it&#8217;s probably time to wrap up my series on implementing KSharedCache with this post. As a recap for those who don&#8217;t want to skip to the end of Part 3, I said I&#8217;d talk about having to defragment the shared cache and porting KIconLoader. Defragmentation [...]]]></description>
			<content:encoded><![CDATA[<p>Almost two weeks since I posted <a href="/wp/2010/05/08/implementing-a-shared-cache-part-3/">Part 3</a>, which means it&#8217;s probably time to wrap up my series on implementing KSharedCache with this post. As a recap for those who don&#8217;t want to skip to the end of Part 3, I said I&#8217;d talk about having to defragment the shared cache and porting KIconLoader.</p>
<h3>Defragmentation</h3>
<p>One of the sub-optimal parts of my implementation of KSharedDataCache is the fact that the data must be contiguous in memory. It would actually be fairly simple to change this due to the existing page design, but right now this is what we&#8217;ve got.</p>
<p>The reason this is sub-optimal is due to an effect called fragmentation (more precisely, external fragmentation). The effect is illustrated in the following diagram:</p>
<p><center><img src="/images/kshareddatacache-fragmentation.png" width="580" height="465"/></center></p>
<p>The problem with fragmentation can be seen in the cache layout at the bottom. The maroon blocks indicate allocated pages. In the bottom cache layout, even though the overall allocation is less than in the other cache, it is not possible to fit the new block in memory because there is no solid block of free memory of sufficient size.</p>
<p>This problem could be solved if only there were a way to move the allocated memory around. In the case of KSharedDataCache this can be done, because only the cache records the location of each data block (when an item is returned to an application, it is actually a copy). This process is called defragmentation, and is essentially the same idea as what disk-based defragmenters do.</p>
<p>My defragmentation is probably fairly naïve but does the job, simply looking for used pages of memory and moving them as far to the beginning as possible. The more interesting part is deciding when to defragment. Right now defragmentation is performed as follows:</p>
<ul>
<li>When we are having to remove currently-used pages due to insufficient consecutive memory when total free space is higher than a certain threshold, before pages are actually removed.</li>
<li>After evicting cache entries, since there are probably more holes in memory, and the reason we evicted things from the cache was due to insufficient consecutive free memory.</li>
</ul>
<p>As I said my defragmentation routine is very simple and could probably be easily improved. I haven&#8217;t noticed issues with it becoming a problem during desktop usage but that&#8217;s perhaps attributable to not coming into use very often (if at all) due to the cache aging I mentioned in Part 3.</p>
<h3>Porting KIconLoader</h3>
<p>Perhaps the largest impetus driving me to do all this work in the first place was due to KIconLoader, which used to use KPixmapCache to cache loaded icons. KIconLoader is used everywhere in KDE and so many KPixmapCache-related crashes were first noticed in seemingly very-unrelated applications when trying to load icons.</p>
<p>Porting KIconLoader to KSharedDataCache was not a direct method name replacement unfortunately, as one of the things KIconLoader stored was the path that the icon was found at. (This used to be done by using the custom data API for KPixmapCache I mentioned in <a href="/wp/2010/04/25/implementing-a-shared-cache-part-1/">Part 1</a>). I had first intended to use KImageCache (an image-related subclass of KSharedDataCache) for KIconLoader, but I ended up using KSharedDataCache directly, to hold cache entries that simply contained the pixmap and the path.</p>
<p>One problem that came up that I only fixed a few minutes ago was that KIconLoader would not only cache loaded icons, but it would also cache failed icon lookups, which was a behavior I had not ported over. This was especially notable in Dolphin browsing in large directories apparently. Either way, that is now fixed.</p>
<h3>Future Directions</h3>
<p>I&#8217;m proud of the work I put into KSharedDataCache, and especially since it has been running in trunk for about 4 weeks now with no major issues that seem to have popped up. However there are quite a few things that could be improved about it:</p>
<ul>
<li>Cache corruption: Although in my opinion the risk of crashes from a corrupted cache is less right now due to the cache layout and non-usage of QDataStream, the possibility is not zero. Because of the serious consequences of cache corruption leading to crashes, it would be nice to have an efficient way to mark that a disk cache should be deleted because it is corrupt. I&#8217;ve thought of some things but have no concrete plans at this point.</li>
<li>The page table/index table method of storing data is very simplistic. There is surely a more appropriate method buried in some ACM or IEEE publication somewhere, even in the limits of fixed memory size. As it stands my method blends some of the disadvantages of 1960&#8242;s-era memory allocators with paged memory allocators, without all of the benefits.</li>
<li>Assuming defragmentation remains required, the defragmenter could probably be made faster as well.</li>
<li>It is not at this point possible to resize a cache once it has been created. There&#8217;s no reason in theory that it can&#8217;t be done, it&#8217;s just not implemented. (Note that implementing this is more complicated than simply changing a size flag in the cache&#8230;)</li>
<li>The cache could possibly be made more concurrent with lock-free algorithms or finer-grained locking. This is not something I&#8217;d like to touch until I have a way to verify correctness of the result, however.</li>
<li>Finally, it possible that someone has done this way better and that I simply missed it, in which event we should look at whether we should just adopt that library as a dependency and make KSharedDataCache a wrapper around it.</li>
<li>Should we remove old KPixmapCache caches after starting up a shiny new 4.5 desktop?</li>
</ul>
<p>So, this concludes my series on implementing a shared cache. I&#8217;ve got to get working on other efficiency improvements, new kdesvn-build releases, classes, etc. It&#8217;s been fun writing though!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purinchu.net/wp/2010/05/20/implementing-a-shared-cache-part-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Implementing a shared cache: Part 3</title>
		<link>http://www.purinchu.net/wp/2010/05/08/implementing-a-shared-cache-part-3/</link>
		<comments>http://www.purinchu.net/wp/2010/05/08/implementing-a-shared-cache-part-3/#comments</comments>
		<pubDate>Sun, 09 May 2010 02:20:03 +0000</pubDate>
		<dc:creator>mpyne</dc:creator>
				<category><![CDATA[Implementing KSharedDataCache]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[collateral evictions]]></category>
		<category><![CDATA[kshareddatacache]]></category>
		<category><![CDATA[pointers]]></category>
		<category><![CDATA[pthreads]]></category>
		<category><![CDATA[ramped entry aging]]></category>
		<category><![CDATA[series]]></category>
		<category><![CDATA[spinlocks]]></category>

		<guid isPermaLink="false">http://www.purinchu.net/wp/?p=623</guid>
		<description><![CDATA[So it has been a few days since Part 2, where I promised I&#8217;d talk about some issues that go with using pointers in shared memory, initial cache setup, and my arbitrary methods I use to handle various scenarios. Pointing to things in shared memory First I&#8217;ll talk about pointers. Essentially all you need to [...]]]></description>
			<content:encoded><![CDATA[<p>So it has been a few days since <a href="/wp/2010/04/30/implementing-a-shared-cache-part-2/">Part 2</a>, where I promised I&#8217;d talk about some issues that go with  using pointers in shared memory, initial cache setup, and my arbitrary methods I use to handle various scenarios.</p>
<h3>Pointing to things in shared memory</h3>
<p>First I&#8217;ll talk about pointers. Essentially all you need to know about them is that a pointer holds a memory address, namely the address of the data you&#8217;re really interested in.</p>
<p>Now, every process in modern operating systems has its own &#8220;address space&#8221;, which defines where things are in memory. So, memory addresses in process 1 have no relation to addresses used in process 2, or any other process.</p>
<p>What this means for shared memory algorithms is that you cannot use normal pointers, since they rely on pointing to a specific spot in a process&#8217;s address space. See below for an example:</p>
<p><center><img src="/images/kshareddatacache-pointers.png" width="641" height="469" alt="Demonstration of address space for three processes shared a cache"/></center></p>
<p>Three KSharedDataCache-using processes are running, and let&#8217;s say that kcalc was the first to create that cache, so the pointers are created from the perspective of kcalc&#8217;s address space. If KSharedDataCache used normal pointers to point to the data in the cache (from the cache header) then things would fail to work right in kate where we point into the middle of the data. The case of krunner is even worse, as we point into the krunner process&#8217;s private data!</p>
<p>The solution is not too hard. The memory map call that creates the connection will tell you where the connection starts. So instead of saying &#8220;the data is at address 0&#215;400000&#8243;, use pointers that say &#8220;the data is 1024 bytes past the start&#8221;. These are called offsets. For example, the pthread library that is standard in POSIX could use this type of technique to implement &#8220;process-shared&#8221; mutexes (mutexes are by default merely thread-shared).</p>
<h3>Initial cache setup</h3>
<p>Taking that first step in creating a cache is hard. Once the cache is setup we can rely on having some means of locking, entry tables that are setup, and other niceties. Creating that in the face of race conditions is another matter though.</p>
<p>My decision to use pthreads for the mutex made this part harder than it could have been otherwise, as the mutex has to be stored with the cache. But you can&#8217;t use the mutex without initializing it first (remember that pthread mutexes default to not being process-shared). If two processes try to create a non-existing cache at the same time, they would both try to initialize the mutex, and the process that initializes the mutex the second time could potentially cause logic errors in the first process.</p>
<p>So, I went with a simpler solution for this rare case: A <a href="http://en.wikipedia.org/wiki/Spinlock">spinlock</a>, using Qt&#8217;s built-in atomic operations. It is not quite a pure spinlock because there are a couple of possibilities (numbered as they are in the code):</p>
<p>Case 0 is that the cache has just been created, without ever having been attached to. (0 because that is the default value for an initially empty file that has just been mapped into shared memory).</p>
<p>Case 1 is that there is a process which has noticed that the cache is not initialized, and is initializing it (in other words, it atomically switched the 0 flag to 1). This is a locking condition: No other process will attempt to initialize the cache. But the cache is not initialized yet!</p>
<p>Case 2 occurs when the cache has been finally initialized, and can have the standard locks and methods used. To access a cache that is in this condition you must use the cache mutex.</p>
<p>I don&#8217;t use a spinlock all the time because my implementation does not do any magical non-locking algorithms, and therefore some operations might take some significant time with the lock held. Using a mutex allows threads that are waiting to sleep and save CPU and battery power, which would not work with a spinlock.</p>
<h3>Cache handling</h3>
<p>Any cache needs a method of deciding when to remove old entries. This is especially vital for hash-based caches that use probing, like KSharedDataCache, where allowing the cache to reach maximum capacity will make it very slow since probing becomes both more common, and more lengthy. I use several techniques to try to get rid of old entries. I make no promises as to their effectiveness, but I felt it was better to try something than to do nothing. The techniques are:</p>
<ul>
<li>Limited Quadratic Probing: One standard method of handling items that hash to the same location in a hash table is to use &#8220;probing&#8221;, where the insertion/find algorithms look at the next entry, then the next, and so on until a free spot is found. Obviously this takes longer, <em>especially</em> if the hash function tends to make entries cluster anyways. In the case of KSharedDataCache it&#8217;s perfectly acceptable to simply give up after a certain number of attempts, and I quite willingly do so (but see the next technique). On the other hand if you can avoid colliding you don&#8217;t have to worry about finding empty spots, so to that end I use the &#8220;<a href="http://www.isthe.com/chongo/tech/comp/fnv/index.html">FNV</a>&#8221; hash function by Fowler, Yo, and Noll.</li>
<li>Ramped Entry Aging&trade;: The basic idea is that as the amount of entries in the cache goes up, it becomes more likely that the insertion method will, instead of probing past a colliding entry, artificially decrease its use count, and kick it out if it becomes unused. There are competing effects here: There&#8217;s no point having a cache if you&#8217;re not going to employ it, so this aging never happens if the cache is lightly loaded. On the other hand entries that get added to the cache and only ever used once could cause collisions for weeks afterwards in the long-lived scenarios I envision so it is important to make entries justify their use. So as the cache load increases, there is a higher and higher chance of entries being evicted if unused. I simply divide the use count in half, so an entry can be quickly evicted even if used a million times a month ago.</li>
<li>Collateral Evictions&reg;: In the event that the first two options don&#8217;t work, then some entries have to be kicked out to make room for new ones. This process is called eviction. In my Collateral Evictions plan, anytime we kick entries out, we kick <em>even more</em> entries out on top of that (I chose twice as many, for no particular reason). The idea is that if we&#8217;re running of out space we&#8217;ll probably have to kick someone else out on the very next insert call anyways, so since it&#8217;s a time-consuming operation we might as well make it effective. The exact entries that get kicked out are decided based on the developer-configurable eviction policy.</li>
</ul>
<p>Next time I&#8217;ll talk about defragmentation, porting KIconLoader, and any other random things I can think up. I hope it hasn&#8217;t been deathly boring so far!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.purinchu.net/wp/2010/05/08/implementing-a-shared-cache-part-3/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
