首先介绍前置工作。
¶ 缩写
缩写 | 全称 |
---|---|
FPR | false positive rate |
¶ 符号
符号 | 含义 | 单位 |
---|---|---|
N | total data size | blocks |
F | buffer size | blocks |
L | number of levels | |
M | 所有bloom filter的平均bits per bit | bits |
p | sum of FPRs across all Bloom filters | |
Bloom filter FPR at Level |
||
T | base capacity ratio | |
X | ratio growth exponential |
¶ Bloom filter
假设bits per entry是
假如FPR是p,那么bits per entry就是
¶ Monkey
论文:https://dl.acm.org/doi/pdf/10.1145/3035918.3064054
假设总的FPR是
然而bloom filter的FPR是随bit数
假设
假设是leveling策略,那么第一层的bits per entry就是
假设
平均bits per entry
我们来代入数字检查一下:
from math import *
= 10
T = 4
L = 0.01
p = log((T**L - 1) / ((T-1)*p)) / log(2)**2 - log(T) / log(2)**2 * \
M -1)*(T-1)*T**L - T**L + T) / \
((L**L - 1) * (T-1))
((Tprint('Average bits per entry: %f\n' %M)
= log((T**L - 1) / ((T-1)*p)) / log(2)**2
M1 = M1
Mi = 1
i = 0
M = 0
data = 0
p while True:
+= Mi * T ** (i-1)
M += T ** (i-1)
data = exp(-Mi * log(2)**2)
p_i += p_i
p print('Level %d, bits per entry: %f, false positive rate: %f' %(i, Mi, p_i))
if i == L:
break
+= 1
i -= log(T) / log(2)**2
Mi /= data
M print('Average bits per entry: %f' %M)
print('Overall false positive rate: %f' %p)
Average bits per entry: 10.334730
Level 1, bits per entry: 24.181732, false positive rate: 0.000009
Level 2, bits per entry: 19.389203, false positive rate: 0.000090
Level 3, bits per entry: 14.596674, false positive rate: 0.000900
Level 4, bits per entry: 9.804144, false positive rate: 0.009001
Average bits per entry: 10.334730
Overall false positive rate: 0.010000
而传统方法
/ p) / log(2)**2 log(L
12.470448459145366
¶ Dostoevsky
论文:https://dl.acm.org/doi/pdf/10.1145/3183713.3196927
大多数数据都在最后一层,因此大多数query都落在最后一层,但是每层产生的compaction I/O都是一样多的。因此将前面的层用tiering做compaction,有T个sorted run,最后一层用leveling,只有一个sorted run。这种策略叫做lazy leveling。
跟monkey一样,将总的FPR
¶ LSM-bush
论文:https://dl.acm.org/doi/pdf/10.1145/3299869.3319903
我们可以发现,增加某层的sorted run个数时,这一层的bits per entry是对数增大的,然而由于每层的数据量是指数增大的,所以增加上面的层的sorted run个数对平均bits per entry影响很小,而且还可以降低写放大。因此我们考虑从底层到最上层让sorted run个数指数增大。
假设最后一层的size ratio是C,那么写放大等于
论文里给出的point read的I/O复杂度是