Home

Awesome

Whippet-db

Fast embedded key-value database engine for Java with a Map interface.

Maven Central Javadoc

Overview

Whippet-db is a fast embedded local key-value store for Java, either in-memory or persistent - at your choice. The library is extremally low-footprint - less then 150 kb, with no dependencies, and is very simple to use. It is written in pure classic Java 1.8 with no use of Unsafe or native methods, so there are no problems with transition to newer Java versions.

Applications

Features

What Whippet DB is not

Setup

Add latest Maven dependency: Maven Central

or download the latest whippet-db-x.x.x jar

Documentation

Brief tutorial with examples

Demo project

The latest javadoc: Javadoc

Performance

The important feature of Whipet, which may seem both as a problem and as a benefit, is that its performance is very sensitive to the randomness of the keys. In more exact terms, it's sensitive to inter- and intra-correlation of bits in the keys. The more correlated are the keys, the better is performance, both in the terms of used space and speed. So Whippet shines when the keys are sequential numbers, and is modest when the keys are strongly random, the difference reaching 5-6 times in speed and 1.5-1.7 times in used space.

The following pictures compare the typical insertion speed and used space of 3 implementations of java.util.Map<Long,Long> - the Whippet DB, the Cronicle Map, and the java.util.HashMap. The implementations were run against the three sets of 50M keys - serial, moderately random and strongly random. The HashMap was unable to insert more then 30-40M keys, it gets stuck in garbage collection.

Keys type# of inserted keys vs timeInsertion speed vs timeUsed space vs # of inserted keys
Sequentialimageimageimage
Moderately randomimageimageimage
Strongly randomimageimageimage

The table below shows the typical figures for a workload consisting of 50M fresh inserts, followed by 50M reads, then 50M deletes, then 50M secondary inserts, against the three key sets described above. Both keys and values are 8-byte Longs. For comparison there are also figures for Cronicle Map.

Keys typeInserts, op/secReads, op/secDeletes, op/secInserts, op/secAverage, op/sec
Whippet, sequential keys5,921,364 (38 bytes/key)9,626,4929,044,8627,257,947 (38 bytes/key)7,676,069
Whippet, moderately random keys2,526,528 (42 bytes/key)3,243,3833,118,3732,169,009 (42 bytes/key)2,692,079
Whippet, strongly random keys1,768,581 (52 bytes/key)2,182,0962,204,7071,633,853 (52 bytes/key)1,914,493
Chronicle, sequential keys2,606,610 (27 bytes/key)4,689,5512,506,3912,713,998 (27 bytes/key)2,931,863
Chronicle, moderately random keys2,487,562 (27 bytes/key)4,405,6742,485,8302,597,267 (27 bytes/key)2,824,300
Chronicle, strongly random keys2,469,867 (27 bytes/key)4,368,3382,451,3402,583,445 (27 bytes/key)2,799,512