<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Optimization</title>
	<link>http://www.nobugs.org/blog/archives/2004/02/26/optimization/</link>
	<description>Thoughts of a software engineer</description>
	<pubDate>Thu, 28 Aug 2008 19:21:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Reinout Heeck</title>
		<link>http://www.nobugs.org/blog/archives/2004/02/26/optimization/#comment-63</link>
		<dc:creator>Reinout Heeck</dc:creator>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0000</pubDate>
		<guid>http://www.nobugs.org/blog/archives/2004/02/26/optimization/#comment-63</guid>
		<description>I spend a lot of time thinking about similar stuff, but keep promising myself to leave implementation to others ;-)

You may want to browse some research on graph transformation languages and their language of specification. &lt;a href="http://citeseer.nj.nec.com/bardohl99application.html"&gt;Here&lt;/a&gt;'s a paper that might entertain you,  this one surveys some visual languages for graph transformation specification but also touches on some of the underlying complexities regarding the implementation of graph rewriting systems.</description>
		<content:encoded><![CDATA[<p>I spend a lot of time thinking about similar stuff, but keep promising myself to leave implementation to others <img src='http://www.nobugs.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
You may want to browse some research on graph transformation languages and their language of specification. <a href="http://citeseer.nj.nec.com/bardohl99application.html">Here</a>&#8217;s a paper that might entertain you,  this one surveys some visual languages for graph transformation specification but also touches on some of the underlying complexities regarding the implementation of graph rewriting systems.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://www.nobugs.org/blog/archives/2004/02/26/optimization/#comment-64</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0000</pubDate>
		<guid>http://www.nobugs.org/blog/archives/2004/02/26/optimization/#comment-64</guid>
		<description>You owe me a beer. :)

I sympathise with your point of view. After writing a reasonably straightforward and very slow algorithm, its maddening to take successive passes over your reasonably easy to understand code and transform it into a horribly butchered and very brittle thing. 

You would definately need something domain specific to help with any serious optimization, and even that probably wouldnt be enough. For example, in the simple case you would perform everything in high precision floating point, or even better as much precision as you need, but often you have to compromise and drop precision in favour of speed, and that requires some interaction with your black box optimizer to tell it what it can get away with.

The frustrating part is the amount of time that we have to devote to plumbing and wiring and jury rigging the elegant solutions we enjoy spending our time devising. I'll buy you a pint when you've found the solution. :)

