LevelDB dbbench 参数设置 和 使用

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

//  Actual benchmarks:

//      fillseq      -- write N values in sequential key order in async mode  顺序写

//      fillrandom    -- write N values in random key order in async mode  随机写

//      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)

使用方法

说明选自 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 官方测试结果

原文: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.

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,098评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,213评论 2 380
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,960评论 0 336
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,519评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,512评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,533评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,914评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,574评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,804评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,563评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,644评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,350评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,933评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,908评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,146评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,847评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,361评论 2 342

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,279评论 0 10
  • 大量的静态图像数据 一、 问题 1. 数据流量特征 通过App向各个微服务提交的业务数据中,通常会包含以下类型的现...
    toliong阅读 1,631评论 0 0
  • 在梦里 我仿佛看到了好多人 他们在看着我 在梦里 我仿佛听到了敲门声 分明是敲的我的门 在梦里 我仿佛感觉到我在一...
    一颗树007阅读 176评论 0 2
  • 【原文】员工执行力差、常常抱怨、找借口……之所以出现这样的问题,是因为企业的领导层对员工的身份定位是“部分人”而非...
    w小郭阅读 337评论 2 0