LevelDB dbbench 參數(shù)設(shè)置 和 使用

// Comma-separated list of operations to run in the specified order

//? Actual benchmarks:

//? ? ? fillseq? ? ? -- write N values in sequential key order in async mode? 順序?qū)?/p>

//? ? ? fillrandom? ? -- write N values in random key order in async mode? 隨機(jī)寫

//? ? ? overwrite? ? -- overwrite N values in random key order in async mode

//? ? ? fillsync? ? ? -- write N/100 values in random key order in sync mode

//? ? ? fill100K? ? ? -- write N/1000 100K values in random order in async mode

//? ? ? deleteseq? ? -- delete N keys in sequential order

//? ? ? deleterandom? -- delete N keys in random order

//? ? ? readseq? ? ? -- read N times sequentially

//? ? ? readreverse? -- read N times in reverse order

//? readrandom? ? -- read N times in random order

//? ? ? readmissing? -- read N missing keys in random order

//? ? ? readhot? ? ? -- read N times in random order from 1% section of DB

//? ? ? seekrandom? ? -- N random seeks

//? ? ? open? ? ? ? ? -- cost of opening a DB

//? ? ? crc32c? ? ? ? -- repeated crc32c of 4K of data

//? ? ? acquireload? -- load N*1000 times

//? Meta operations:

//? ? ? compact? ? -- Compact the entire DB

//? ? ? stats? ? ? -- Print DB stats

//? ? ? sstables? ? -- Print sstable info

//? ? ? heapprofile -- Dump a heap profile (if supported by this port)

使用方法

說(shuō)明選自 https://github.com/facebook/rocksdb/wiki/Benchmarking-tools

./db_bench --benchmarks="fillseq"

./db_bench --benchmarks="fillseq,stats" --statistics

./db_bench --benchmarks="readrandom" --use_existing_db

./db_bench --benchmarks="fillseq,readrandom,readseq"

RocksDB Benchmarks List:

readwhilewriting? ? ? -- 1 writer, N threads doing random reads

? ? ? readwhilemerging? ? ? -- 1 merger, N threads doing random reads

? ? ? readrandomwriterandom -- N threads doing random-read, random-write

cache_bench

./cache_bench --help

cache_bench: Warning: SetUsageMessage() never called

...

? Flags from cache/cache_bench.cc:

? ? -cache_size (Number of bytes to use as a cache of uncompressed data.)

? ? ? type: int64 default: 8388608

? ? -erase_percent (Ratio of erase to total workload (expressed as a

? ? ? percentage)) type: int32 default: 10

? ? -insert_percent (Ratio of insert to total workload (expressed as a

? ? ? percentage)) type: int32 default: 40

? ? -lookup_percent (Ratio of lookup to total workload (expressed as a

? ? ? percentage)) type: int32 default: 50

? ? -max_key (Max number of key to place in cache) type: int64

? ? ? default: 1073741824

? ? -num_shard_bits (shard_bits.) type: int32 default: 4

? ? -ops_per_thread (Number of operations per thread.) type: uint64

? ? ? default: 1200000

? ? -populate_cache (Populate cache before operations) type: bool

? ? ? default: false

? ? -threads (Number of concurrent threads to run.) type: int32 default: 16

? ? -use_clock_cache () type: bool default: false

LevelDB Benchmarks 官方測(cè)試結(jié)果

原文:http://www.lmdb.tech/bench/microbench/benchmark.html

Google, July 2011

In order to test LevelDB's performance, we benchmark it against other well-established database implementations. We compare LevelDB (revision 39) against?SQLite3?(version 3.7.6.3) and?Kyoto Cabinet's?(version 1.2.67) TreeDB (a B+Tree based key-value store). We would like to acknowledge Scott Hess and Mikio Hirabayashi for their suggestions and contributions to the SQLite3 and Kyoto Cabinet benchmarks, respectively.

Benchmarks were all performed on a six-core Intel(R) Xeon(R) CPU X5650 @ 2.67GHz, with 12288 KB of total L3 cache and 12 GB of DDR3 RAM at 1333 MHz. (Note that LevelDB uses at most two CPUs since the benchmarks are single threaded: one to run the benchmark, and one for background compactions.) We ran the benchmarks on two machines (with identical processors), one with an Ext3 file system and one with an Ext4 file system. The machine with the Ext3 file system has a SATA Hitachi HDS721050CLA362 hard drive. The machine with the Ext4 file system has a SATA Samsung HD502HJ hard drive. Both hard drives spin at 7200 RPM and have hard drive write-caching enabled (using `hdparm -W 1 [device]`). The numbers reported below are the median of three measurements.

