<?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>Toru Maesaka &#187; oss</title>
	<atom:link href="http://torum.net/category/oss/feed/" rel="self" type="application/rss+xml" />
	<link>http://torum.net</link>
	<description>Hackaholic and a Web Addict based in Tokyo</description>
	<lastBuildDate>Tue, 28 Feb 2012 10:52:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>BlitzDB Crash Safety and Auto Recovery</title>
		<link>http://torum.net/2010/07/blitzdb-crash-safety-and-auto-recovery/</link>
		<comments>http://torum.net/2010/07/blitzdb-crash-safety-and-auto-recovery/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 09:43:14 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[blitzdb]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://torum.net/?p=2369</guid>
		<description><![CDATA[Crash Safety is a big deal in the database league. Lack of durability can lead to all sorts of terrible things upon a catastrophic event. Many projects, especially in the so called NoSQL world compromises crash safety in return for higher QPS. The argument there is that the availability of the overall system should be [...]]]></description>
			<content:encoded><![CDATA[<p>Crash Safety is a big deal in the database league. Lack of durability can lead to all sorts of terrible things upon a catastrophic event. Many projects, especially in the so called NoSQL world compromises crash safety in return for higher QPS. The argument there is that the availability of the overall system should be accomplished by replication since a database server can&#8217;t be rescued if the physical disk breaks. I happen to agree with this philosophy but I am also aware that this isn&#8217;t a correct answer for everyone. So, what will I do with BlitzDB?</p>
<p>Several relational database hackers have pointed out that BlitzDB isn&#8217;t any safer than MyISAM since it doesn&#8217;t guarantee crash safety. This is currently true but I plan on making BlitzDB much safer than MyISAM by providing following features.</p>
<ol>
<li>Auto Recovery Routine (startup option)</li>
<li>Tokyo Cabinet&#8217;s Transaction API (table-specific option)</li>
</ol>
<p>The second feature above would actually guarantee BlitzDB to be crash safe (especially combined with auto recovery) but I won&#8217;t get into depth in this post since this topic deserves a blog post of it&#8217;s own. Let me just state that this feature will be provided in a form like this:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> t1 <span style="color: #66cc66;">&#40;</span>
  a int <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">,</span>
  b varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE <span style="color: #66cc66;">=</span> BLITZDB<span style="color: #66cc66;">,</span> CRASH_SAFE;</pre></div></div>

<p>From here on, I&#8217;ll cover how I plan on hacking auto recovery in BlitzDB.</p>
<h3>Auto Recovery Challenges</h3>
<p>As I blogged a while back, <a href="http://torum.net/2010/01/how-to-recover-a-tokyo-cabinet-database-file/">recovering Tokyo Cabinet</a> is relatively simple. However, this is not a sufficient solution in BlitzDB since the data file (hash database that actually holds the rows) and the index file(s) are independent from each other. That is, the likelihood of the data file and the index file(s) to be inconsistent is very high after a crash. So, how can we hack on this? Pretty simple.</p>
<h3>Indexes aren&#8217;t Important at Recovery Phase</h3>
<p>Because BlitzDB logically separates the data file and it&#8217;s indexes, index files aren&#8217;t that important. If a server crash had occurred, BlitzDB could delete the index file(s) and recompute them from the data file. Needless to say, this process would involve a lot of random access and computation but it would not dominate the time space of the system since it&#8217;s a one-time cost. This approach however has one flaw in it such that the index files can&#8217;t be recomputed if the data file is broken or is unrecoverable.</p>
<p>Therefore to guarantee crash safety, BlitzDB must ensure that the data file is unbreakable. This is precisely where Tokyo Cabinet&#8217;s Transaction API comes in. I&#8217;m planning on using it to protect the data file from breaking. If the data file is protected, the table can be rescued. Simple!</p>
<p>So, that&#8217;s what I have in mind for making BlitzDB a safer engine. Unfortunately I can&#8217;t start hacking on it immediately since I have several bugs to fix first. Nevertheless I&#8217;m looking forward to start hacking on it. This challenge should be quite fun to tackle.</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2010/07/blitzdb-crash-safety-and-auto-recovery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extending CREATE TABLE Syntax in Drizzle</title>
		<link>http://torum.net/2010/07/extending-create-table-syntax-in-drizzle/</link>
		<comments>http://torum.net/2010/07/extending-create-table-syntax-in-drizzle/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 17:37:42 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[api]]></category>

		<guid isPermaLink="false">http://torum.net/?p=2367</guid>
		<description><![CDATA[The flexibility to add table-specific options for things like compression, encryption and optimization can be useful to storage engine developers as this flexibility can open up new possibilities. Here&#8217;s what I&#8217;m talking about: CREATE TABLE t1 &#40; ... &#41; ENGINE = my_engine, MY_OPTION = your_arg; Supporting this is relatively easy in Drizzle and this API [...]]]></description>
			<content:encoded><![CDATA[<p>The flexibility to add table-specific options for things like compression, encryption and optimization can be useful to storage engine developers as this flexibility can open up new possibilities. Here&#8217;s what I&#8217;m talking about:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> t1 <span style="color: #66cc66;">&#40;</span>
  <span style="color: #66cc66;">...</span>
<span style="color: #66cc66;">&#41;</span> ENGINE <span style="color: #66cc66;">=</span> my_engine<span style="color: #66cc66;">,</span> MY_OPTION <span style="color: #66cc66;">=</span> your_arg;</pre></div></div>

<p>Supporting this is relatively easy in Drizzle and this API feature (and a bit more) is <a href="http://askmonty.org/wiki/Manual:Extending_CREATE_TABLE">available in MariaDB</a> as well. Unfortunately Drizzle&#8217;s method to do this isn&#8217;t documented in the Wiki yet but it should be added when our Storage Engine API becomes stable (as in, no interface changes).</p>
<h3>Implement StorageEngine::doValidateTableOptions()</h3>
<p>Here&#8217;s the actual interface.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">bool</span> StorageEngine<span style="color: #008080;">::</span><span style="color: #007788;">doValidateTableOptions</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> <span style="color: #000040;">&amp;</span>key,
                                           <span style="color: #0000ff;">const</span> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> <span style="color: #000040;">&amp;</span>state<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>This function is called for each table options given at CREATE TABLE syntax execution. The first argument, <em>key</em> is a const reference to a string that represents the option name. The second argument, <em>state</em> represents the argument given for that option.</p>
<p>Therefore, given: <em>COMPRESSION = YES_PLEASE</em>, <em>key</em> would be &#8220;COMPRESSION&#8221; and <em>state</em> would be &#8220;YES_PLEASE&#8221;. The objective of this function is to check whether the key/state pair makes sense to your storage engine. If this function returns false, Drizzle will return an error for the CREATE TABLE query. Personally I think this interface can be improved to be a bit more Developer friendly, such as making life easier to validate numeric values without enforcing the developer to play around with the data. Saying that, given the pace that Drizzle is growing, this could be improved before we know it.</p>
<h3>Access Options at StorageEngine::doCreateTable()</h3>
<p>Here&#8217;s the actual interface for doCreateTable().</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">int</span> doCreateTable<span style="color: #008000;">&#40;</span>drizzled<span style="color: #008080;">::</span><span style="color: #007788;">Session</span> <span style="color: #000040;">&amp;</span>session,
                  drizzled<span style="color: #008080;">::</span><span style="color: #007788;">Table</span> <span style="color: #000040;">&amp;</span>table_arg,
                  <span style="color: #0000ff;">const</span> drizzled<span style="color: #008080;">::</span><span style="color: #007788;">TableIdentifier</span> <span style="color: #000040;">&amp;</span>identifier,
                  drizzled<span style="color: #008080;">::</span><span style="color: #007788;">message</span><span style="color: #008080;">::</span><span style="color: #007788;">Table</span> <span style="color: #000040;">&amp;</span>table_proto<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>Given that the options were successfully validated, doCreateTable() is called next. In Drizzle, all information regarding a table (including options) is represented in a Google Protocol Buffer message. A reference to that message object is passed to doCreateTable() as the fourth argument so all you need to do is loop through the options list in the message object and extract what you need. Here&#8217;s a minimal example that only takes care of one option.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">int</span> n_options <span style="color: #000080;">=</span> table_proto.<span style="color: #007788;">engine</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>.<span style="color: #007788;">options_size</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> n_options<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
  <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>table_proto.<span style="color: #007788;">engine</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>.<span style="color: #007788;">options</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span>.<span style="color: #007788;">name</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> <span style="color: #FF0000;">&quot;my_option_name&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">// Do whatever you like with this stream.</span>
    std<span style="color: #008080;">::</span><span style="color: #007788;">istringstream</span> stream<span style="color: #008000;">&#40;</span>table_proto.<span style="color: #007788;">engine</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>.<span style="color: #007788;">options</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span>.<span style="color: #007788;">state</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>The above example should be simple to extend to handle multiple options. What&#8217;s really important in the above example is that the option name can be accessed with the name() accessor and the state (value) of that option with the state() accessor.</p>
<p>So, that&#8217;s all I have to cover for now. I hope this feature will help storage engine developers create and provide useful table specific features for their engine.</p>
<p>Happy Hacking.</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2010/07/extending-create-table-syntax-in-drizzle/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>BlitzDB is now in Drizzle&#8217;s Trunk Repository</title>
		<link>http://torum.net/2010/06/blitzdb-drizzle-merge/</link>
		<comments>http://torum.net/2010/06/blitzdb-drizzle-merge/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 11:20:45 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[blitzdb]]></category>

		<guid isPermaLink="false">http://torum.net/?p=2362</guid>
		<description><![CDATA[Happy to announce that BlitzDB has been merged with Drizzle&#8217;s Trunk. As much as I&#8217;m excited, it&#8217;s time to come back to reality. This merge is merely a beginning. There is much more work that needs to be done to BlitzDB such as ensuring stability by adding more tests, find bugs, and eliminate them. I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>Happy to announce that BlitzDB has <a href="http://bazaar.launchpad.net/~drizzle-developers/drizzle/development/revision/1626">been merged</a> with Drizzle&#8217;s Trunk.</p>
<p>As much as I&#8217;m excited, it&#8217;s time to come back to reality. This merge is merely a beginning. There is much more work that needs to be done to BlitzDB such as ensuring stability by adding more tests, find bugs, and eliminate them. I&#8217;m hoping that the likelihood of bugs being found will increase due to this merge. Admittedly, I want to hack on fancy (yet important) things like auto recovery but I&#8217;m going to resist doing this until I&#8217;m truly satisfied with the quality of BlitzDB. My plan is to have BlitzDB rock solid by Drizzle&#8217;s Beta release.</p>
<p>The review process to get BlitzDB into Drizzle was straight forward and smooth. This is mostly due to the fact that the community was very supportive about testing. Folks like Stewart Smith and Patrick Crews from Rackspace pointed out several bugs that I would not have found myself. I&#8217;m certainly lucky to have a supportive professional QA engineer (looking at you Patrick) to test out and give punishment to BlitzDB.</p>
<p>All I&#8217;ll be doing on BlitzDB for the next couple of weeks is debugging and refactoring to improve readability. What I need more of at the moment is test cases on JOINs that are likely to be used in practice. If you have a good test case, I would greatly appreciate it!</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2010/06/blitzdb-drizzle-merge/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>BlitzDB Concurrent Testing and Write Performance</title>
		<link>http://torum.net/2010/05/blitzdb-concurrency-testing/</link>
		<comments>http://torum.net/2010/05/blitzdb-concurrency-testing/#comments</comments>
		<pubDate>Wed, 12 May 2010 06:42:05 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[blitzdb]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://torum.net/?p=2353</guid>
		<description><![CDATA[Last month while being at the MySQL Conference, several people asked me about the status of BlitzDB. Specifically, they were interested in when I&#8217;ll release BlitzDB. Fair enough &#8211; I&#8217;ve been working on this project long enough for people to start questioning this. The answer is, BlitzDB is done in terms of implementing the design. [...]]]></description>
			<content:encoded><![CDATA[<p>Last month while being at the MySQL Conference, several people asked me about the status of BlitzDB. Specifically, they were interested in when I&#8217;ll release BlitzDB. Fair enough &#8211; I&#8217;ve been working on this project long enough for people to start questioning this.</p>
<p>The answer is, BlitzDB is done in terms of implementing the design. Right now it&#8217;s about finding bugs, fixing it and testing BlitzDB&#8217;s stability under concurrent load. Thanks to the motivation boost I gained at the conference, I&#8217;ve now fixed the bugs that were slowing me down and I&#8217;m gradually adding more tests into BlitzDB&#8217;s test suite. I consider BlitzDB&#8217;s initial release to be the day it gets merged into Drizzle&#8217;s trunk. This is almost ready as BlitzDB seems to be building fine on Drizzle&#8217;s Build Farm infrastructure. However, I won&#8217;t move to the next step until I&#8217;m satisfied with BlitzDB&#8217;s stability.</p>
<p>Yesterday I spent some time doing some concurrency testing on BlitzDB&#8217;s INSERT code with skyload. Needless to say, concurrency testing is also a convenient way to look at the performance of a particular component. So, I decided to publish my findings from this test. First, here is the background of the test.</p>
<h3>Purpose of the Test</h3>
<ul>
<li>Test BlitzDB&#8217;s slot-lock mechanism.</li>
<li>Confirm that BlitzDB will not crash under concurrent INSERT workload.</li>
<li>Confirm that key insertion to the index is working as expected.</li>
<li>Confirm that writes to multiple indexes work as expected.</li>
<li>Observe the write-performance impact of adding an index.</li>
</ul>
<p>Two commodity boxes were used. One dedicated for the client and the other dedicated for the server (Drizzle + BlitzDB). Both boxes has the same spec: Intel Quad Xeon E5345 (2×4MB L2 cache), 8GB Memory, 500GB SATA II, gigabit NIC. Servers were connected by a gigabit switch. File system on the server was ext3.</p>
<p>By default, a BlitzDB table is optimized for up to 1 million rows. Therefore this test inserted 1 million rows to a table with different concurrency levels. A different concurrency level is used per run. The table used in this test only contains three integer columns. Tests are performed up to three indexes. The linux kenel&#8217;s dirty buffer is flushed before each test run. Tests were run until the performance curve flattened.</p>
<h3>Result</h3>
<p align="center"><a href="http://www.flickr.com/photos/tmaesaka/4598572902/" title="BlitzDB Table Insertion - Multi Index by tmaesaka, on Flickr"><img src="http://farm2.static.flickr.com/1324/4598572902_c1e45d7ac5.jpg" width="500" height="294" alt="BlitzDB Table Insertion - Multi Index" /></a></p>
<p>As seen above, scalability from 1 thread to 4 thread showed an ideal curve. This is expected since the server is a 4 core box. From 4 threads, performance showed some improvements up to 12 threads. From there on, concurrency greatly exceeds the number of physical cores so we can&#8217;t observe decent performance growth. The highest insert QPS gained in this test was <strong>just over 86,000 QPS</strong>. With more cores on the server and more clients, I suspect BlitzDB can hit over 100k QPS.</p>
<p>Although this graph looks good at first sight, I&#8217;m not happy with it. The performance penalty for adding multiple indexes should be greater than what&#8217;s observed in this result. This is because TC&#8217;s B+Tree is internally protected by a single lock on writes. I suspect that the performance penalty is not observed in this graph because I didn&#8217;t give BlitzDB enough load to make TC work hard. This implies that a bottleneck could exist elsewhere (Network, Drizzle or BlitzDB&#8217;s handler level code).</p>
<p>However, I&#8217;m glad that BlitzDB stood stable on this concurrency test which was what I wanted to test in the first place. Admittedly I need to mix several types of queries to properly test BlitzDB&#8217;s stability. I plan on doing this next with sysbench and hopefully <a href="https://launchpad.net/randgen">RQG</a>.</p>
<p>Once this is done, I&#8217;ll submit a merge proposal to the Drizzle Project :)</p>
<h3>Future Development Plans</h3>
<ul>
<li>Find bugs, Fix bugs, Repeat.</li>
<li>Write an inbuilt auto recovery routine.</li>
<li>Eventually add a crash safe option to BlitzDB.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2010/05/blitzdb-concurrency-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing BlitzDB on Drizzle&#8217;s Build Farm</title>
		<link>http://torum.net/2010/05/blitzdb-on-build-farm/</link>
		<comments>http://torum.net/2010/05/blitzdb-on-build-farm/#comments</comments>
		<pubDate>Thu, 06 May 2010 10:37:36 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[blitzdb]]></category>
		<category><![CDATA[hudson]]></category>

		<guid isPermaLink="false">http://torum.net/?p=2349</guid>
		<description><![CDATA[One of many important things that the Drizzle project takes seriously is for the project sourcecode to successfully build in all our target platforms AND pass tests in them. This is not really specific to Drizzle as most open source projects would have the same policy. For example we do the same thing in memcached [...]]]></description>
			<content:encoded><![CDATA[<p>One of many important things that the Drizzle project takes seriously is for the project sourcecode to successfully build in all our target platforms AND pass tests in them. This is not really specific to Drizzle as most open source projects would have the same policy. For example we do the same thing in memcached thanks to Dustin Sailing&#8217;s buildbot kungfu. </p>
<p>Yesterday, Monty Taylor gave me access to Drizzle&#8217;s Build Farm Infrastructure so that I could test BlitzDB on various Linux distributions and FreeBSD. Unfortunately most build machines didn&#8217;t have Tokyo Cabinet installed so I could only test builds on Ubuntu and Debian. Fortunately the build went fine on those platforms though this was predictable since Ubuntu is my primary development platform. What was disturbing was getting test errors on my index test suite. I guess it&#8217;s time to put my thinking cap on and see what the problem is there.</p>
<p>This is a big leap towards getting BlitzDB in Drizzle&#8217;s trunk which I&#8217;m steadily working towards. I also want to benchmark BlitzDB at it&#8217;s current state with <a href="http://sysbench.sourceforge.net/">sysbench</a>&#8216;s OLTP tests. This is still low in my priority queue but hopefully I&#8217;ll do it in the next couple of months.</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2010/05/blitzdb-on-build-farm/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Drizzle Google Summer of Code Projects</title>
		<link>http://torum.net/2010/04/drizzle-summer-of-code/</link>
		<comments>http://torum.net/2010/04/drizzle-summer-of-code/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 06:12:03 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[gsoc]]></category>

		<guid isPermaLink="false">http://torum.net/?p=2346</guid>
		<description><![CDATA[This morning while being half a sleep, I was delighted to see an announcement email for Drizzle&#8217;s Google Summer of Code projects in my inbox. Congratulations to not only those that are taking part in GSoC via Drizzle but all of you participating in GSoC this year. Here&#8217;s the actual announcement email that contains the [...]]]></description>
			<content:encoded><![CDATA[<p>This morning while being half a sleep, I was delighted to see an announcement email for Drizzle&#8217;s Google Summer of Code projects in my inbox. Congratulations to not only those that are taking part in GSoC via Drizzle but all of you participating in GSoC this year. Here&#8217;s the actual announcement email that contains the list of Drizzle projects that will take place this year.</p>
<ul>
<li><a href="https://lists.launchpad.net/drizzle-discuss/msg06568.html">https://lists.launchpad.net/drizzle-discuss/msg06568.html</a></li>
</ul>
<p>This year I&#8217;m mentoring <a href="http://www.ucs.louisiana.edu/~ded5797/">Djellel Eddine Difallah</a> on &#8220;<strong>A Memcached Query Cache Plugin for Drizzle</strong>&#8220;. This happens to be a project I abandoned a <a href="http://torum.net/2008/10/rethink-query-cache-drizzle/">long time ago</a> so I was happy to see someone digging it up and seeking interest in it.</p>
<p>I&#8217;m excited to work with Djellel over the summer. Looking forward to having lots of fun with all the technical challenges and most importantly hacking under the open community environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2010/04/drizzle-summer-of-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DATE type under the hood in Drizzle/MySQL</title>
		<link>http://torum.net/2010/03/date-type-and-drizzle/</link>
		<comments>http://torum.net/2010/03/date-type-and-drizzle/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 07:24:39 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[blitzdb]]></category>
		<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://torum.net/?p=2338</guid>
		<description><![CDATA[Learned something new from my own bug in BlitzDB today. The problem was that writing a DATE column index would always return a duplicate key error (regardless of what I feed it). There are two suspicious candidates that can cause this. Comparison Function has a defect. Key Generator has a defect. The latter suspect was [...]]]></description>
			<content:encoded><![CDATA[<p>Learned something new from my own bug in BlitzDB today. The problem was that writing a DATE column index would always return a duplicate key error (regardless of what I feed it). There are two suspicious candidates that can cause this.</p>
<ul>
<li>Comparison Function has a defect.</li>
<li>Key Generator has a defect.</li>
</ul>
<p>The latter suspect was going to be tricky if it was true since BlitzDB currently uses Drizzle&#8217;s native &#8220;field packer&#8221; (except for VARCHAR) inherited from MySQL. This would mean that Drizzle&#8217;s field system has a bug in it which was somewhat difficult to believe. Furthermore, you should always blame yourself before you start suspecting other people&#8217;s code. So, I decided to look into the comparison function which was completely written by me. Turned out that&#8217;s where the bug was.</p>
<h3>Comparison Function</h3>
<p>Allow me to quickly clarify what I mean by &#8220;comparison function&#8221; in this context. TC&#8217;s B+Tree API has an interface that allows you to provide your own comparison function for all operations that involves traversing.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">bool tcbdbsetcmpfunc<span style="color: #009900;">&#40;</span>TCBDB <span style="color: #339933;">*</span>bdb<span style="color: #339933;">,</span> TCCMP cmp<span style="color: #339933;">,</span> <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>cmpop<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>What BlitzDB&#8217;s comparison function callback does is, it looks at the data type of the values to be compared and performs appropriate processing on the values then compares them. You can also look at it as a long switch statement. For those that are interested, this code is in <a href="http://bazaar.launchpad.net/%7Etmaesaka/blitzdb/trunk/annotate/head%3A/plugin/blitzdb/blitzcmp.cc">blitzcmp.cc</a> (blitz_keycmp_cb).</p>
<h3>DATE under the hood</h3>
<p>After inspecting the &#8220;type number&#8221; with GDB and looking at the corresponding ha_base_keytype enum, it turns out that the DATE type is internally represented as an unsigned 3 byte integer (HA_KEYTYPE_UINT24). This was pleasant to discover since I&#8217;ve been wondering what a 3 byte integer is still used for in Drizzle. The problem I had was that I didn&#8217;t take this type into account in the comparator and it also showed how silly I am since the answer was always there.</p>
<ul>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/storage-requirements.html">10.5. Data Type Storage Requirements</a></li>
</ul>
<p>Now, the question is should it be kept this way? Respect alignment or reduce total I/O and space by keeping it this way? This should hopefully be a fun discussion to have in the Drizzle community :)</p>
<p>P.S. My two cents is that it should respect alignment since folks that seek performance should have most of their data on memory. Respecting alignment in this environment should make some difference. Although, I can only say this after benchmarking it of course.</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2010/03/date-type-and-drizzle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speaking at the MySQL Conference 2010</title>
		<link>http://torum.net/2010/02/speaking-at-the-mysql-conference-2010/</link>
		<comments>http://torum.net/2010/02/speaking-at-the-mysql-conference-2010/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 09:31:30 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[travel]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://torum.net/?p=2336</guid>
		<description><![CDATA[I&#8217;m a little behind in announcing this but I&#8217;m going to be speaking at O&#8217;Reilly&#8217;s MySQL Conference this year. My presentation is a three hour tutorial titled, Drizzle Storage Engine Development. Practical Example with BlitzDB. Three hours is a long time but I assure you that there will be a break. This session isn&#8217;t solely [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a little behind in announcing this but I&#8217;m going to be speaking at O&#8217;Reilly&#8217;s MySQL Conference this year. My presentation is a three hour tutorial titled, <a href="http://en.oreilly.com/mysql2010/public/schedule/detail/12409">Drizzle Storage Engine Development. Practical Example with BlitzDB</a>. Three hours is a long time but I assure you that there will be a break.</p>
<p>This session isn&#8217;t solely about going through Drizzle&#8217;s Storage Engine API. Various performance topics like B+Tree structure, memory handling and concurrency control will be covered. I will also go through BlitzDB&#8217;s design concept and it&#8217;s internal stuff. So, needless to say I&#8217;ll talk a lot about Tokyo Cabinet and it&#8217;s internals as well.</p>
<p>Hopefully those that come along will walk out of the tutorial standing far ahead of the start line. It will help you get started on reading the implementation of other storage engines in the MySQL ecosystem (MyISAM, InnoDB, PBXT, Federated and so forth). Better yet you will start writing one.</p>
<p>Looking forward to seeing you there :)</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2010/02/speaking-at-the-mysql-conference-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Progress on BlitzDB&#8217;s Index Component</title>
		<link>http://torum.net/2010/02/progress-on-blitzdb-index-component/</link>
		<comments>http://torum.net/2010/02/progress-on-blitzdb-index-component/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 03:55:07 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[blitzdb]]></category>
		<category><![CDATA[index]]></category>

		<guid isPermaLink="false">http://torum.net/?p=2335</guid>
		<description><![CDATA[I recently gained some decent momentum on developing the indexing component of BlitzDB. Most of my time spent on BlitzDB for the last couple of weeks have been studying the indexing API and digging into how other engines have implemented it. I even referred back to MySQL 4.x to see how the BDB engine pulls [...]]]></description>
			<content:encoded><![CDATA[<p>I recently gained some decent momentum on developing the indexing component of BlitzDB. Most of my time spent on BlitzDB for the last couple of weeks have been studying the indexing API and digging into how other engines have implemented it. I even referred back to MySQL 4.x to see how the BDB engine pulls off the Indexing API.</p>
<p>The actual coding wasn&#8217;t too bad thanks to Tokyo Cabinet&#8217;s awesome B+Tree API. I&#8217;ve been busier adding new tests and fixing silly bugs as they arise. I also implemented the <a href="http://torum.net/2010/01/further-thoughts-on-blitzdb-index/">Primary Key optimization</a> that I blogged about a while back. As a result of all this, the following goodness has been added to <a href="http://bazaar.launchpad.net/~tmaesaka/blitzdb/trunk/changes">BlitzDB&#8217;s Trunk</a>.</p>
<ul>
<li>Index Lookup</li>
<li>Forward Index Scan</li>
<li>Reverse Index Scan</li>
</ul>
<p>This means that BlitzDB is now equipped with both a Table Scanner and an Index Scanner which are two essential components for a general purpose storage engine. As much as I&#8217;d like to work on optimizing the code and adding features (like recovery), I&#8217;m going to take a break and spend the rest of the month working on testing and debugging. There&#8217;s no point in adding features if the base has notable flaws in it.</p>
<h3>Challenges Encountered</h3>
<p>Writing the Index Scanner itself is easy. The most difficult thing that slowed me down was developing the comparison function for index keys. The end result was a simple piece of code but I had to study various things before I could start writing any code.</p>
<ul>
<li>How to respect collation</li>
<li>How keys are represented internally</li>
<li>How types are represented internally</li>
<li>How to write a custom comparison function for Tokyo Cabinet</li>
<li>&#8230; and so on</li>
</ul>
<p>I&#8217;ve also started using <a href="http://www.evernote.com">Evernote</a> to jot down my spontaneous ideas on optimizing BlitzDB. I&#8217;ve made these notes public and they will most likely be updated while I&#8217;m commuting on the train.</p>
<ul>
<li><a href="http://www.evernote.com/pub/tmaesaka/blitzdb">http://www.evernote.com/pub/tmaesaka/blitzdb/</a></li>
</ul>
<p>There are much more that I&#8217;d like to write about like how I intend on developing the table recovery routine without simply using <a href="http://torum.net/2010/01/how-to-recover-a-tokyo-cabinet-database-file/">TC&#8217;s recovery mechanism</a> but I shall restrain myself for another day.</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2010/02/progress-on-blitzdb-index-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notes on HEAP/MyISAM Index Key Handling on WRITE</title>
		<link>http://torum.net/2010/01/notes-on-heap-myisam-key-generation/</link>
		<comments>http://torum.net/2010/01/notes-on-heap-myisam-key-generation/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 08:57:05 +0000</pubDate>
		<dc:creator>Toru Maesaka</dc:creator>
				<category><![CDATA[drizzle]]></category>
		<category><![CDATA[knowledge]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://torum.net/?p=2331</guid>
		<description><![CDATA[Disclaimer: This post is based on HEAP/MyISAM&#8217;s sourcecode in Drizzle. Here are my brief notes on investigating how index keys are generated in HEAP and MyISAM. I lurked through these because I&#8217;ve started preparing for decent index support in BlitzDB. I also wrote this to assist my biological memory for later grepping (I have terrible [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Disclaimer: This post is based on HEAP/MyISAM&#8217;s sourcecode in Drizzle.</strong></p>
<p>Here are my brief notes on investigating how index keys are generated in HEAP and MyISAM. I lurked through these because I&#8217;ve started preparing for decent index support in BlitzDB. I also wrote this to assist my biological memory for later grepping (I have terrible memory for names). I&#8217;m only going to cover key generation on write in this post. Otherwise this post is going to be massive.</p>
<h3>HEAP Engine</h3>
<p>The index structure of HEAP can be either BTREE or HASH (in MySQL doc terms). Like other engines HEAP has a structure for keeping Key definition (parts, type, logic and etc). This structure is called HP_KEYDEF and it contains function pointers for write, delete, and getting the length of the key. These function pointers are assigned to at table creation or when the table is opened. The assigned function depends on the data structure of the index and it can be either of the following:</p>
<h4>BTREE</h4>
<ul>
<li>hp_rb_write_key()</li>
<li>hp_rb_delete_key()</li>
</ul>
<h4>HASH</h4>
<ul>
<li>hp_write_key()</li>
<li>hp_delete_key()</li>
</ul>
<p>As for get_key_length(), either of the following functions are used for both data structures.</p>
<ul>
<li>hp_rb_var_key_length()</li>
<li>hp_rb_null_key_length()</li>
<li>hp_rb_key_length()</li>
</ul>
<p>When writing a row to the tree, HEAP writes to the index using a key generated by hp_rb_make_key(). Note that it does not use this for the hash index. The generated key is populated inside &#8216;recbuffer&#8217; in HEAP&#8217;s handler object (HP_INFO structure).</p>
<p>From my understanding, it loops through the key segments (I suspect it is similar the internal  KEY_PART_INFO structure) and appropriately copies each key field value to the output buffer. By meaning &#8220;appropriately&#8221; it respects the characteristics of the data type when packing the buffer. For example, for a variable length field, it will only copy the actual data and not the max possible size of it. The final byte that is copied to the buffer is the address of the chunk where the record lives.</p>
<h3>MyISAM Engine</h3>
<p>The upper layer of key handling in MyISAM looks somewhat similar to HEAP so you can really tell that it was written by the same people. Things are nicely wrapped together by the MYISAM_SHARE structure so it&#8217;s relatively easy to follow. BlitzDB has a class called BlitzShare for the same purpose (This is based off Archive Engine&#8217;s ArchiveShare class).</p>
<p>Like HEAP, MyISAM has a structure for individual key definition called MI_KEYDEF (it&#8217;s defined in myisam.h). There are more function pointers in this structure than HEAP.</p>
<ul>
<li>bin_search()</li>
<li>get_key()</li>
<li>pack_key()</li>
<li>store_key()</li>
<li>ck_insert()</li>
<li>ck_delete()</li>
</ul>
<p>In Drizzle, _mi_ck_write() is assigned to ck_insert() which is the entry point to writing a MyISAM index. The key that MyISAM uses to write to the index is generated by _mi_make_key(). Like HEAP, it will loop through the key segments and pack the relevant fields accordingly to the characteristic of the data type. The output buffer belongs to MyISAM&#8217;s hander (lastkey2).</p>
<h3>From Here</h3>
<p>I&#8217;ve actually written a naive key generator for BlitzDB already based on Drizzle/MySQL&#8217;s internal KEY_PART_INFO array. It seems to be working on EXACT MATCH but I still need to implement an index scanner which looks much harder to pull off than a table scanner. What I&#8217;m really worried about is supporting composite indexes (namely reading/searching on it) but hopefully I&#8217;ll understand how this area of the storage system works soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://torum.net/2010/01/notes-on-heap-myisam-key-generation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

