ShareHashFile是一個輕巧的,可嵌入的NOSQL鍵值存儲 /哈希表,具有穩定的鍵提示,零副本IPC隊列以及用C為Linux編寫的多重IPC Logging庫。直接在共享內存中訪問的數據;共享Hashfile和應用程序計劃之間沒有使用插座;沒有服務器過程。 C&C ++的API。
默認情況下,數據將保存在共享內存中,使所有數據都可以訪問任何進程。多達40億鍵可以存儲在單個共享Hashfile Hash表中,該鍵只能通過可用的RAM限制。
例如,假設您有一個帶有128GB RAM的盒子,SharedHashfile哈希表使用了96GB。該盒子有24個內核,並且共有24個過程(例如Nginx分叉的從工藝或其他方法)同時訪問96GB的哈希表。每個過程共享與共享內存完全相同的96GB。
由於一個鍵,值對在跨n個進程的共享內存中保存,因此共享內存可以隨時更改和/或移動。因此,獲得一個值總是會導致接收值的本地副本。
鍵和值當前是二進製字符串,最大長度為2^32字節。
傳統的malloc()在共享內存中不起作用,因為我們必須使用偏移而不是傳統的指針。因此,ShareHashfile使用其自己的Malloc()實現來共享內存。
為了避免記憶孔,然後在鑰匙,值插入時會不時發生垃圾收集。在垃圾收集過程中,垃圾收集過程中產生的值對的數量被算法故意限制為最多8,192對,無論在哈希表中插入了多少鍵。這意味著哈希表總是感覺非常響應。
ShareHashFile旨在優雅地擴展,隨著更多關鍵,值對插入。沒有突然的記憶增加或記憶加倍事件。而且由於重新匯總鑰匙而沒有大大的停頓。
為了減少爭論,設計沒有單個全局哈希表鎖定。取而代之的是,鑰匙在256個鎖上分碎,以減少鎖定爭論。
對於具有高水平寫作的用例,因此由於刪除鑰匙刪除的記憶孔時,由於回收 /收縮的內存映射區域而導致的系統MMAP()調用過多,因此性能可能會受到影響。
為了提高寫重用案例的性能,可以在整個哈希表中固定鍵和值,這意味著可以輕鬆地重複使用刪除的鍵而無需創建內存孔,並且無需昂貴的系統MMAP()調用。
使用固定長度鍵和值還減少了使用的RAM量,因為鍵和值不再存儲,例如1億鍵和值將節省1億 * 8字節= 8億字節。
哈希表存儲在/dev/shm中的內存映射文件中,這意味著即使沒有進程使用哈希表,數據仍然存在。但是,哈希表將無法生存在重新啟動時。
與其他哈希表不同,存儲在sharedhashfile中的每個密鑰都會分配自己的UID,例如shf_make_hash("key", 3); uint32_t uid = shf_put_key_val(shf, "val", 3) 。要在將來獲取相同的密鑰,請選擇通過其密鑰訪問鍵,或通過其UID訪問鍵,例如shf_make_hash("key", 3); shf_get_key_val_copy(shf)或shf_get_uid_val_copy(shf, uid) 。
UID有用什麼? UID不會佔用任何額外的資源,可以將其視為“免費”資源。訪問鑰匙的UID比通過其鍵訪問鍵要快。由於UID的大小僅為32bit,因此可以輕鬆地存儲作為對程序中的鍵的引用,或嵌入到鍵,值對的值中,甚至嵌入其他鍵中。
示例用法:如果UID1指向密鑰"user-id-<xyz>" ,並且UID2指向鍵"facebook.com" ,則另一個'mash Up'鍵可能為"<uid1><uid2>" 。是否想找出"user-id-<xyz>"是否在其個人URL白名單中具有"facebook.com"嗎?只需查看是否存在鍵"<uid1><uid2>" 。
“穩定鑰匙提示”中的“穩定”是什麼意思?這意味著即使鍵和/或值字節在內存中移動,UID也保持不變。
它如何工作?創建X固定尺寸的隊列元素,然後將這些隊列元素推向/從。
示例:想像兩個過程Process A & Process B 。 Process A創建100,000個隊列元素和3個隊列; queue-free , queue-a2b和queue-b2a 。從直覺上講,所有隊列元素都被推到queue-free上。 Process A然後產生附加到ShareHashfile的Process B ,以便從queue-a2b中拉出。要執行零拷貝IPC,然後Process A可以從無queue-free下將隊列元素拉到固定尺寸,共享內存隊列元素,然後將隊列元素推入queue-a2b 。 Process B相反;從queue-a2b中拉出隊列元素,操縱固定大小,共享內存隊列隊列元素,並將隊列元素推入queue-b2a 。 Process A還可以從queue-b2a中拉出隊列項目,以消化Process B結果。
那麼,每秒可以通過Processes A和Process B來回移動多少個隊列元素?在聯想W530筆記本電腦上,如果兩個Process A和Process B都在C中寫成。
注意:當隊列元素從一個隊列移動到另一個隊列時,然後不復制它,只會更新引用。
它如何工作? Process A調用shf_log_thread_new(),該shf_log_thread_new()創建共享內存日誌緩衝區和日誌輸出線程,該線程會定期監視新的日誌線。 Process B調用SHF_LOG_ATTACH_EXISTING()開始登錄相同的共享日誌。使用C宏SHF_PLAIN()和SHF_DEBUG()登錄。如果尚未調用SHF_LOG_THREAD_NEW(),則輸出會自動進入Stdout,否則日誌記錄由日誌輸出線程多路復用。
示例輸出:
sharedhashfile$ cat debug/test.q.shf.t.tout
1..10
=0.000000 23056 pid 23056 started; mode is 'c2c'
=0.000013 23056 - SHF_SNPRINTF() // 'test-23056-ipc-queue'
ok 1 - c2*: shf_attach() works for non-existing file as expected
=0.000002 23060 shf.monitor: monitoring pid 23056 to delete /dev/shm/test-23056-ipc-queue.shf
1..7
=0.000001 23064 pid 23064 started; mode is '4c'
=0.000010 23064 - SHF_SNPRINTF() // 'test-23064-ipc-queue'
ok 1 - 4c: shf_attach_existing() works for existing file as expected
#0.003948 1 --> auto mapped to thread id 23061
#0.003948 1 shf_log_thread(shf=?){}
ok 2 - c2*: put lock in value as expected
ok 3 - c2*: shf_q_new() returned as expected
ok 4 - c2*: moved expected number of new queue items // estimate 51,044,225 q items per second without contention
#0.131327 2 --> auto mapped to thread id 23064
#0.131327 2 '4c' mode; behaving as client
ok 2 - 4c: shf_q_get_name('qid-free') returned qid as expected
ok 3 - 4c: shf_q_get_name('qid-a2b' ) returned qid as expected
ok 4 - 4c: shf_q_get_name('qid-b2a' ) returned qid as expected
#0.158467 2 shf_race_start() // 2 horses started after 0.000001 seconds
#0.158474 2 testing process b IPC queue a2b --> b2a speed
#0.158467 3 --> auto mapped to thread id 23056
#0.158467 3 shf_race_start() // 2 horses started after 0.027820 seconds
#0.158484 3 testing process a IPC queue b2a --> a2b speed
ok 5 - 4c: moved expected number of new queue items // estimate 53,106,512 q items per second with contention
#0.179207 2 testing process b IPC lock speed
ok 6 - 4c: got lock value address as expected
ok 5 - c2*: moved expected number of new queue items // estimate 52,951,698 q items per second with contention
#0.180467 3 testing process a IPC lock speed
ok 6 - c2*: got lock value address as expected
#0.180475 3 shf_race_start() // 2 horses started after 0.000000 seconds
#0.180475 2 shf_race_start() // 2 horses started after 0.001165 seconds
ok 7 - c2*: rw lock expected number of times // estimate 4,422,109 locks per second; with contention
ok 7 - 4c: rw lock expected number of times // estimate 4,411,319 locks per second; with contention
#0.633875 2 ending child
ok 8 - c2*: rw lock expected number of times // estimate 51,144,435 locks per second; without contention
ok 9 - c2*: rw lock expected number of times // estimate 381,821,029 locks per second; without lock, just loop
ok 10 - c2*: test still alive
#0.677166 3 ending parent
#0.677177 3 shf_del(shf=?)
#0.677180 3 - SHF_SNPRINTF() // 'du -h -d 0 /dev/shm/test-23056-ipc-queue.shf ; rm -rf /dev/shm/test-23056-ipc-queue.shf/'
#0.677181 3 shf_detach(shf=?)
#0.677183 3 shf_log_thread_del(shf=?) // waiting for log thread to end
=0.686385 3 shf_backticks('du -h -d 0 /dev/shm/test-23056-ipc-queue.shf ; rm -rf /dev/shm/test-23056-ipc-queue.shf/')
=0.724220 3 - read 39 bytes from the pipe
test: shf size before deletion: 394M /dev/shm/test-23056-ipc-queue.shf
筆記:
使用make構建發布代碼,並使用make debug構建發行代碼。測試自動運行。
root@16vcpu:/# make clean ; make
rm -rf release debug
make: variable: PROD_SRCS=murmurhash3.c shf.c tap.c
make: variable: PROD_OBJS=release/murmurhash3.o release/shf.o release/tap.o
make: variable: TEST_SRCS=test.1.tap.c test.9.shf.c
make: variable: TEST_OBJS=release/test.1.tap.o release/test.9.shf.o
make: variable: TEST_EXES=release/test.1.tap.t release/test.9.shf.t
make: compling: release/test.1.tap.o
make: compling: release/murmurhash3.o
make: compling: release/shf.o
make: compling: release/tap.o
make: linking: release/test.1.tap.t
make: running: release/test.1.tap.t
1..1
ok 1 - All passed
make: compling: release/test.9.shf.o
make: linking: release/test.9.shf.t
make: running: release/test.9.shf.t
1..10
ok 1 - shf_attach_existing() fails for non-existing file as expected
ok 2 - shf_attach() works for non-existing file as expected
ok 3 - shf_get_copy_via_key() could not find unput key as expected
ok 4 - shf_get_copy_via_key() could find put key as expected
ok 5 - put expected number of keys // 2293581 keys per second
ok 6 - got expected number of non-existing keys // 3812667 keys per second
ok 7 - got expected number of existing keys // 3021523 keys per second
ok 8 - graceful growth cleans up after itself as expected
ok 9 - del expected number of existing keys // 3109056 keys per second
ok 10 - del does not clean up after itself as expected
running tests on: via command: 'cat /proc/cpuinfo | egrep 'model name' | head -n 1'
running tests on: `model name : Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz`
-OP MMAP REMAP SHRK PART TOTAL ------PERCENT OPERATIONS PER PROCESS PER SECOND -OPS
--- -k/s --k/s --/s --/s M-OPS 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 -M/s
PUT 3.4 16.9 1298 626 0.0 10 10 8 5 3 2 8 9 9 6 2 8 4 7 8 4 0.0
PUT 51.4 363.7 1410 1200 5.4 7 6 7 6 7 5 6 7 6 6 6 7 7 6 5 6 5.4 -------
PUT 65.2 336.9 2036 2036 10.1 7 5 7 6 7 6 7 7 6 6 6 7 7 6 5 6 4.6 ------
PUT 56.8 331.7 1888 1888 14.9 6 5 6 7 6 7 7 7 6 6 6 7 7 6 5 6 4.9 ------
PUT 73.8 286.8 2200 2200 18.8 7 5 5 7 7 7 7 7 6 7 6 6 6 5 5 7 3.9 -----
PUT 21.2 412.9 726 726 25.1 6 5 5 7 7 8 7 7 6 6 6 6 6 5 5 7 6.3 --------
PUT 77.9 312.0 2554 2557 29.3 6 6 6 6 6 7 6 6 6 6 6 7 6 6 6 7 4.2 -----
PUT 96.7 272.2 3044 3041 32.5 7 6 6 6 6 7 6 6 6 7 6 7 6 6 6 7 3.1 ----
PUT 63.3 303.3 1804 1804 36.6 7 6 6 5 5 7 6 7 5 6 5 7 7 6 6 7 4.2 -----
PUT 11.5 380.9 349 349 43.2 7 6 6 5 5 7 6 6 6 5 6 7 7 6 6 6 6.6 --------
PUT 26.3 444.5 895 898 49.1 7 6 6 5 5 7 6 7 6 6 6 7 7 6 6 7 5.9 -------
PUT 55.0 283.9 1862 1860 53.8 5 6 6 6 6 6 5 7 6 6 7 7 7 6 6 7 4.7 ------
PUT 75.0 312.1 2480 2480 57.4 7 7 6 5 6 5 7 7 6 6 7 7 6 7 5 6 3.6 ----
PUT 88.5 191.2 2859 2858 60.6 7 7 6 6 7 6 7 5 7 5 7 7 6 7 6 5 3.2 ----
PUT 90.6 244.9 2853 2854 63.5 7 7 5 7 7 5 7 5 7 5 7 7 6 7 7 5 2.9 ---
PUT 82.6 258.8 2455 2455 66.4 7 7 5 7 7 6 7 5 6 5 7 7 5 7 6 5 3.0 ---
PUT 69.7 185.9 1970 1970 70.3 7 7 6 5 7 6 7 6 5 5 7 7 6 7 7 5 3.9 -----
PUT 28.8 409.6 761 760 75.6 6 7 6 6 6 5 6 6 7 5 7 7 5 7 7 6 5.2 ------
PUT 7.2 490.9 230 230 82.0 6 8 5 6 6 5 5 6 5 5 7 8 6 8 7 6 6.4 --------
PUT 11.1 414.9 391 391 88.4 6 7 7 6 6 5 5 6 6 5 6 7 5 7 7 6 6.4 --------
PUT 22.3 323.4 810 810 94.5 7 8 8 7 6 6 5 7 6 5 7 2 6 8 7 7 6.1 --------
PUT 26.1 302.4 1124 1124 99.3 2 5 8 9 7 8 10 1 9 9 6 0 8 4 9 6 4.8 ------
PUT 1.6 6.8 239 239 100.0 0 0 0 0 0 0 0 0 14 58 0 0 5 0 23 0 0.7
MIX 0.0 0.0 0 0 100.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0
MIX 21.8 103.9 0 0 105.3 5 6 6 7 7 7 7 5 8 6 6 3 7 6 7 7 5.3 -------
MIX 0.5 8.2 0 0 114.0 6 6 5 6 7 5 6 7 7 6 7 6 7 7 6 6 8.7 -----------
MIX 0.0 8.5 0 0 122.8 6 6 5 6 7 5 6 7 7 6 7 6 7 7 6 6 8.7 -----------
MIX 0.0 9.6 0 0 131.7 6 6 6 6 7 6 6 7 6 6 7 6 7 7 6 6 8.9 -----------
MIX 0.0 11.1 0 0 140.8 6 6 7 6 7 6 5 7 6 6 7 5 7 7 5 6 9.1 ------------
MIX 0.0 12.0 0 0 149.6 6 6 7 7 6 6 6 6 7 6 6 6 6 6 6 7 8.8 -----------
MIX 0.0 12.7 0 0 158.3 7 6 6 7 6 6 7 6 7 6 6 6 6 6 7 7 8.7 -----------
MIX 0.0 14.0 0 0 167.1 7 6 6 7 6 6 7 6 7 6 6 6 6 6 7 7 8.8 -----------
MIX 0.0 14.7 0 0 176.2 7 6 6 5 6 6 7 6 7 6 6 5 6 6 7 7 9.1 ------------
MIX 0.0 16.3 0 0 185.1 6 7 7 7 7 7 6 6 6 5 6 7 6 5 6 6 8.9 -----------
MIX 0.0 17.0 0 0 194.3 6 7 7 7 7 6 6 6 6 5 6 7 6 5 6 6 9.2 ------------
MIX 0.0 7.1 0 0 200.0 9 9 7 2 3 10 9 5 0 11 4 14 3 7 6 1 5.7 -------
GET 0.0 0.0 0 0 200.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0
GET 0.0 2.1 0 0 200.3 3 6 7 6 7 6 6 6 7 7 7 3 7 7 7 7 0.3
GET 0.0 2.4 0 0 208.5 6 6 6 6 7 6 6 6 7 6 7 6 6 7 6 7 8.2 ----------
GET 0.0 0.0 0 0 217.4 6 7 7 6 7 5 6 6 7 6 7 6 6 7 6 6 8.9 -----------
GET 0.0 0.0 0 0 226.3 6 7 8 6 7 5 6 6 7 5 7 5 6 7 6 5 9.0 -----------
GET 0.0 0.0 0 0 235.3 6 7 7 6 8 5 6 6 8 5 7 5 5 7 6 6 9.0 -----------
GET 0.0 0.0 0 0 244.2 6 7 6 8 7 5 6 6 7 6 7 6 6 5 6 6 8.9 -----------
GET 0.0 0.0 0 0 253.5 5 8 5 8 6 6 7 8 7 5 8 5 5 5 7 5 9.3 ------------
GET 0.0 0.0 0 0 263.1 4 8 5 9 5 5 8 9 5 5 8 5 5 5 8 5 9.6 ------------
GET 0.0 0.0 0 0 272.9 4 8 5 7 5 7 8 9 5 5 8 5 5 5 8 5 9.8 -------------
GET 0.0 0.0 0 0 282.3 5 7 5 6 8 7 7 8 5 5 7 5 5 6 7 5 9.4 ------------
GET 0.0 0.0 0 0 291.0 6 2 6 6 9 10 8 4 6 6 2 6 6 6 8 6 8.7 -----------
GET 0.0 0.0 0 0 298.7 12 0 10 3 0 9 0 0 4 12 0 12 13 9 0 15 7.7 ----------
GET 0.0 0.0 0 0 300.0 32 0 0 0 0 0 0 0 0 23 0 27 18 0 0 0 1.3 -
* MIX is 2% (2000000) del/put, 98% (12100654) get
make: built and tested release version
筆記:
這是8個核心Lenovo W530筆記本電腦上的一個示例,顯示了帶有1億鍵的哈希桌,然後進行2%的刪除/插入物,98%的讀數為每秒超過1000萬次的操作率:
$ make clean ; make release
$ PATH=release:$PATH SHF_PERFORMANCE_TEST_ENABLE=1 test.f.shf.t
...
perf testing: SharedHashFile
running tests on: via command: 'cat /proc/cpuinfo | egrep 'model name' | head -n 1'
running tests on: `model name : Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz`
-OP MMAP REMAP SHRK PART TOTAL ------PERCENT OPERATIONS PER PROCESS PER SECOND -OPS
--- -k/s --k/s --/s --/s M-OPS 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 -M/s
PUT 0.2 0.0 0 0 0.0 32 30 0 0 0 0 0 38 0 0 0 0 0 0 0 0 0.0
PUT 30.0 89.4 1767 1767 4.5 13 13 13 12 13 12 12 13 0 0 0 0 0 0 0 0 4.5 -----
PUT 30.6 70.8 1925 1925 8.6 13 12 13 13 13 12 13 12 0 0 0 0 0 0 0 0 4.1 -----
PUT 17.1 103.3 1090 1090 13.7 12 12 13 13 13 12 13 13 0 0 0 0 0 0 0 0 5.1 ------
PUT 37.2 47.6 2334 2334 16.4 13 12 13 13 13 12 12 13 0 0 0 0 0 0 0 0 2.6 ---
PUT 15.7 88.1 944 944 21.4 13 12 13 12 12 12 13 12 0 0 0 0 0 0 0 0 5.0 ------
PUT 15.6 105.9 1035 1035 26.1 13 12 13 12 13 12 13 13 0 0 0 0 0 0 0 0 4.7 ------
PUT 34.3 63.6 2180 2181 29.3 13 12 13 12 12 13 12 13 0 0 0 0 0 0 0 0 3.1 ----
PUT 39.7 48.8 2478 2478 31.9 13 12 13 12 13 13 13 12 0 0 0 0 0 0 0 0 2.7 ---
PUT 32.1 47.3 1950 1949 35.0 12 12 12 12 13 13 12 12 0 0 0 0 0 0 0 0 3.0 ----
PUT 9.2 108.6 542 542 40.6 13 13 13 12 13 12 13 13 0 0 0 0 0 0 0 0 5.7 -------
PUT 8.4 132.2 552 552 46.4 13 12 13 12 12 12 13 12 0 0 0 0 0 0 0 0 5.8 -------
PUT 18.1 44.8 1184 1184 51.0 12 12 13 12 12 13 12 13 0 0 0 0 0 0 0 0 4.6 ------
PUT 25.3 98.8 1622 1622 54.4 13 12 13 12 13 12 13 13 0 0 0 0 0 0 0 0 3.4 ----
PUT 27.0 52.5 1730 1730 56.9 12 13 12 13 13 12 12 13 0 0 0 0 0 0 0 0 2.5 ---
PUT 35.4 67.9 2260 2260 59.4 13 13 13 13 13 13 12 12 0 0 0 0 0 0 0 0 2.5 ---
PUT 38.1 52.3 2382 2383 61.9 13 12 12 13 13 13 13 12 0 0 0 0 0 0 0 0 2.5 ---
PUT 37.2 18.8 2306 2306 64.4 13 13 12 13 13 13 12 12 0 0 0 0 0 0 0 0 2.5 ---
PUT 33.7 25.1 2059 2059 67.1 13 12 12 13 12 13 13 12 0 0 0 0 0 0 0 0 2.8 ---
PUT 23.8 75.4 1427 1426 70.1 13 12 12 13 13 13 13 12 0 0 0 0 0 0 0 0 3.0 ---
PUT 12.2 191.3 705 706 73.9 12 13 13 13 13 13 12 12 0 0 0 0 0 0 0 0 3.8 -----
PUT 4.5 15.7 270 269 80.8 12 12 13 13 13 13 12 12 0 0 0 0 0 0 0 0 6.9 ---------
PUT 5.2 129.8 347 347 87.0 13 12 13 12 13 13 12 12 0 0 0 0 0 0 0 0 6.2 --------
PUT 8.4 133.8 557 557 92.4 13 13 12 13 12 13 12 13 0 0 0 0 0 0 0 0 5.4 -------
PUT 14.3 6.2 933 933 97.3 13 12 12 13 12 13 13 12 0 0 0 0 0 0 0 0 4.9 ------
PUT 11.5 16.5 777 777 100.0 11 15 10 13 11 12 13 15 0 0 0 0 0 0 0 0 2.7 ---
MIX 0.0 0.0 0 0 100.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0
MIX 2.3 5.6 0 0 101.2 12 14 11 12 12 12 13 13 0 0 0 0 0 0 0 0 1.2 -
MIX 0.3 3.9 0 0 110.4 12 13 13 13 12 13 12 13 0 0 0 0 0 0 0 0 9.2 ------------
MIX 0.0 4.1 0 0 119.7 13 13 13 12 12 13 13 13 0 0 0 0 0 0 0 0 9.3 ------------
MIX 0.0 5.3 0 0 129.4 13 13 12 13 12 13 12 13 0 0 0 0 0 0 0 0 9.8 -------------
MIX 0.0 5.6 0 0 139.0 13 13 12 12 12 13 13 12 0 0 0 0 0 0 0 0 9.6 ------------
MIX 0.0 6.3 0 0 148.5 13 13 13 12 12 12 13 12 0 0 0 0 0 0 0 0 9.5 ------------
MIX 0.0 7.0 0 0 158.4 13 13 13 12 12 13 12 13 0 0 0 0 0 0 0 0 9.9 -------------
MIX 0.0 7.0 0 0 167.7 12 13 13 12 12 13 12 13 0 0 0 0 0 0 0 0 9.3 ------------
MIX 0.0 7.9 0 0 176.7 13 13 13 13 12 13 12 13 0 0 0 0 0 0 0 0 9.1 ------------
MIX 0.0 8.7 0 0 186.5 13 12 13 13 12 13 12 13 0 0 0 0 0 0 0 0 9.8 -------------
MIX 0.0 8.7 0 0 196.0 13 13 13 12 12 12 12 13 0 0 0 0 0 0 0 0 9.5 ------------
MIX 0.0 3.5 0 0 200.0 10 8 12 15 17 11 15 11 0 0 0 0 0 0 0 0 4.0 -----
GET 0.0 0.0 0 0 200.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0
GET 0.0 0.6 0 0 206.5 13 13 13 12 10 13 13 13 0 0 0 0 0 0 0 0 6.5 --------
GET 0.0 0.0 0 0 217.9 13 12 13 13 12 12 12 13 0 0 0 0 0 0 0 0 11.4 ---------------
GET 0.0 0.0 0 0 229.3 13 12 13 13 13 11 12 13 0 0 0 0 0 0 0 0 11.4 ---------------
GET 0.0 0.0 0 0 240.6 13 13 13 13 13 12 12 13 0 0 0 0 0 0 0 0 11.3 ---------------
GET 0.0 0.0 0 0 251.9 13 13 13 12 13 13 10 13 0 0 0 0 0 0 0 0 11.3 ---------------
GET 0.0 0.0 0 0 263.2 12 12 13 12 13 13 12 13 0 0 0 0 0 0 0 0 11.3 ---------------
GET 0.0 0.0 0 0 274.4 13 13 13 13 12 13 13 11 0 0 0 0 0 0 0 0 11.2 --------------
GET 0.0 0.0 0 0 285.9 12 13 13 13 12 12 13 13 0 0 0 0 0 0 0 0 11.5 ---------------
GET 0.0 0.0 0 0 297.3 12 13 13 13 12 12 13 12 0 0 0 0 0 0 0 0 11.4 ---------------
GET 0.0 0.0 0 0 300.0 6 9 0 11 22 21 24 6 0 0 0 0 0 0 0 0 2.7 ---
* MIX is 2% (2000000) del/put, 98% (12100654) get
DB size: 3.9G /dev/shm/test-shf-19973.shf
這是與上述相同的測試,但使用LMDB而不是共享HashaShfile:
筆記:
$ perl perf-test-lmdb.pl
...
perf testing: LMDB aka Lightning MDB
running tests on: via command: 'cat /proc/cpuinfo | egrep 'model name' | head -n 1'
running tests on: `model name : Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz`
-OP MMAP REMAP SHRK PART TOTAL ------PERCENT OPERATIONS PER PROCESS PER SECOND -OPS
--- -k/s --k/s --/s --/s M-OPS 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 -M/s
PUT 0.0 0.0 0 0 0.0 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0
PUT 0.0 0.0 0 0 1.1 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.1 -
PUT 0.0 0.0 0 0 1.9 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.8 -
PUT 0.0 0.0 0 0 2.6 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.7
PUT 0.0 0.0 0 0 3.3 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.7
PUT 0.0 0.0 0 0 3.9 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.6
PUT 0.0 0.0 0 0 4.4 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.6
PUT 0.0 0.0 0 0 5.0 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5
PUT 0.0 0.0 0 0 5.4 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5
PUT 0.0 0.0 0 0 5.9 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5
PUT 0.0 0.0 0 0 6.3 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4
PUT 0.0 0.0 0 0 6.8 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4
PUT 0.0 0.0 0 0 7.2 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4
PUT 0.0 0.0 0 0 7.6 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4
PUT 0.0 0.0 0 0 7.9 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4
PUT 0.0 0.0 0 0 8.3 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3
PUT 0.0 0.0 0 0 8.6 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3
...
PUT 0.0 0.0 0 0 72.1 0 0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3
PUT 0.0 0.0 0 0 72.3 5 0 93 2 0 0 0 0 0 0 0 0 0 0 0 0 0.2
...
PUT 0.0 0.0 0 0 100.0100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2
MIX 0.0 0.0 0 0 100.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0
MIX 0.0 0.0 0 0 100.3 13 12 12 13 13 12 12 13 0 0 0 0 0 0 0 0 0.3
MIX 0.0 0.0 0 0 101.3 12 12 12 13 12 12 13 13 0 0 0 0 0 0 0 0 1.0 -
MIX 0.0 0.0 0 0 102.3 13 12 13 13 12 13 12 12 0 0 0 0 0 0 0 0 1.0 -
...
MIX 0.0 0.0 0 0 198.3 13 13 12 13 13 12 12 12 0 0 0 0 0 0 0 0 1.0 -
MIX 0.0 0.0 0 0 199.4 12 12 12 12 13 13 13 13 0 0 0 0 0 0 0 0 1.1 -
MIX 0.0 0.0 0 0 200.0 13 27 10 3 17 8 11 11 0 0 0 0 0 0 0 0 0.6
GET 0.0 0.0 0 0 200.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0
GET 0.0 0.0 0 0 203.0 13 13 12 13 11 13 12 13 0 0 0 0 0 0 0 0 3.0 ---
GET 0.0 0.0 0 0 208.1 13 12 13 13 12 13 11 13 0 0 0 0 0 0 0 0 5.2 ------
GET 0.0 0.0 0 0 213.4 12 11 14 12 13 13 13 11 0 0 0 0 0 0 0 0 5.2 ------
GET 0.0 0.0 0 0 218.6 13 11 14 12 13 12 13 12 0 0 0 0 0 0 0 0 5.2 ------
GET 0.0 0.0 0 0 223.8 13 11 13 13 13 13 12 12 0 0 0 0 0 0 0 0 5.3 -------
GET 0.0 0.0 0 0 229.2 12 12 12 13 14 14 12 12 0 0 0 0 0 0 0 0 5.4 -------
GET 0.0 0.0 0 0 234.3 12 13 12 12 11 13 13 13 0 0 0 0 0 0 0 0 5.1 ------
GET 0.0 0.0 0 0 239.6 11 12 14 12 12 13 14 12 0 0 0 0 0 0 0 0 5.3 -------
GET 0.0 0.0 0 0 244.9 12 12 14 10 13 13 14 13 0 0 0 0 0 0 0 0 5.3 -------
GET 0.0 0.0 0 0 250.1 11 11 13 13 13 13 14 13 0 0 0 0 0 0 0 0 5.3 -------
GET 0.0 0.0 0 0 255.3 13 12 12 12 13 12 13 12 0 0 0 0 0 0 0 0 5.2 ------
GET 0.0 0.0 0 0 260.5 13 12 11 13 12 14 13 11 0 0 0 0 0 0 0 0 5.2 ------
GET 0.0 0.0 0 0 265.8 13 12 12 11 13 13 14 11 0 0 0 0 0 0 0 0 5.2 ------
GET 0.0 0.0 0 0 270.8 14 12 12 12 13 13 13 12 0 0 0 0 0 0 0 0 5.1 ------
GET 0.0 0.0 0 0 275.9 12 14 13 13 13 12 14 10 0 0 0 0 0 0 0 0 5.1 ------
GET 0.0 0.0 0 0 281.3 12 14 13 12 12 13 14 10 0 0 0 0 0 0 0 0 5.4 -------
GET 0.0 0.0 0 0 286.4 14 13 12 13 12 13 13 12 0 0 0 0 0 0 0 0 5.2 ------
GET 0.0 0.0 0 0 291.7 13 12 11 11 13 13 13 13 0 0 0 0 0 0 0 0 5.3 -------
GET 0.0 0.0 0 0 296.7 12 13 12 13 13 14 11 13 0 0 0 0 0 0 0 0 5.0 ------
GET 0.0 0.0 0 0 300.0 12 22 11 19 10 0 0 25 0 0 0 0 0 0 0 0 3.2 ----
GET 0.0 0.0 0 0 300.0 0 0 0 0 0 0 0100 0 0 0 0 0 0 0 0 0.0
* MIX is 2% (2000000) del/put, 98% (12100654) get
DB size: 2.6G /dev/shm/test-lmdb-20848