Benchmark Source Code

We wrote benchmark tools for SQLite and Kyoto TreeDB based on LevelDB's?db_bench. The code for each of the benchmarks resides here:

LevelDB:?db/db_bench.cc.

SQLite:?doc/bench/db_bench_sqlite3.cc.

Kyoto TreeDB:?doc/bench/db_bench_tree_db.cc.

Custom Build Specifications

LevelDB: LevelDB was compiled with the?tcmalloc?library and the?Snappy?compression library (revision 33). Assertions were disabled.

TreeDB: TreeDB was compiled using the?LZO?compression library (version 2.03). Furthermore, we enabled the TSMALL and TLINEAR options when opening the database in order to reduce the footprint of each record.

SQLite: We tuned SQLite's performance, by setting its locking mode to exclusive. We also enabled SQLite's?write-ahead logging.

1. Baseline Performance

This section gives the baseline performance of all the databases. Following sections show how performance changes as various parameters are varied. For the baseline:

Each database is allowed 4 MB of cache memory.

Databases are opened in?asynchronous?write mode. (LevelDB's sync option, TreeDB's OAUTOSYNC option, and SQLite3's synchronous options are all turned off). I.e., every write is pushed to the operating system, but the benchmark does not wait for the write to reach the disk.

Keys are 16 bytes each.

Value are 100 bytes each (with enough redundancy so that a simple compressor shrinks them to 50% of their original size).

Sequential reads/writes traverse the key space in increasing order.

Random reads/writes traverse the key space in random order.

A. Sequential Reads

LevelDB4,030,000 ops/sec?

Kyoto TreeDB1,010,000 ops/sec?

SQLite3383,000 ops/sec?

B. Random Reads

LevelDB129,000 ops/sec?

Kyoto TreeDB151,000 ops/sec?

SQLite3134,000 ops/sec?

C. Sequential Writes

LevelDB779,000 ops/sec?

Kyoto TreeDB342,000 ops/sec?

SQLite348,600 ops/sec?

D. Random Writes

LevelDB164,000 ops/sec?

Kyoto TreeDB88,500 ops/sec?

SQLite39,860 ops/sec?

LevelDB outperforms both SQLite3 and TreeDB in sequential and random write operations and sequential read operations. Kyoto Cabinet has the fastest random read operations.

2. Write Performance under Different Configurations

A. Large Values

For this benchmark, we start with an empty database, and write 100,000 byte values (~50% compressible). To keep the benchmark running time reasonable, we stop after writing 1000 values.

Sequential Writes

LevelDB1,100 ops/sec?

Kyoto TreeDB1,000 ops/sec?

SQLite31,600 ops/sec?

Random Writes

LevelDB480 ops/sec?

Kyoto TreeDB1,100 ops/sec?

SQLite31,600 ops/sec?

LevelDB doesn't perform as well with large values of 100,000 bytes each. This is because LevelDB writes keys and values at least twice: first time to the transaction log, and second time (during a compaction) to a sorted file. With larger values, LevelDB's per-operation efficiency is swamped by the cost of extra copies of large values.

B. Batch Writes

A batch write is a set of writes that are applied atomically to the underlying database. A single batch of N writes may be significantly faster than N individual writes. The following benchmark writes one thousand batches where each batch contains one thousand 100-byte values. TreeDB does not support batch writes and is omitted from this benchmark.

Sequential Writes

LevelDB840,000 entries/sec?(1.08x baseline)

SQLite3124,000 entries/sec?(2.55x baseline)

Random Writes

LevelDB221,000 entries/sec?(1.35x baseline)

SQLite322,000 entries/sec?(2.23x baseline)

Because of the way LevelDB persistent storage is organized, batches of random writes are not much slower (only a factor of 4x) than batches of sequential writes.

C. Synchronous Writes

In the following benchmark, we enable the synchronous writing modes of all of the databases. Since this change significantly slows down the benchmark, we stop after 10,000 writes. For synchronous write tests, we've disabled hard drive write-caching (using `hdparm -W 0 [device]`).

For LevelDB, we set WriteOptions.sync = true.

In TreeDB, we enabled TreeDB's OAUTOSYNC option.

For SQLite3, we set "PRAGMA synchronous = FULL".

Sequential Writes

LevelDB100 ops/sec?(0.003x baseline)

Kyoto TreeDB7 ops/sec?(0.0004x baseline)

SQLite388 ops/sec?(0.002x baseline)

Random Writes

LevelDB100 ops/sec?(0.015x baseline)

Kyoto TreeDB8 ops/sec?(0.001x baseline)

SQLite388 ops/sec?(0.009x baseline)

Also see the?ext4?performance numbers below since synchronous writes behave significantly differently on?ext3?and?ext4.

D. Turning Compression Off

In the baseline measurements, LevelDB and TreeDB were using light-weight compression (Snappy?for LevelDB, and?LZO?for TreeDB). SQLite3, by default does not use compression. The experiments below show what happens when compression is disabled in all of the databases (the SQLite3 numbers are just a copy of its baseline measurements):

Sequential Writes

LevelDB594,000 ops/sec?(0.76x baseline)

Kyoto TreeDB485,000 ops/sec?(1.42x baseline)

SQLite348,600 ops/sec?(1.00x baseline)

Random Writes

LevelDB135,000 ops/sec?(0.82x baseline)

Kyoto TreeDB159,000 ops/sec?(1.80x baseline)

SQLite39,860 ops/sec?(1.00x baseline)

LevelDB's write performance is better with compression than without since compression decreases the amount of data that has to be written to disk. Therefore LevelDB users can leave compression enabled in most scenarios without having worry about a tradeoff between space usage and performance. TreeDB's performance on the other hand is better without compression than with compression. Presumably this is because TreeDB's compression library (LZO) is more expensive than LevelDB's compression library (Snappy).

E. Using More Memory

We increased the overall cache size for each database to 128 MB. For LevelDB, we partitioned 128 MB into a 120 MB write buffer and 8 MB of cache (up from 2 MB of write buffer and 2 MB of cache). For SQLite3, we kept the page size at 1024 bytes, but increased the number of pages to 131,072 (up from 4096). For TreeDB, we also kept the page size at 1024 bytes, but increased the cache size to 128 MB (up from 4 MB).

Sequential Writes

LevelDB812,000 ops/sec?(1.04x baseline)

Kyoto TreeDB321,000 ops/sec?(0.94x baseline)

SQLite348,500 ops/sec?(1.00x baseline)

Random Writes

LevelDB355,000 ops/sec?(2.16x baseline)

Kyoto TreeDB284,000 ops/sec?(3.21x baseline)

SQLite39,670 ops/sec?(0.98x baseline)

SQLite's performance does not change substantially when compared to the baseline, but the random write performance for both LevelDB and TreeDB increases significantly. LevelDB's performance improves because a larger write buffer reduces the need to merge sorted files (since it creates a smaller number of larger sorted files). TreeDB's performance goes up because the entire database is available in memory for fast in-place updates.

3. Read Performance under Different Configurations

A. Larger Caches

We increased the overall memory usage to 128 MB for each database. For LevelDB, we allocated 8 MB to LevelDB's write buffer and 120 MB to LevelDB's cache. The other databases don't differentiate between a write buffer and a cache, so we simply set their cache size to 128 MB.

Sequential Reads

LevelDB5,210,000 ops/sec?(1.29x baseline)

Kyoto TreeDB1,070,000 ops/sec?(1.06x baseline)

SQLite3609,000 ops/sec?(1.59x baseline)

Random Reads

LevelDB190,000 ops/sec?(1.47x baseline)

Kyoto TreeDB463,000 ops/sec?(3.07x baseline)

SQLite3186,000 ops/sec?(1.39x baseline)

As expected, the read performance of all of the databases increases when the caches are enlarged. In particular, TreeDB seems to make very effective use of a cache that is large enough to hold the entire database.

B. No Compression Reads

For this benchmark, we populated a database with 1 million entries consisting of 16 byte keys and 100 byte values. We compiled LevelDB and Kyoto Cabinet without compression support, so results that are read out from the database are already uncompressed. We've listed the SQLite3 baseline read performance as a point of comparison.

Sequential Reads

LevelDB4,880,000 ops/sec?(1.21x baseline)

Kyoto TreeDB1,230,000 ops/sec?(3.60x baseline)

SQLite3383,000 ops/sec?(1.00x baseline)

Random Reads

LevelDB149,000 ops/sec?(1.16x baseline)

Kyoto TreeDB175,000 ops/sec?(1.16x baseline)

SQLite3134,000 ops/sec?(1.00x baseline)

Performance of both LevelDB and TreeDB improves a small amount when compression is disabled. Note however that under different workloads, performance may very well be better with compression if it allows more of the working set to fit in memory.

Note about Ext4 Filesystems

The preceding numbers are for an ext3 file system. Synchronous writes are much slower under?ext4?(LevelDB drops to ~31 writes / second and TreeDB drops to ~5 writes / second; SQLite3's synchronous writes do not noticeably drop) due to ext4's different handling of?fsync?/?msync?calls. Even LevelDB's asynchronous write performance drops somewhat since it spreads its storage across multiple files and issues?fsync?calls when switching to a new file.

Acknowledgements

Jeff Dean and Sanjay Ghemawat wrote LevelDB. Kevin Tseng wrote and compiled these benchmarks. Mikio Hirabayashi, Scott Hess, and Gabor Cselle provided help and advice.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市荣暮,隨后出現(xiàn)的幾起案子与学,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 210,978評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件驹尼,死亡現(xiàn)場(chǎng)離奇詭異衡未,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)婚夫,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 89,954評(píng)論 2 384
  • 文/潘曉璐 我一進(jìn)店門浸卦,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人案糙,你說(shuō)我怎么就攤上這事限嫌。” “怎么了时捌?”我有些...
    開(kāi)封第一講書人閱讀 156,623評(píng)論 0 345
  • 文/不壞的土叔 我叫張陵怒医,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我奢讨,道長(zhǎng)稚叹,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書人閱讀 56,324評(píng)論 1 282
  • 正文 為了忘掉前任,我火速辦了婚禮扒袖,結(jié)果婚禮上塞茅,老公的妹妹穿的比我還像新娘。我一直安慰自己季率,他們只是感情好野瘦,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,390評(píng)論 5 384
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著飒泻,像睡著了一般缅刽。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上蠢络,一...
    開(kāi)封第一講書人閱讀 49,741評(píng)論 1 289
  • 那天衰猛,我揣著相機(jī)與錄音,去河邊找鬼刹孔。 笑死啡省,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的髓霞。 我是一名探鬼主播卦睹,決...
    沈念sama閱讀 38,892評(píng)論 3 405
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼方库!你這毒婦竟也來(lái)了结序?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書人閱讀 37,655評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤纵潦,失蹤者是張志新(化名)和其女友劉穎徐鹤,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體邀层,經(jīng)...
    沈念sama閱讀 44,104評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡返敬,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,451評(píng)論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了寥院。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片劲赠。...
    茶點(diǎn)故事閱讀 38,569評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖秸谢,靈堂內(nèi)的尸體忽然破棺而出凛澎,到底是詐尸還是另有隱情,我是刑警寧澤估蹄,帶...
    沈念sama閱讀 34,254評(píng)論 4 328
  • 正文 年R本政府宣布塑煎,位于F島的核電站,受9級(jí)特大地震影響元媚,放射性物質(zhì)發(fā)生泄漏轧叽。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,834評(píng)論 3 312
  • 文/蒙蒙 一刊棕、第九天 我趴在偏房一處隱蔽的房頂上張望炭晒。 院中可真熱鬧,春花似錦甥角、人聲如沸网严。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 30,725評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)震束。三九已至,卻和暖如春当犯,著一層夾襖步出監(jiān)牢的瞬間垢村,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 31,950評(píng)論 1 264
  • 我被黑心中介騙來(lái)泰國(guó)打工嚎卫, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留嘉栓,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,260評(píng)論 2 360
  • 正文 我出身青樓拓诸,卻偏偏與公主長(zhǎng)得像侵佃,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子奠支,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,446評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,306評(píng)論 0 10
  • 大量的靜態(tài)圖像數(shù)據(jù) 一馋辈、 問(wèn)題 1. 數(shù)據(jù)流量特征 通過(guò)App向各個(gè)微服務(wù)提交的業(yè)務(wù)數(shù)據(jù)中,通常會(huì)包含以下類型的現(xiàn)...
    toliong閱讀 1,641評(píng)論 0 0
  • 在夢(mèng)里 我仿佛看到了好多人 他們?cè)诳粗?在夢(mèng)里 我仿佛聽(tīng)到了敲門聲 分明是敲的我的門 在夢(mèng)里 我仿佛感覺(jué)到我在一...
    一顆樹007閱讀 177評(píng)論 0 2
  • 【原文】員工執(zhí)行力差、常常抱怨尔崔、找借口……之所以出現(xiàn)這樣的問(wèn)題井联,是因?yàn)槠髽I(yè)的領(lǐng)導(dǎo)層對(duì)員工的身份定位是“部分人”而非...
    w小郭閱讀 339評(píng)論 2 0