bytedance / terarkdb

A RocksDB compatible KV storage engine with better performance
Apache License 2.0
2.04k stars 203 forks source link

How can I see Compaction Stats? #151

Closed lovers-under-moon closed 2 years ago

lovers-under-moon commented 2 years ago

[BUG]

Expected behavior

I would like to see the Compaction Stats in test.log,so I add stats to benchmarks's param.

root@wdh-femu:/media/wdh/MyFile/terarkdb# ./output/db_bench --zbd_path=nvme1n1 --benchmarks="fillrandom,stats,sstables,levelstats" --use_existing_db=0 --histogram=1 --num=10000000 --value_size=1000 --compression_type=none --db=test_db_1>test.log
RocksDB:    version 5.18
Date:       Wed Nov 17 12:34:16 2021
CPU:        32 * Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
CPUCache:   20480 KB

Actual behavior

I printf the files in db,there are a lot of files.This is correct. But the stats in test.log is strange,the files is too few and file size is too small.

root@wdh-femu:/media/wdh/MyFile/terarkdb# output/zenfs list --zbd=nvme1n1 --path=test_db_1
           0    Nov 17 2021 12:34:16            LOCK                            
     1883464    Nov 17 2021 12:35:33            LOG                             
    64123678    Nov 17 2021 12:34:30            000172.sst                      
    67584810    Nov 17 2021 12:34:30            000174.sst                      
    64125951    Nov 17 2021 12:34:30            000178.sst                      
    67584870    Nov 17 2021 12:34:30            000181.sst                      
    67584831    Nov 17 2021 12:34:30            000182.sst                      
    64157972    Nov 17 2021 12:34:30            000184.sst   
……
    67582979    Nov 17 2021 12:35:33            001287.sst                      
    40952609    Nov 17 2021 12:35:33            001288.log                      
    64147427    Nov 17 2021 12:35:32            001289.sst                      
    67584795    Nov 17 2021 12:35:33            001291.sst                      
    67584722    Nov 17 2021 12:35:33            001293.sst                      
        4698    Nov 17 2021 12:35:33            001294.sst                      
           0    Nov 17 2021 12:35:33            001296.log                      
    64157825    Nov 17 2021 12:35:33            001297.sst                      
        2440    Nov 17 2021 12:35:33            001299.sst                      
          16    Nov 17 2021 12:34:17            CURRENT                         
          37    Nov 17 2021 12:34:16            IDENTITY                        
      232228    Nov 17 2021 12:35:33            MANIFEST-000009                 
        5342    Nov 17 2021 12:34:16            OPTIONS-000005  
root@wdh-femu:/media/wdh/MyFile/terarkdb# output/zenfs df --zbd=nvme1n1
Free: 7766799 MB
Used: 16452 MB
Reclaimable: 19595 MB
Space amplification: 119%
** Compaction Stats [default] **
Level    Files   Size     Score Read(GB)  Rn(GB) Rnp1(GB) Write(GB) Wnew(GB) Moved(GB) W-Amp Rd(MB/s) Wr(MB/s) Comp(sec) Comp(cnt) Avg(sec) KeyIn KeyDrop
----------------------------------------------------------------------------------------------------------------------------------------------------------
  L0      0/0    0.00 KB   0.0      0.0     0.0      0.0       9.6      9.6       0.0   1.0      0.0    356.7        27       160    0.171       0      0
  L1      1/0    2.38 KB   2.8     12.7     9.6      3.1       9.4      6.3       0.0   1.0    251.8    186.3        52       213    0.242     13M   211K
  L2      1/1    4.59 KB   0.0      0.0     0.0      0.0      10.6     10.6       0.0 148920.4      0.0    181.6        60       218    0.274    7635   615K
  L3      1/1   15.14 KB   0.0      0.0     0.0      0.0       3.8      3.8       0.0 47731.2      0.0    169.9        23        83    0.279    7298   666K
 Sum      3/2   22.11 KB   0.0     12.7     9.6      3.1      33.4     30.2       0.0   3.5     80.2    211.1       162       674    0.240     13M  1493K
 Int      0/0    0.00 KB   0.0     12.0     9.1      2.9      32.3     29.5       0.0   3.6     77.5    209.4       158       654    0.242     12M  1487K
Uptime(secs): 77.0 total, 72.0 interval
Flush(GB): cumulative 9.558, interval 8.960
AddFile(GB): cumulative 0.000, interval 0.000
AddFile(Total Files): cumulative 0, interval 0
AddFile(L0 Files): cumulative 0, interval 0
AddFile(Keys): cumulative 0, interval 0
Cumulative compaction: 33.37 GB write, 443.60 MB/s write, 12.68 GB read, 168.62 MB/s read, 161.9 seconds
Interval compaction: 32.35 GB write, 459.95 MB/s write, 11.97 GB read, 170.20 MB/s read, 158.2 seconds
Stalls(count): 0 level0_slowdown, 0 level0_slowdown_with_compaction, 0 level0_numfiles, 0 level0_numfiles_with_compaction, 0 stop for pending_compaction_bytes, 0 slowdown for pending_compaction_bytes, 0 memtable_compaction, 0 memtable_slowdown, interval 0 total count

Steps to reproduce the behavior

My TerarkDB branch is dev.1.4 and WITH_ZENFS=ON.Using ZNS SSD storing data

skyzh commented 2 years ago

The stats only count key SSTs. You may disable KV separation by making blob ratio larger.

skyzh commented 2 years ago

Hi @lovers-under-moon , if you don't have further questions, I'll close this issue. Hope my answer helps! Feel free to reopen it when you need to.