<?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>SysAdmin Adventures &#187; performance</title>
	<atom:link href="http://blog.tpa.me.uk/tag/performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tpa.me.uk</link>
	<description>Tech notes from a Systems Administrator</description>
	<lastBuildDate>Mon, 31 Oct 2011 11:09:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Kronolith Performance Problem</title>
		<link>http://blog.tpa.me.uk/2009/09/17/kronolith-performance-problem/</link>
		<comments>http://blog.tpa.me.uk/2009/09/17/kronolith-performance-problem/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 11:27:16 +0000</pubDate>
		<dc:creator>Zordrak</dc:creator>
				<category><![CDATA[Web Apps]]></category>
		<category><![CDATA[horde]]></category>
		<category><![CDATA[kronolith]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://blog.tpa.me.uk/?p=143</guid>
		<description><![CDATA[I use Kronolith all over the place. It&#8217;s part of the Horde application suite. It is basically a very featureful calendar server and I like it a lot. Having said that, I use it pretty much exclusively from Sunbird/Lightning because the web-interface still needs a little work in my opinion. Nonetheless it&#8217;s very good. The [...]]]></description>
			<content:encoded><![CDATA[<p>I use Kronolith all over the place. It&#8217;s part of the Horde application suite. It is basically a very featureful calendar server and I like it a lot. Having said that, I use it pretty much exclusively from Sunbird/Lightning because the web-interface still needs a little work in my opinion. Nonetheless it&#8217;s very good.</p>
<p><strong>The Problem.</strong><br />
I recently rolled it out at work along with the rest of the Horde webmail suite (and some extras and tweaks), and immediately ran into a problem. I imported the CEO&#8217;s calendar without a hitch, but as soon as I tried to access it via the RPC .ics file link (i.e. via Sunbird) I discovered the problem &#8211; it was taking forever to spit the file out. I discovered I could duplicate the problem from anywhere and it always took about 50 seconds between asking for the .ics file and actually receiving it.</p>
<p>After MANY hours trying to debug the problem, finally resulting in using the Zend xdebug extension to produce a call-graph with time information that I could view in KCacheGrind I discovered that those 50 seconds were pretty much ALL spent in php::iconv_substr, from calls made in Horde&#8217;s String.php.</p>
<p>The bottom line is, in order to wrap strings to conform to the .ics file standard specification, the developers created their own wordwrap function instead of using PHP&#8217;s own wordwrap function because the latter wouldn&#8217;t do line-folding in the way required by the specification. The problem is, the Horde developers&#8217; version is extremely inefficient in comparison to the PHP version. This hasn&#8217;t really cropped up before because (I guess) not a lot of people put much information in the &#8220;Description&#8221; section of events. Thing is, the CEO&#8217;s PA had been filling out the Description field with a duplicate of the Location and Date information along with anything else that was relevant and a long end-line that was just symbols. With all of this text to wordwrap into .ics file standard using an inefficient wordwrap function, it took forever &#8211; well 50 seconds anyway.</p>
<p><strong>The Solution.</strong><br />
Solution the first: get the PA to stop duplicating information that was already a core part of the event object anyway and try to limit the use of the Description field. Obviously that&#8217;s not much of a solution, but I&#8217;m certain it will make a good amount of difference.</p>
<p>The actual solution, is simply to dump the Horde developers&#8217; wordwrap function in favour of the native PHP function. This does make for .ics files that are not quite standards compliant, but so far I haven&#8217;t had any clients complain or fail to function properly with them. I don&#8217;t like it, but if I have to choose between standards compliance with a 50s load time and very slight non-compliance with a 3s load time, I know which I&#8217;m going to pick every time.</p>
<p>The change itself is tiny. Find lib/Horde/iCalendar.php and head to around line 1055. It&#8217;s line 1055 in Horde Groupware Webmail Edition v1.2.3, but it may be slightly different in your version.</p>
<p>Remove or comment out the lines:</p>
<div class="codecolorer-container php geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$attr_string</span> <span style="color: #339933;">=</span> String<span style="color: #339933;">::</span><a href="http://www.php.net/wordwrap" onclick="pageTracker._trackPageview('/outgoing/www.php.net/wordwrap?referer=');"><span style="color: #990000;">wordwrap</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attr_string</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">75</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_newline <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'utf-8'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>and replace with:</p>
<div class="codecolorer-container php geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$attr_string</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/wordwrap" onclick="pageTracker._trackPageview('/outgoing/www.php.net/wordwrap?referer=');"><span style="color: #990000;">wordwrap</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attr_string</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">75</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_newline <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>et voilá.</p>
<p>I don&#8217;t believe the developers plan on fixing this problem in the Horde H3 (version 3) tree, but I am assured that they are refactoring the code for Horde 4 which should take care of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tpa.me.uk/2009/09/17/kronolith-performance-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

