Install Kyoto Cabinet
# http://torum.net/2010/01/kyotocabinet-alpha-release/ ulimit -u unlimited #zlib compression sudo apt-get install -y zlib1g-dev build-essential #lzma compression sudo apt-get install -y lzma liblzma-dev #lzo compression sudo apt-get install -y liblzo2-dev sudo apt-get remove -y libtokyocabinet-dbg libtokyocabinet-dev tokyocabinet-bin libtokyocabinet9 sudo apt-get install -y xz-utils #lua sudo apt-get remove -y lua5.2 liblua5.2-0 liblua5.2-0-dbg liblua5.2-dev sudo apt-get remove -y lua50 liblua50 liblua50-dbg liblua50-dev sudo apt-get install -y lua5.1 liblua5.1 liblua5.1-dev sudo apt-get install -y zlib1g zlib1g-dev sudo apt-get autoremove -y # kyoto cabinet build mkdir -p ~/build/kyoto cd ~/build/kyoto version="1.2.76" # download wget http://fallabs.com/kyotocabinet/pkg/kyotocabinet-$version.tar.gz # extract tar xvzf kyotocabinet-$version.tar.gz # build and install cd kyotocabinet-$version ./configure --enable-zlib --enable-lzo --enable-lzma make sudo make install #--Add /usr/local/lib path ---------------------- # make installs the library copies to /usr/local/lib # add /usr/local/lib into the /etc/ld.so.conf file # Also fixes this error # Error: libkyotocabinet.so.16: cannot open shared object file: No such file or directory # More sane default configurations - the default 50% free memory allocation is too much for me if [ "`sudo grep '/usr/local/lib' /etc/ld.so.conf`" == "" ] ; then sudo tee -a /etc/ld.so.conf <<"_EOF_" /usr/local/lib _EOF_ #sudo ldconfig -v sudo ldconfig
Install Python 2 Bindings for Kyoto Cabinet
mkdir -p ~/build/kyoto/ cd ~/build/kyoto/ wget http://fallabs.com/kyotocabinet/pythonlegacypkg/kyotocabinet-python-legacy-1.18.tar.gz tar xvfz kyotocabinet-python-legacy-1.18.tar.gz cd kyotocabinet-python-* sudo python setup.py install
Test Kyoto Cabinet
python -c 'import kyotocabinet'
Performance Test
mkdir -p ~/build/kyoto/test cd ~/build/kyoto/test tee ./kyoto_cabinet_test.py <<"_EOF_" from kyotocabinet import * import sys def main(): import sys #print "argurment count",len(sys.argv) if len(sys.argv) < 4: print """enter operation and how many. example: time python kyoto_cabinet_test.py# write 1 million values to testdb time python kyoto_cabinet_test.py test.db write 1000000 # read 1 million values to testdb time python kyoto_cabinet_test.py test.db read 1000000 """ return filename,ops,max = sys.argv[1],sys.argv[2],int(sys.argv[3]) db = DB() db.open(filename+".kch", DB.OWRITER | DB.OCREATE) if 'write' in ops: mystring='a'*80 for i in range(0,max): db.set('key'+str(i), str(i)+mystring) elif 'read' in ops: for i in range(0,max): db.get('key'+str(i)) else: print 'unkown operation:%s use "read" or "write"'%ops print 'done' if __name__ == "__main__": main() _EOF_
Execute Tests
# 1 million write time python kyoto_cabinet_test.py testdb write 1000000 #done # #real 0m2.433s #user 0m1.686s #sys 0m0.746s a@a:~/build/kyoto/test$ time python kyoto_cabinet_test.py testdb read 1000000 #done # #real 0m1.901s #user 0m1.480s #sys 0m0.420s # 100 million write time python kyoto_cabinet_test.py bigtestdb write 100000000 #KeyboardInterrupt # #real 30m27.003s #user 5m56.869s #sys 8m3.308s # i just gave up after 13 mins # 100 million read time python kyoto_cabinet_test.py bigtestdb read 100000000 # not yet done
Limitations
Only one writer process is permitted at a time.
The number of database readers is however unlimited.
Notes
Comparison with LuxIO: http://luxio.sourceforge.net/
Comparison with Google LevelDB: http://maxpert.tumblr.com/post/8330476086/leveldb-vs-kyoto-cabinet-my-findings
LevelDB with Kyoto Tycoon: http://fallabs.com/blog/promenade.cgi?id=30
References
1. http://d.hatena.ne.jp/nashuaki/20110721/1311240883
2. http://skipperkongen.dk/2013/02/14/giving-kyotocabinet-a-go/
3. http://fallabs.com/kyotocabinet/pythonlegacydoc/
4.