Skip to content

Commit 89ab77c

Browse files
authored
Merge pull request #684 from IntersectMBO/wenkokke/memory-size-alloc-request-fpr
doc: various comments relating to FPR
2 parents de811f1 + 1cb99c7 commit 89ab77c

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,30 @@ The worst-case in-memory size of an LSM-tree is *O*(*n*).
278278

279279
- The worst-case in-memory size of the Bloom filters is *O*(*n*).
280280

281-
The total in-memory size of all Bloom filters depends on the Bloom
281+
The total in-memory size of all Bloom filters is the number of bits
282+
per physical entry multiplied by the number of physical entries. The
283+
required number of bits per physical entry is determined by the Bloom
282284
filter allocation strategy, which is determined by the
283285
`confBloomFilterAlloc` field of `TableConfig`.
284286

285287
`AllocFixed bitsPerPhysicalEntry`
286-
The total in-memory size of all Bloom filters is the number of bits
287-
per physical entry multiplied by the number of physical entries.
288+
The number of bits per physical entry is specified as
289+
`bitsPerPhysicalEntry`.
288290

289291
`AllocRequestFPR requestedFPR`
290-
**TODO**: How does one determine the bloom filter size using
291-
`AllocRequestFPR`?
292+
The number of bits per physical entry is determined by the requested
293+
false-positive rate, which is specified as `requestedFPR`.
294+
295+
The false-positive rate scales exponentially with the number of bits
296+
per entry:
297+
298+
| False-positive rate | Bits per entry |
299+
|---------------------|----------------|
300+
| 1 in 10 |  ≈ 4.77 |
301+
| 1 in 100 |  ≈ 9.85 |
302+
| 1 in 1, 000 |  ≈ 15.79 |
303+
| 1 in 10, 000 |  ≈ 22.58 |
304+
| 1 in 100, 000 |  ≈ 30.22 |
292305

293306
- The worst-case in-memory size of the indexes is *O*(*n*).
294307

lsm-tree.cabal

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,29 @@ description:
139139

140140
* The worst-case in-memory size of the Bloom filters is \(O(n)\).
141141

142-
The total in-memory size of all Bloom filters depends on the Bloom filter allocation strategy, which is determined by the @confBloomFilterAlloc@ field of @TableConfig@.
142+
The total in-memory size of all Bloom filters is the number of bits per physical entry multiplied by the number of physical entries.
143+
The required number of bits per physical entry is determined by the Bloom filter allocation strategy, which is determined by the @confBloomFilterAlloc@ field of @TableConfig@.
143144

144145
[@AllocFixed bitsPerPhysicalEntry@]:
145-
The total in-memory size of all Bloom filters is the number of bits per physical entry multiplied by the number of physical entries.
146+
The number of bits per physical entry is specified as @bitsPerPhysicalEntry@.
146147
[@AllocRequestFPR requestedFPR@]:
147-
__TODO__: How does one determine the bloom filter size using @AllocRequestFPR@?
148+
The number of bits per physical entry is determined by the requested false-positive rate, which is specified as @requestedFPR@.
149+
150+
The false-positive rate scales exponentially with the number of bits per entry:
151+
152+
+---------------------------+---------------------+
153+
| False-positive rate | Bits per entry |
154+
+===========================+=====================+
155+
| \(1\text{ in }10\) | \(\approx 4.77 \) |
156+
+---------------------------+---------------------+
157+
| \(1\text{ in }100\) | \(\approx 9.85 \) |
158+
+---------------------------+---------------------+
159+
| \(1\text{ in }1{,}000\) | \(\approx 15.79 \) |
160+
+---------------------------+---------------------+
161+
| \(1\text{ in }10{,}000\) | \(\approx 22.58 \) |
162+
+---------------------------+---------------------+
163+
| \(1\text{ in }100{,}000\) | \(\approx 30.22 \) |
164+
+---------------------------+---------------------+
148165

149166
* The worst-case in-memory size of the indexes is \(O(n)\).
150167

src/Database/LSMTree/Internal/Config.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ instance NFData TableConfig where
7878
-- | A reasonable default 'TableConfig'.
7979
--
8080
-- This uses a write buffer with up to 20,000 elements and a generous amount of
81-
-- memory for Bloom filters (FPR of 2%).
81+
-- memory for Bloom filters (FPR of 1%).
8282
--
8383
defaultTableConfig :: TableConfig
8484
defaultTableConfig =

0 commit comments

Comments
 (0)