Craig</description>
		<content:encoded><![CDATA[<p>You owe me a beer. <img src='http://www.nobugs.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I sympathise with your point of view. After writing a reasonably straightforward and very slow algorithm, its maddening to take successive passes over your reasonably easy to understand code and transform it into a horribly butchered and very brittle thing. </p>
<p>You would definately need something domain specific to help with any serious optimization, and even that probably wouldnt be enough. For example, in the simple case you would perform everything in high precision floating point, or even better as much precision as you need, but often you have to compromise and drop precision in favour of speed, and that requires some interaction with your black box optimizer to tell it what it can get away with.</p>
<p>The frustrating part is the amount of time that we have to devote to plumbing and wiring and jury rigging the elegant solutions we enjoy spending our time devising. I&#8217;ll buy you a pint when you&#8217;ve found the solution. <img src='http://www.nobugs.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Craig</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony Bailey</title>
		<link>http://www.nobugs.org/blog/archives/2004/02/26/optimization/#comment-65</link>
		<dc:creator>Anthony Bailey</dc:creator>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0000</pubDate>
		<guid>http://www.nobugs.org/blog/archives/2004/02/26/optimization/#comment-65</guid>
		<description>(That some refactorings are the mirror of optimisations is a nice observation. Thankyou for that.)

When I read this article, I was reminded of the idea of proving the correctness of programs. Bear with me for an analogy.

When I was studying, there was this idea that a program might come with a proof that it accorded to some specification. The developer enviroment would have tools that helped you derive a program from the specification in a way that guaranteed that it met that spec. Of course this can be done for toy programs. The hope was that approaches could be found that would scale well enough to help in the real world.

For the most part, this dream has not been realised. Formalising specifications is hard! Formalising proof/derivation techniques is harder, &lt;strong&gt;and&lt;/strong&gt; it always misses some of the ever expanding set of tricks you want to use. I'm sure progress continues to be made in these areas, but it hasn't touched my daily developer life since I left academia.

So back in the real world, we get value from using unit tests instead. It's one tenable way of kinda formalising specifications, because programming languages are pretty good ways to describe the behaviour of programs. And although running lots of test cases doesn't guarantee program correctness, it's a significant confidence boost. You haven't shown the program will always do the right thing, but you have definitely shown it does the right thing in lots of important cases. (Quasi)Proof by example.

By now the analogy should be obvious. (If you prefer, it's not even an analogy, just a specialization of the above to a particular kind of spec/test.) Yes, it would be wonderful to formalise a framework wherein one could apply all the useful transformations to turn nice programs into fast programs and therefore know that these two programs - the one you understand and the one you run - were intensionally equivalent. Nice research project. May pay off big one day.

In the mean time, here we are in that real world again. So: write the nice program. Derive the fast program yourself, by hand, using all your cleverness. Then offer evidence that they are &lt;em&gt;extensionally&lt;/em&gt; equivalent: make sure they give appropriately equal results when run on a battery of test-cases.

(I know I'm not saying you anything you don't already know, Andy, since you implemented various clean reference renderers to test for equivalence with the quick-but-dirty tweaked to SSE hell released versions at Voxar. But I thought it might be worth saying it out loud nonetheless.)</description>
		<content:encoded><![CDATA[<p>(That some refactorings are the mirror of optimisations is a nice observation. Thankyou for that.)</p>
<p>When I read this article, I was reminded of the idea of proving the correctness of programs. Bear with me for an analogy.</p>
<p>When I was studying, there was this idea that a program might come with a proof that it accorded to some specification. The developer enviroment would have tools that helped you derive a program from the specification in a way that guaranteed that it met that spec. Of course this can be done for toy programs. The hope was that approaches could be found that would scale well enough to help in the real world.</p>
<p>For the most part, this dream has not been realised. Formalising specifications is hard! Formalising proof/derivation techniques is harder, <strong>and</strong> it always misses some of the ever expanding set of tricks you want to use. I&#8217;m sure progress continues to be made in these areas, but it hasn&#8217;t touched my daily developer life since I left academia.</p>
<p>So back in the real world, we get value from using unit tests instead. It&#8217;s one tenable way of kinda formalising specifications, because programming languages are pretty good ways to describe the behaviour of programs. And although running lots of test cases doesn&#8217;t guarantee program correctness, it&#8217;s a significant confidence boost. You haven&#8217;t shown the program will always do the right thing, but you have definitely shown it does the right thing in lots of important cases. (Quasi)Proof by example.</p>
<p>By now the analogy should be obvious. (If you prefer, it&#8217;s not even an analogy, just a specialization of the above to a particular kind of spec/test.) Yes, it would be wonderful to formalise a framework wherein one could apply all the useful transformations to turn nice programs into fast programs and therefore know that these two programs - the one you understand and the one you run - were intensionally equivalent. Nice research project. May pay off big one day.</p>
<p>In the mean time, here we are in that real world again. So: write the nice program. Derive the fast program yourself, by hand, using all your cleverness. Then offer evidence that they are <em>extensionally</em> equivalent: make sure they give appropriately equal results when run on a battery of test-cases.</p>
<p>(I know I&#8217;m not saying you anything you don&#8217;t already know, Andy, since you implemented various clean reference renderers to test for equivalence with the quick-but-dirty tweaked to SSE hell released versions at Voxar. But I thought it might be worth saying it out loud nonetheless.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AlexF</title>
		<link>http://www.nobugs.org/blog/archives/2004/02/26/optimization/#comment-66</link>
		<dc:creator>AlexF</dc:creator>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0000</pubDate>
		<guid>http://www.nobugs.org/blog/archives/2004/02/26/optimization/#comment-66</guid>
		<description>You owe me, and and a rapidly-expanding set of engineers nearby, a beer :)

Here's a complex problem: What if the optimization isn't just performed at a code level? What if you could also significantly optimize the data structures? If I write the simplest possible algorithm to perform a set of operations on a simple data structure, is there any way of specifying not just ways to transform the code to operate more efficiently, but also transforming the data structure to be more efficient in the context of the algorithm(s)?

The data structure issue isn't so relevant in, say, volume rendering, but it's a potentially huge win if you have something more complex. Debugging the optimized code and data structures would be "interesting". 

I think I need more knowledge of graph theory...</description>
		<content:encoded><![CDATA[<p>You owe me, and and a rapidly-expanding set of engineers nearby, a beer <img src='http://www.nobugs.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Here&#8217;s a complex problem: What if the optimization isn&#8217;t just performed at a code level? What if you could also significantly optimize the data structures? If I write the simplest possible algorithm to perform a set of operations on a simple data structure, is there any way of specifying not just ways to transform the code to operate more efficiently, but also transforming the data structure to be more efficient in the context of the algorithm(s)?</p>
<p>The data structure issue isn&#8217;t so relevant in, say, volume rendering, but it&#8217;s a potentially huge win if you have something more complex. Debugging the optimized code and data structures would be &#8220;interesting&#8221;. </p>
<p>I think I need more knowledge of graph theory&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Birkett</title>
		<link>http://www.nobugs.org/blog/archives/2004/02/26/optimization/#comment-67</link>
		<dc:creator>Andrew Birkett</dc:creator>
		<pubDate>Thu, 01 Jan 1970 01:00:00 +0000</pubDate>
		<guid>http://www.nobugs.org/blog/archives/2004/02/26/optimization/#comment-67</guid>
		<description>Yeah, I briefly &lt;a href="http://rover.cs.northwestern.edu/~surana/blog/past/000132.html"&gt;discussed this kind of idea&lt;/a&gt; with someone.  There's the whole other axis concerning whether you "know a priori" what you need to optimize, or whether this is something you can only discover by running typical test cases - eg. profile driving optimization.

Graph theory: yeah, I always resent when one of my real-world interests drives me to learn about some dry, abstract area like graph theory.  But it's happening more and more.  Automated proof systems is the other thing which I keep getting dragged reluctantly towards.

You can claim your beer next time you're in Edinburgh. :-)</description>
		<content:encoded><![CDATA[<p>Yeah, I briefly <a href="http://rover.cs.northwestern.edu/~surana/blog/past/000132.html">discussed this kind of idea</a> with someone.  There&#8217;s the whole other axis concerning whether you &#8220;know a priori&#8221; what you need to optimize, or whether this is something you can only discover by running typical test cases - eg. profile driving optimization.</p>
<p>Graph theory: yeah, I always resent when one of my real-world interests drives me to learn about some dry, abstract area like graph theory.  But it&#8217;s happening more and more.  Automated proof systems is the other thing which I keep getting dragged reluctantly towards.</p>
<p>You can claim your beer next time you&#8217;re in Edinburgh. <img src='http://www.nobugs.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>
