kissdb golang 绑定 » 荒野无灯weblog

Keep It Simple, Stupid.


kissdb golang 绑定

this is a golang binding for kissdb C api. repo :

KISSDB 是一个最简单的 key/value 存储,使用纯 C 开发, gti repo url为:

我给它写了个go语言绑定: go doc:

benchmark (Intel(R) Core(TM) i7-8700K CPU @ 4.50GHz, 6 core 12 thread):

goos: linux
goarch: amd64
BenchmarkOpen100-12           100000         21585 ns/op
BenchmarkOpen1000-12           50000         29218 ns/op
BenchmarkGet-12              1000000          1299 ns/op
BenchmarkSet-12               300000         16986 ns/op
BenchmarkSave100-12            30000         47847 ns/op
BenchmarkSave10000-12          30000         47690 ns/op
ok  14.630s

(Keep It) Simple Stupid Database

KISSDB is about the simplest key/value store you'll ever see, anywhere. It's written in plain vanilla C using only the standard string and FILE I/O functions, and should port to just about anything with a disk or something that acts like one.

It stores keys and values of fixed length in a stupid-simple file format based on fixed-size hash tables. If a hash collision occurrs, a new "page" of hash table is appended to the database. The format is append-only. There is no delete. Puts that replace an existing value, however, will not grow the file as they will overwrite the existing entry.

Hash table size is a space/speed trade-off parameter. Larger hash tables will reduce collisions and speed things up a bit, at the expense of memory and disk space. A good size is usually about 1/2 the average number of entries you expect.


Tiny, compiles to ~4k on an x86_64 Linux system Small memory footprint (only caches hash tables) Very space-efficient (on disk) if small hash tables are used Makes a decent effort to be robust on power loss Pretty respectably fast, especially given its simplicity 64-bit, file size limit is 2^64 bytes Ports to anything with a C compiler and stdlib/stdio Public domain Limitations:

Fixed-size keys and values, must recreate and copy to change any init size parameter Add/update only, no delete Iteration is supported but key order is undefined No search for subsets of keys/values No indexes No transactions No special recovery features if a database gets corrupted No built-in thread-safety (guard it with a mutex in MT code) No built-in caching of data (only hash tables are cached for lookup speed) No endian-awareness (currently), so big-endian DBs won't read on little-endian machines

Tagged in :

All Comments (8)
Gravatar image
Gravatar image
善良的朋友: 法 轮 功是佛 家上乘修 炼大 法,修者是按真、善、忍的标准,做一善良的好人。但是江 泽 民之流出于嫉恨,为了迫害法 轮 功,导演了被国际上评为十大假新闻的“天 安 门 自 焚”案。一些学员被虐杀,更多的学员被抄家、劳教和判刑。法 轮 功修炼者甚至被作为活体器官库,由此制造了这个星球从未有过的罪恶——活 摘 器官的罪行。这是赤裸裸的酷刑罪、屠杀罪、反人类罪。
Gravatar image
白岩松:中国与世界脱节最大的是普世价值,中国与世界其他国家没有共同的价值观,所以得不到朋友。 李连杰:有权有势的中国人移民,无权无势的中国人偷渡,这是一个国家还是监狱?——国家有这样的吗?当然是监狱,要不然,为什么人们不管有钱无钱,总想逃离这个国家——你听说过美国人偷渡的吗?! 孟德斯鸠:在专制的国家里,人的命运和畜牲一样,就是本能、服从和惩罚。
Gravatar image
声明~~~ 当今社会被共 产 党专制搞的极其恶劣,权钱交易、权色交易盛行。老百姓说当今的恶党官员个个贪,大官大贪,小官小贪,无官不贪,可见我们老百姓能生活的怎么样了。这种现象也不能长久,人不治天治,所以我们现在声明退出它的一切组织(团、队),成为一个真正的中华民族的子孙。 ~~江明、晓娟~~