<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>Vincent Geddes &#187; General</title>
	<atom:link href="http://blogs.gnome.org/vgeddes/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.gnome.org/vgeddes</link>
	<description>Blogging is Serious Business!</description>
	<lastBuildDate>Sat, 13 Sep 2008 18:37:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license>		<item>
		<title>Fibonacci Redux</title>
		<link>http://blogs.gnome.org/vgeddes/2008/07/15/fibonacci-redux/</link>
		<comments>http://blogs.gnome.org/vgeddes/2008/07/15/fibonacci-redux/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 01:56:03 +0000</pubDate>
		<dc:creator>vgeddes</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Smalltalk]]></category>

		<guid isPermaLink="false">http://blogs.gnome.org/vgeddes/2008/07/15/fibonacci-redux/</guid>
		<description><![CDATA[Time for more microbenchmarks! Someone just pointed me out to this post which describes another fibonacci shootout. It gave the brand new Ruby 1.9 VM a test drive. Ruby 1.9&#8217;s execution model is quite different from 1.8, featuring a highly optimized bytecode interpreter (codenamed YARV). I must admit that I totally overlooked YARV. All the [...]]]></description>
			<content:encoded><![CDATA[<p>Time for more microbenchmarks! Someone just pointed me out to this <a href="http://antoniocangiano.com/2007/11/28/holy-shmoly-ruby-19-smokes-python-away/">post</a> which describes another <a href="http://en.wikipedia.org/wiki/Fibonacci_number">fibonacci</a> shootout. It gave the brand new Ruby 1.9 VM a test drive. Ruby 1.9&#8217;s execution model is quite different from 1.8, featuring a highly optimized bytecode interpreter (codenamed YARV). I must admit that I totally overlooked YARV. All the buzz around <a href="http://rubini.us/">Rubinius</a> distracted me.</p>
<p>YARV beats the pants off ruby 1.8. It also outperforms Panda Smalltalk, not by much though. I have prepared a fresh benchmark. This time I present the fibonacci code using images since wordpress refuses to let me format language code sanely. I also got a bit carried away with GIMP and made the code look all pretty.</p>
<p style="text-align: center"><img src="http://blogs.gnome.org/vgeddes/files/2008/07/fib-rb190.png" alt="fib-rb190.png" /></p>
<p style="text-align: center"><img src="http://blogs.gnome.org/vgeddes/files/2008/07/fib-st2.png" alt="fib-st2.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/vgeddes/2008/07/15/fibonacci-redux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Progress</title>
		<link>http://blogs.gnome.org/vgeddes/2008/07/10/progress/</link>
		<comments>http://blogs.gnome.org/vgeddes/2008/07/10/progress/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 14:37:48 +0000</pubDate>
		<dc:creator>vgeddes</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Smalltalk]]></category>

		<guid isPermaLink="false">http://blogs.gnome.org/vgeddes/2008/07/10/progress/</guid>
		<description><![CDATA[I am having great fun working on my Smalltalk VM. I spent the last few weeks mainly on implementing a compacting garbage collector. There have been some nice additions to the class library, including the Set, Dictionary, and System classes.What&#8217;s been particularly pleasing to me personally is that certain benchmarks have come out very fast, [...]]]></description>
			<content:encoded><![CDATA[<p>I am having great fun working on my Smalltalk VM. I spent the last few weeks mainly on implementing a compacting garbage collector. There have been some nice additions to the class library, including the Set, Dictionary, and System classes.What&#8217;s been particularly pleasing to me personally is that certain benchmarks have come out very fast, faster than Python or Ruby.</p>
<h2> Fibonacci Benchmark</h2>
<pre>fibonacci
    self &lt;= 2
        ifTrue: [^ 1]
        ifFalse: [^ (self - 2) fibonacci + (self - 1) fibonacci].</pre>
<p>The naive recursive fibonacci function isn&#8217;t a very exemplary benchmark. Nevertheless, I am advertising the results here because I think its a good start. In my opinion, the fibonacci function does at least give a good benchmark for method invocation performance (i.e changing the current context or activation record of an interpreter). The benchmarks below are all based on calculating the 32nd fibonacci number. I assume that the Python and Ruby binaries are compiled using the optimal CFLAGS. If that&#8217;s not the case, then I guess Ubuntu has a bit of a problem.</p>
<h3>Squeak Smalltalk: 0.427s</h3>
<p>The winner, <a href="http://www.squeak.org">Squeak</a>. I can&#8217;t reason about why its faster than Panda. I suspect squeak&#8217;s context management scheme is slightly more optimized at the moment.</p>
<h3>Panda Smalltalk: 0.67s</h3>
<p>Yes, that&#8217;s my <a href="https://edge.launchpad.net/panda-smalltalk">VM</a>! coming a respectable second. As I stated above, there&#8217;s still work to be done on context management. The executable was compiled using &#8220;-g -O3 -fomit-frame-pointer&#8221;.</p>
<h3>Python: 1.18s</h3>
<p>Python has a bytecode interpreter and uses the C stack to store activation records. So its context management is probably an order of magnitude faster than Panda. I suspect the python is slower as it allocates an actual object for each integer. In Panda, integers are just stuffed into pointers, which are then tagged in the two low-order bits so that the interpreter can differentiate between normal objects and integers.</p>
<h3>Ruby: 4m0.2s</h3>
<p>No excuse. This gives dynamic languages a bad name. I suspect the main performance killer here is that Ruby&#8217;s execution model is based upon an abstract syntax tree rather than bytecodes. The problem with AST&#8217;s is that the nodes are spread throughout the heap, reducing locality. A lot of indirect memory references are required during execution, which slows things down. Hopefully Rubinius or JRuby will improve matters since they include bytecode interpreters.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/vgeddes/2008/07/10/progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3 + 4</title>
		<link>http://blogs.gnome.org/vgeddes/2008/04/14/3-4/</link>
		<comments>http://blogs.gnome.org/vgeddes/2008/04/14/3-4/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 23:00:10 +0000</pubDate>
		<dc:creator>vgeddes</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Smalltalk]]></category>

		<guid isPermaLink="false">http://blogs.gnome.org/vgeddes/2008/04/14/3-4/</guid>
		<description><![CDATA[As some of you might have noticed, I have become somewhat of a Smalltalk weenie recently. This was a long time coming, but basically a reaction to many years of tedious hacking in C. Now don&#8217;t get me wrong, C is a great language, I still love it, but I have been using it in [...]]]></description>
			<content:encoded><![CDATA[<p>As some of you might have noticed, I have become somewhat of a Smalltalk <a href="http://c2.com/cgi/wiki?SmugSmalltalkWeenie">weenie</a> recently. This was a long time coming, but basically a reaction to many years of tedious hacking in C. Now don&#8217;t get me wrong, C is a great language, I still love it, but I have been using it in entirely inappropriate places.</p>
<p>After reading up on Smalltalk a few months ago, I was entranced, and quickly decided that I just had to build my own Smalltalk system. Since I didn&#8217;t want it to be tied to any sort of platform (i.e. Java), I chose to write it in C (C99 to be specific).</p>
<p>I started out with the compiler. In order to learn more about compiler theory, I wrote a Smalltalk source-to-bytecode compiler from the ground up. The compiler translates source code into a compact bytecode representation consisting of about 30 different bytecodes. Currently, all Smalltalk-80 syntax is supported (except for message cascades). Of course, the compiler needs to manipulate on Smalltalk objects, so I also designed an object memory model (basically how objects are stored in physical memory). All objects have the same header, consisting of book-keeping, hash, and class fields. I intend to reduce the number of header fields to two though, since the hash field is often unnecessary. For example, instances of <em>String</em> will have a custom hash function, and will never need to access the hash field.</p>
<p>As with most Smalltalk VMs (and possibly Python/Ruby), integers are represented using tagged pointers. This kind of pointer has a 1-bit tag in the low-order position. If the bit is 1, then the rest of the pointer contains a 31-bit integer, otherwise, the pointer simply points to a heap-allocated object. This arrangement increases performance greatly, as having to heap-allocate integer objects would absolutely kill performance. We can get away with this, since on most architectures, pointers are aligned on 4 byte boundaries, thus leaving the low-order 2 bits of each pointer unused.</p>
<p>Just this evening, the VM passed a critical milestone, that of being able to evaluate the expression &#8220;3 + 4&#8243;. This sounds trivial, but a whole of lot nuts-and-bolts have to be in place to make this work. A few hours after the &#8220;3+4&#8243; test, the VM was capable of executing unary methods, as well as handling local variables and activation records.</p>
<p>Below is some sample Smalltalk code which shows what the VM can do currently, basically some arithmetic, local variable manipulation, and a method call to &#8220;increment&#8221;. Note that the method <em>doIt</em> belongs to the <em>UndefinedObject</em> class, and <em>increment</em> to <em>SmallInteger.</em></p>
<p><img src="http://blogs.gnome.org/vgeddes/files/2008/04/smalltalk.png" alt="smalltalk.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/vgeddes/2008/04/14/3-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
