<?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>kris.kalish.net &#187; Little Projects</title>
	<atom:link href="http://kris.kalish.net/category/littleprojects/feed/" rel="self" type="application/rss+xml" />
	<link>http://kris.kalish.net</link>
	<description>Musings in Geekery</description>
	<lastBuildDate>Wed, 09 Nov 2011 08:34:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Timing Parallel Algorithms in C++</title>
		<link>http://kris.kalish.net/2010/04/timing-parallel-algorithms-in-c/</link>
		<comments>http://kris.kalish.net/2010/04/timing-parallel-algorithms-in-c/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 03:49:33 +0000</pubDate>
		<dc:creator>kris</dc:creator>
				<category><![CDATA[Little Projects]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://kris.kalish.net/?p=220</guid>
		<description><![CDATA[It seems to be that it has become common knowledge that if you want to time something in c++, you use clock(). Typically you construct something that looks like: #include&#60;ctime&#62; #include&#60;iostream&#62; using namespace std; int main() { clock_t startTime, endTime; startTime = clock(); // Do some computationally expensive thing endTime = clock(); cout &#60;&#60; "It [...]]]></description>
			<content:encoded><![CDATA[<p>It seems to be that it has become common knowledge that if you want to time something in c++, you use clock().  Typically you construct something that looks like:</p>
<pre>
<code>
#include&lt;ctime&gt;
#include&lt;iostream&gt;

using namespace std;

int main()
{
      clock_t startTime, endTime;
      startTime = clock();
      // Do some computationally expensive thing
      endTime = clock();
      cout &lt;&lt; "It took " &lt;&lt; (endTime - startTime) / (CLOCKS_PER_SEC / 1000) &lt;&lt; "ms." &lt;&lt; endl;
}
</code>
</pre>
<p>
I&#8217;m sure most seasoned C++ developers have written something like this at one point or another.  Unfortunately, this breaks down when timing a multithreaded algorithm.  The clock() method is constructed in such a way that it always returns the amount of CPU time elapsed, not the real time elapsed.  Perhaps this is common knowledge to some, but the reference documentation on sites like cplusplus.com simply state: &#8220;Returns the number of clock ticks elapsed since the program was launched.&#8221;  This is incredibly ambiguous to me, because I could think of clock ticks as either the 2.6 billions ticks per second my CPU is receiving, or the number of ticks from the built in clock that have elapsed.
</p>
<p>
Regardless, that was tangential.  To get reasonably accurate <i>actual</i> time that has elapsed, you need to employ gettimeofday(), which populates a struct with the current time in seconds since the epoch (plus a microsecond component).
</p>
<pre>
<code>
#include&lt;sys/time.h&gt;
#include&lt;iostream&gt;

using namespace std;

int main()
{
      struct timeval startTime, endTime;
      long totalTime;

      // The second parameter is the timezone, but it's ignored in the newer linux kernels
      gettimeofday(&#038;startTime, NULL);
      // Do some computationally expensive thing
      gettimeofday(&#038;endTime, NULL);

      // We need to combine the two components of timeval into one value.
      totalTime =  (endTime.tv_sec - startTime.tv_sec) * 1000000L;
      totalTime += (endTime.tv_usec - startTime.tv_usec);

      cout &lt;&lt; "It took " &lt;&lt; (totalTime / 1000L) &lt;&lt; "ms." &lt;&lt; endl;
}
</code>
</pre>
<p>
And there you have it! I&#8217;d be interested to see if this method is any more accurate on a real time linux kernel.</p>
]]></content:encoded>
			<wfw:commentRss>http://kris.kalish.net/2010/04/timing-parallel-algorithms-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started with tinySTM (Ubuntu 9.04)</title>
		<link>http://kris.kalish.net/2009/09/getting-started-with-tinystm-ubuntu-9-04/</link>
		<comments>http://kris.kalish.net/2009/09/getting-started-with-tinystm-ubuntu-9-04/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 21:11:47 +0000</pubDate>
		<dc:creator>kris</dc:creator>
				<category><![CDATA[Little Projects]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[tinystm]]></category>

		<guid isPermaLink="false">http://kris.kalish.net/?p=115</guid>
		<description><![CDATA[This post is a quick guide to go from nothing to writing small tinySTM based applications. For those that don&#8217;t know, tinySTM is a library for writing applications that use transactional memory for synchronization in lieu of traditional locks an semaphores. So this begs two questions now. What is synchronization and what is transactional memory? [...]]]></description>
			<content:encoded><![CDATA[<p>
This post is a quick guide to go from nothing to writing small tinySTM based applications. For those that don&#8217;t know, tinySTM is a library for writing applications that use transactional memory for synchronization in lieu of traditional locks an semaphores.  So this begs two questions now. What is <i>synchronization</i> and what is <i>transactional memory</i>?
</p>
<p>
Loosely speaking, <i>synchronization</i> is a term used to refer to any method to prevent processes or threads from trampling on one another.  What do I mean trampling? There&#8217;s things like <i>memory consistency errors</i> which is a term for when threads have an inconsistent view of the same data.  For example, if two threads check the value of an integer and see different values.  This is typically caused when the integer is cached on the CPU.  One core will load a cached version of the variable and the other thread (running on a different core) will go to RAM to read the value. And so different values are seen!  Synchronization prevents problems like these.
</p>
<p>
<i>Transactional Memory</i> (TM) is a style of synchronization that was inspired heavily by databases.  In a database requests are encapsulated as transactions. Databases ensure integrity through transactions. This is accomplished by rolling-back any changes that were made in a partially completed transaction.  This means that failed transactions won&#8217;t break your database.  The same is true of memory.
</p>
<p>
With a little back story, we&#8217;re ready to start </p>
<p><code>wget http://tinystm.org/sites/tinystm.org/files/tinySTM/tinySTM-0.9.9.tgz<br />
tar -xvf tinySTM-0.9.9.tgz<br />
cd tinySTM-0.9.9<br />
sudo apt-get install libatomic-ops-dev<br />
export LIBAO_HOME=/usr/include/atomic_ops<br />
make<br />
</code></p>
<p>
Runing <code class="inline">make</code> compiles tinySTM and puts a static library file at <code class="inline">~/tinySTM-0.9.9/lib/libstm.a</code>.  Anything we write to use tinySTM will need to link to this lib file.
</p>
<p>
Let&#8217;s make sure that everything is working by compiling and running the example code that came with tinySTM.
</p>
<p><code>cd test<br />
make<br />
cd bank<br />
# To run these demos with multiple threads we use the "-n" option<br />
./bank -n 3<br />
</code></p>
<p>
If everything is working correctly you should get some pretty lengthy output that looks similar to this:
</p>
<p><code>kris@cosmos:~/tinySTM-0.9.9/test/bank$ ./bank -n 3<br />
Nb accounts    : 1024<br />
Duration       : 10000<br />
Nb threads     : 3<br />
Read-all rate  : 20<br />
Read threads   : 0<br />
Seed           : 0<br />
Write-all rate : 0<br />
Write threads  : 0<br />
Type sizes     : int=4/long=8/ptr=8/word=8<br />
Initializing STM<br />
STM flags      : -O3 -DNDEBUG -Wall -Wno-unused-function -Wno-unused-label -fno-strict-aliasing -D_REENTRANT -I/usr/include/atomic_ops/include -I./include -I./src -DTLS -DDESIGN=2 -DCM=0 -DINTERNAL_STATS -DROLLOVER_CLOCK -DCLOCK_IN_CACHE_LINE -UNO_DUPLICATES_IN_RW_SETS -UWAIT_YIELD -UUSE_BLOOM_FILTER -DEPOCH_GC -UCONFLICT_TRACKING -UREAD_LOCKED_DATA -ULOCK_IDX_SWAP -UDEBUG -UDEBUG2<br />
Creating thread 0<br />
Creating thread 1<br />
Creating thread 2<br />
STARTING...<br />
STOPPING...<br />
Thread 0<br />
  #transfer   : 1969727<br />
  #read-all   : 492137<br />
  #write-all  : 0<br />
  #aborts     : 522377<br />
    #lock-r   : 167012<br />
    #lock-w   : 387<br />
    #val-r    : 354978<br />
    #val-w    : 0<br />
    #val-c    : 0<br />
    #inv-mem  : 0<br />
    #realloc  : 0<br />
    #r-over   : 0<br />
  #lr-ok      : 0<br />
  #lr-failed  : 0<br />
  Max retries : 35784<br />
Thread 1<br />
  #transfer   : 3517300<br />
  #read-all   : 879229<br />
  #write-all  : 0<br />
  #aborts     : 986623<br />
    #lock-r   : 288231<br />
    #lock-w   : 691<br />
    #val-r    : 697695<br />
    #val-w    : 6<br />
    #val-c    : 0<br />
    #inv-mem  : 0<br />
    #realloc  : 0<br />
    #r-over   : 0<br />
  #lr-ok      : 0<br />
  #lr-failed  : 0<br />
  Max retries : 45082<br />
Thread 2<br />
  #transfer   : 1947009<br />
  #read-all   : 486864<br />
  #write-all  : 0<br />
  #aborts     : 580381<br />
    #lock-r   : 228081<br />
    #lock-w   : 328<br />
    #val-r    : 351970<br />
    #val-w    : 2<br />
    #val-c    : 0<br />
    #inv-mem  : 0<br />
    #realloc  : 0<br />
    #r-over   : 0<br />
  #lr-ok      : 0<br />
  #lr-failed  : 0<br />
  Max retries : 57503<br />
Bank total    : 0 (expected: 0)<br />
Duration      : 10000 (ms)<br />
#txs          : 9292266 (929226.600000 / s)<br />
#read txs     : 1858230 (185823.000000 / s)<br />
#write txs    : 0 (0.000000 / s)<br />
#update txs   : 7434036 (743403.600000 / s)<br />
#aborts       : 2089381 (208938.100000 / s)<br />
  #lock-r     : 683324 (68332.400000 / s)<br />
  #lock-w     : 1406 (140.600000 / s)<br />
  #val-r      : 1404643 (140464.300000 / s)<br />
  #val-w      : 8 (0.800000 / s)<br />
  #val-c      : 0 (0.000000 / s)<br />
  #inv-mem    : 0 (0.000000 / s)<br />
  #realloc    : 0 (0.000000 / s)<br />
  #r-over     : 0 (0.000000 / s)<br />
#lr-ok        : 0 (0.000000 / s)<br />
#lr-failed    : 0 (0.000000 / s)<br />
Max retries   : 57503<br />
</code></p>
<p>
It&#8217;s really no fun to run someone else&#8217;s code, so lets build something simple from the ground up. I&#8217;ll be using the Boost Thread library for threading instead of pthreads (which is what the tinySTM examples use).
</p>
<p>
I&#8217;m going to write a very contrived example, where I&#8217;ll have a Counter class and a MyRunnable class.  The Counter class will be extremely simple. In fact, it will basically just be a wrapper around an integer.  The only method of interest it will provide will be <code class="inline">increment()</code>, which will increment the integer some amount each time it is called.  The other class, MyRunnable is basically just an encapsulation of a Boost thread, you can think of it as class the implements Runnable in Java.
</p>
<p>
The program will start a bunch of threads via Boost, which results in the the <code class="inline">run()</code> method of each MyRunnable object getting executed from a different thread of execution.  The MyRunnables will try to call <code class="inline">increment()</code> on the same Counter object.  If everything is done right, each call should be accounted for in the end.
</p>
<p>
I will synchronize the <code class="inline">increment()</code> method by enclosing its body in a transaction.  That means that if another thread modifies any of the memory touched in the body of increment, the transaction will be canceled and rolled back to the original state.
</p>
<p>
Don&#8217;t forget to copy all of the tinySTM .h files (stm.h, mod_mem.h, etc) and the library file (libstm.a) into your current working directory. With all of that in mind, here&#8217;s the example:
</p>
<pre>
<code>//File: samplestm.cpp
//Author: Kristopher Kalish
#include &lt;iostream&gt;
#include &lt;boost/thread.hpp&gt;
#include &lt;atomic_ops.h&gt;
#include "stm.h"

// These following macros are from the tinySTM examples, and they truly
// are useful.
/*
 * Useful macros to work with transactions. Note that, to use nested
 * transactions, one should check the environment returned by
 * stm_get_env() and only call sigsetjmp() if it is not null.
 */
#define RO                              1
#define RW                              0
#define START(id, ro)                   { sigjmp_buf *_e = stm_get_env(); stm_tx_attr_t _a = {id, ro}; sigsetjmp(*_e, 0); stm_start(_e, &#038;_a)
#define LOAD(addr)                      stm_load((stm_word_t *)addr)
#define STORE(addr, value)              stm_store((stm_word_t *)addr, (stm_word_t)value)
#define COMMIT                          stm_commit(); }

using namespace std;

static const int INCREMENT = 5;
static const int NUM_RUNS  = 100000;

class Counter
{
public:
	Counter()
	{
		value = 0;
	}

	/**
	 * Increment the counter by five by looping. A loop was picked to
	 * make calls to increment() take more cpu time.
	 */
	void increment()
	{
		START(0, RW);

		for(int i = 0; i &lt; INCREMENT; i++)
		{
			int tmp = (int) LOAD(&#038;this-&gt;value);
			tmp = tmp + 1;

			STORE(&#038;this-&gt;value, tmp);
		}

		COMMIT;
	}

	int getValue()
	{
		return value;
	}

private:
	int value;

};

class MyRunnable
{
public:

	MyRunnable(int id, boost::barrier* bar, Counter* count)
	{
		this-&gt;id    = id;
		this-&gt;bar   = bar;
		this-&gt;count = count;
	}

	void run()
	{
		for(int i = 0; i &lt; NUM_RUNS; i++)
		{
			count-&gt;increment();
		}

		// all done, wait at the barrier
		bar-&gt;wait();
	}

	// The entry point for a thread
	void operator()()
	{
		// We must call stm_init_thread() at the beginning of each
		// thread's line of execution before using the tinySTM library
		stm_init_thread();

		run();

		// Call this at the end of each thread's execution to have
		// tinySTM clean up.
		stm_exit_thread();
	}

private:
	int             id;
	boost::barrier* bar;
	Counter*        count;

};

int main()
{
	int            numThreads = 4;
	boost::barrier my_barrier(numThreads);
	Counter        count;

	cout &lt;&lt; "Intializing tinySTM." &lt;&lt; endl;
	stm_init();

	cout &lt;&lt; "Counter is starting with value: " &lt;&lt; count.getValue() &lt;&lt; endl;
	cout &lt;&lt; "Starting " &lt;&lt; numThreads &lt;&lt; " counting threads..." &lt;&lt; endl;

	// Need to make at least one thread
	assert(numThreads &gt;= 1);

	// Make the first thread
	boost::thread thread1(MyRunnable(0, &#038;my_barrier, &#038;count));

	// Then make the remaining threads
	for(int i = 1; i &lt; numThreads; i++)
		boost::thread thread(MyRunnable(i, &#038;my_barrier, &#038;count));

	// thread1 will terminate when all threads have reached the barrier
	thread1.join(); // Wait for thread1 to terminate 

	cout &lt;&lt; "Counter is ended with value: " &lt;&lt; count.getValue() &lt;&lt; endl;
	cout &lt;&lt; "Counter should be: " &lt;&lt; NUM_RUNS * numThreads * INCREMENT &lt;&lt; endl;

	// Let tinySTM clean up after itself
	stm_exit();

	return 0;
}
</code>
</pre>
<p>
Then to compile and run, we will need to link against the tinySTM library and Boost library:
</p>
<p><code>g++ samplestm.cpp -lboost_thread-mt libstm.a -o sample<br />
./sample<br />
</code></p>
<p>
Example output:
</p>
<pre>
<code>Intializing tinySTM.
Counter is starting with value: 0
Starting 4 counting threads...
Counter is ended with value: 2000000
Counter should be: 2000000
</code>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://kris.kalish.net/2009/09/getting-started-with-tinystm-ubuntu-9-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started with Boost Threads</title>
		<link>http://kris.kalish.net/2009/09/getting-started-with-boost-threads/</link>
		<comments>http://kris.kalish.net/2009/09/getting-started-with-boost-threads/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 22:43:11 +0000</pubDate>
		<dc:creator>kris</dc:creator>
				<category><![CDATA[Little Projects]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://kris.kalish.net/?p=130</guid>
		<description><![CDATA[Boost is collection of open source C++ libraries. They are released under the &#8220;Boost License&#8221; so they can be incorporated into open-source and closed-source projects. Anyway, one of the libraries in the collection that is of particular interest to me is the threading library. It&#8217;s cross-platform, so I should be able to run my code [...]]]></description>
			<content:encoded><![CDATA[<p>
Boost is collection of open source C++ libraries. They are released under the &#8220;Boost License&#8221; so they can be incorporated into open-source and closed-source projects.  Anyway, one of the libraries in the collection that is of particular interest to me is the threading library.  It&#8217;s cross-platform, so I should be able to run my code on any platform. It also uses proper C++ templating, so it&#8217;s clean as well.
</p>
<p>
This post is targeted to readers who already have some experience writing multi-threaded applications (in Java for example).  This post tell you only what you need to go from nothing to compiling a simple Boost-based program that uses locks.
</p>
<p>
The first thing we have to do is get Boost. The threading library was last changed in version 1.36, so anything 1.36 and later will do.  You can do a manual install by following the instructions in the <a href="http://www.boost.org/doc/libs/1_39_0/more/getting_started/index.html">Getting Started Guide</a>. However, I use Ubuntu 9.04 which packages the Boost library, and I&#8217;m a huge advocate of using your distro&#8217;s package management system so I&#8217;ll be using that.
</p>
<p>
To get Boost in Ubuntu, run the following:
</p>
<p><code>sudo apt-get install libboost1.37-dev<br />
echo "That was easy!"</code></p>
<p>
So now all that&#8217;s left is make a simple, multi-threaded application.
</p>
<pre>
<code>// File: sample.cpp
#include &lt;iostream&gt;
#include &lt;boost/thread.hpp&gt;

using namespace std;

class MyRunnable
{
public:

	MyRunnable(int id, boost::mutex* mutex, boost::barrier* bar)
	{
		this-&gt;id    = id;
		this-&gt;mutex = mutex;
		this-&gt;bar   = bar;
	}

	// The entry point for a thread
	void operator()()
	{
		for(int i = 0; i &lt; 10; ++i)
		{
			boost::mutex::scoped_lock  lock(*mutex);
                       cout &lt;&lt; "id: " &lt;&lt; this-&gt;id &lt;&lt; ", " &lt;&lt; i &lt;&lt; endl;
		}

		// all done, wait at the barrier.
                // wait() returns when everyone has met at the barrier
		bar-&gt;wait();
	}

private:
	int id;
	boost::mutex* mutex;
	boost::barrier* bar;

};

int main()
{
	boost::mutex io_mutex;
        // this barrier will wait for two invocations of wait()
	boost::barrier my_barrier(2); 

	cout &lt;&lt; "Starting two counting threads..." &lt;&lt; endl;
	// the boost::mutex cannot be copied (for obvious reasons)
	// so we must pass the pointer to the mutex.
	boost::thread thread1(MyRunnable(1, &#038;io_mutex, &#038;my_barrier));
	boost::thread thread2(MyRunnable(2, &#038;io_mutex, &#038;my_barrier));

	thread1.join(); // wait for thread1 to finish

	// Note how the program doesn't return until all threads are dead
	return 0;

}
</code>
</pre>
<p>
Then compile and run!:
</p>
<p><code>g++ sample.cpp -lboost_thread-mt<br />
./a.out</code></p>
<p>
The output will of course vary a lot each time you run it, but it should look something like this:
</p>
<p><code>id: Starting two counting threads...<br />
1, 0<br />
id: 1, 1<br />
id: 1, 2<br />
id: 1, 3<br />
id: 1, 4<br />
id: 1, 5<br />
id: 1, 6<br />
id: 1, 7<br />
id: 1, 8<br />
id: 1, 9<br />
id: 2, 0<br />
id: 2, 1<br />
id: 2, 2<br />
id: 2, 3<br />
id: 2, 4<br />
id: 2, 5<br />
id: 2, 6<br />
id: 2, 7<br />
id: 2, 8<br />
id: 2, 9<br />
</code></p>
<p>
Notice how the output of the two threads we created is interleaved with the output of the main thread of execution.  This is one of the dangers of threading!</p>
]]></content:encoded>
			<wfw:commentRss>http://kris.kalish.net/2009/09/getting-started-with-boost-threads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stop Bruteforce Attacks on sshd and Get Emailed About Them</title>
		<link>http://kris.kalish.net/2009/07/stop-bruteforce-attacks-on-sshd-and-get-emailed-about-them/</link>
		<comments>http://kris.kalish.net/2009/07/stop-bruteforce-attacks-on-sshd-and-get-emailed-about-them/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 19:15:13 +0000</pubDate>
		<dc:creator>kris</dc:creator>
				<category><![CDATA[Little Projects]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://kris.kalish.net/?p=107</guid>
		<description><![CDATA[So now that I have a server on a static IP address, I decided it was time to lockdown sshd a little. I thought there was a simple option I could change in /etc/ssh/sshd_config to block repeated attempts. A few minutes of googling turned up nothing though. I did stumble upon a nifty application called [...]]]></description>
			<content:encoded><![CDATA[<p>
So now that I have a server on a static IP address, I decided it was time to lockdown sshd a little.  I thought there was a simple option I could change in <i>/etc/ssh/sshd_config</i> to block repeated attempts. A few minutes of googling turned up nothing though. I did stumble upon a nifty application called DenyHosts. It basically watches your log files for repeated and failed attempts to login via ssh, and then after reaching a threshold, adds that IP to the hosts.deny file. Banning the user from any interaction with your server.
</p>
<p>
The whole things is pretty customizable. For instance, you can even set it up to email you about banned users or suspicious logins! Here&#8217;s a quickstart guide for Ubuntu:
</p>
<p>
We will use postfix, a very slim SMTP server to send mail.<br />
<code>sudo apt-get install deny-hosts<br />
sudo apt-get install postfix</code>
</p>
<p>
Now some configuration:<br />
<code>sudo vi /etc/denyhosts.conf<br />
# Change the line "ADMIN_EMAIL = root@localhost" to<br />
# ADMIN_EMAIL = your@emailaddres<br />
sudo /etc/init.d/denyhosts restart</code>
</p>
<p>
And now you&#8217;re done! It&#8217;s ridiculously easy to get going, it&#8217;s tweaking it to your liking that takes time.  The default settings are pretty harsh, so you may want to lax them a bit. For instance, it considers 10 bad logins for an existant over the course of 5 days to be a ban-worthy offense and bans are never forgotten. The configuration file, <i>/etc/denyhosts.config</i>, is well documented so it&#8217;s a good place to start.</p>
]]></content:encoded>
			<wfw:commentRss>http://kris.kalish.net/2009/07/stop-bruteforce-attacks-on-sshd-and-get-emailed-about-them/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hard Drive Benchmarking</title>
		<link>http://kris.kalish.net/2009/05/hard-drive-benchmarking/</link>
		<comments>http://kris.kalish.net/2009/05/hard-drive-benchmarking/#comments</comments>
		<pubDate>Sat, 23 May 2009 18:13:14 +0000</pubDate>
		<dc:creator>kris</dc:creator>
				<category><![CDATA[Little Projects]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[hdd]]></category>

		<guid isPermaLink="false">http://colossal.ath.cx/?p=65</guid>
		<description><![CDATA[I was looking for a quick and dirty way to benchmark hard drives this morning and I stumbled upon iozone. It was way sweeter and more elaborate than I could have ever dreamed! Here&#8217;s a quick and dirty jump-start guide for Ubuntu 9.04: cd ~ sudo apt-get install gnuplot iozone3 cp -R /usr/share/doc/iozone3/examples ./iozone cd [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a quick and dirty way to benchmark hard drives this morning and I stumbled upon <a href="http://www.iozone.org" target="_blank">iozone</a>.  It was way sweeter and more elaborate than I could have ever dreamed!</p>
<p>Here&#8217;s a quick and dirty jump-start guide for Ubuntu 9.04:<br />
<code>cd ~<br />
sudo apt-get install gnuplot iozone3<br />
cp -R /usr/share/doc/iozone3/examples ./iozone<br />
cd iozone<br />
uncompress gnu3d.dem<br />
# The following command runs the benchmark and will take a while to complete<br />
iozone -a &gt; mybenchmark.txt<br />
chmod u+x Generate_Graphs<br />
./Generate_Graphs mybenchmark.txt<br />
</code></p>
<p>
This will start gnuplot and display a graph that can be rotated. Closing it will open the next one in the sequence.  The script also generates a bunch of postscript versions of the graphs.
</p>
<p>
To get a bunch of png images make a script called <i>topng.sh</i>.
</p>
<p>File <i>topng.sh</i>:<br />
<code>#!/bin/bash<br />
newFileName=`basename $1`<br />
newFileName=`echo $newFileName | sed s/.ps/.png/`<br/><br />
echo $newFileName<br />
ps2png $1 ./pngs/$newFileName<br />
</code></p>
<p>Then execute:<br />
<code>find -name "*.png" -exec ./topng.sh {} ;<br />
</code></p>
<p>Here are the resulting benchmarks:</p>

<div class="ngg-albumoverview">	
	<!-- List of galleries -->
	
	<div class="ngg-album">
		<div class="ngg-albumtitle"><a href="http://kris.kalish.net/2009/05/hard-drive-benchmarking/?album=1&amp;gallery=2">Samsung 250GB Benchmark</a></div>
			<div class="ngg-albumcontent">
				<div class="ngg-thumbnail">
					<a href="http://kris.kalish.net/2009/05/hard-drive-benchmarking/?album=1&amp;gallery=2"><img class="Thumb" alt="Samsung 250GB Benchmark" src="http://kris.kalish.net/wp-content/gallery/miniboxbench/thumbs/thumbs_write.png"/></a>
				</div>
				<div class="ngg-description">
				<p>Graphs generated by gnuplot and IOZone.</p>
								<p><strong>13</strong> Photos</p>
							</div>
		</div>
	</div>

 	
	<div class="ngg-album">
		<div class="ngg-albumtitle"><a href="http://kris.kalish.net/2009/05/hard-drive-benchmarking/?album=1&amp;gallery=3">Seagate 7200.12 1TB Benchmark</a></div>
			<div class="ngg-albumcontent">
				<div class="ngg-thumbnail">
					<a href="http://kris.kalish.net/2009/05/hard-drive-benchmarking/?album=1&amp;gallery=3"><img class="Thumb" alt="Seagate 7200.12 1TB Benchmark" src="http://kris.kalish.net/wp-content/gallery/duobench/thumbs/thumbs_write.png"/></a>
				</div>
				<div class="ngg-description">
				<p></p>
								<p><strong>13</strong> Photos</p>
							</div>
		</div>
	</div>

 	 	
	<!-- Pagination -->
 	<div class="ngg-clear"></div> 	
</div>


<p>If you&#8217;re looking for a little more thorough description of IOZone and what the benchmarks really mean, someone else has already <a href="http://www.linux.com/archive/feature/139744" target="_blank">written it</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kris.kalish.net/2009/05/hard-drive-benchmarking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My Blog&#8217;s New Home</title>
		<link>http://kris.kalish.net/2009/05/microatx-server/</link>
		<comments>http://kris.kalish.net/2009/05/microatx-server/#comments</comments>
		<pubDate>Fri, 22 May 2009 05:24:18 +0000</pubDate>
		<dc:creator>kris</dc:creator>
				<category><![CDATA[Little Projects]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[microatx]]></category>

		<guid isPermaLink="false">http://192.168.1.11/~kris/wordpress/?p=3</guid>
		<description><![CDATA[The Hardware I just built a MicroATX system for my blog, and other projects, to live on. The specs: Kingston 4GB (2 x 2GB) 240-Pin DDR2 SDRAM DDR2 800 Intel Pentium E5200 Wolfdale 2.5GHz 2MB L2 Cache Gigabyte GA-G31M-ES2L LGA 775 Intel G31 Micro ATX Intel Motherboard Apevia X-QPACK-NW-BK/420 Black Case Random Samsung 250GB Hard [...]]]></description>
			<content:encoded><![CDATA[<h2>The Hardware</h2>
<p>I just built a MicroATX system for my blog, and other projects, to live on.</p>
<p>The specs:</p>
<ul>
<li>Kingston 4GB (2 x 2GB) 240-Pin DDR2 SDRAM DDR2 800</li>
<li>Intel Pentium E5200 Wolfdale 2.5GHz 2MB L2 Cache</li>
<li>Gigabyte GA-G31M-ES2L LGA 775 Intel G31 Micro ATX Intel Motherboard</li>
<li>Apevia X-QPACK-NW-BK/420 Black Case</li>
<li>Random Samsung 250GB Hard Drive</li>
</ul>
<p>Here are a couple of shots from the <a href="?page_id=38">full gallery</a>:</p>
<div>
<a href="http://kris.kalish.net/wp-content/gallery/microatxserver/IMG_1162.JPG" title="This is the MicroATX motherboard. It was very cheap (around $50)." class="shutterset_singlepic10" >
	<img class="ngg-singlepic ngg-left" src="http://kris.kalish.net/wp-content/gallery/cache/10__100x_IMG_1162.JPG" alt="Gigabyte Motherboard" title="Gigabyte Motherboard" />
</a>
</p>

<a href="http://kris.kalish.net/wp-content/gallery/microatxserver/IMG_1165.jpg" title="Stock Intel cooler installed and the 4GB of RAM" class="shutterset_singlepic12" >
	<img class="ngg-singlepic ngg-left" src="http://kris.kalish.net/wp-content/gallery/cache/12__100x_IMG_1165.jpg" alt="CPU Cooler/RAM Installed" title="CPU Cooler/RAM Installed" />
</a>
</div>
<div style="clear: both;">&nbsp;</div>
<h2>The Software</h2>
<p>I&#8217;ve traditionally always had some kind of built-from-scratch blog growing up, but lately I&#8217;ve been experimenting with various blogs.  At first I was restricted to blog software written in ASP.net because my hosting was on a Windows machine, but now my blog has moved to <em>my</em> machine!  On Windows, I was using <a href="http://www.subtextproject.com/" target="_blank">Subtext</a>. It wasn&#8217;t bad, and it got the job done. There were a fair amount of themes available, which was important because I didn&#8217;t want to invest myself in a particular project by writing my own theme.  It was pretty unpolished though, primarily the Admin interface.  It seemed to have gaps of missing features (and it was homely).</p>
<p>With the luxury of running my own server, it was logical to try <a href="http://www.wordpress.org" target="_blank">WordPress</a>.  It&#8217;s better in every dimension.  There&#8217;s a massive userbase which means several things: it can be coaxed to do anything, millions of plugins, lots of support, and it&#8217;s easy to google solutions to any problem you run into.</p>
<p>With WordPress up and running, my first priority was to find a good theme and photo gallery.  The theme was easy to find, but finding a good photo gallery was a journey.  For the photo gallery I tried the following plugins: photoJAR, Lightbox 2, WPG2, and <a href="http://wordpress.org/extend/plugins/nextgen-gallery/" target="_blank">NextGEN</a>.  They were all impossible or unreasonably difficult to customize the way I wanted except for <a href="http://wordpress.org/extend/plugins/nextgen-gallery/" target="_blank">NextGEN</a>. For tweaking I recommend looking at the <a href="http://nextgen.boelinger.com/" target="_blank">NextGEN Gallery</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kris.kalish.net/2009/05/microatx-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

