Skip to content

Commit 2096d15

Browse files
committed
fix: expose all data types referenced by LSMTreeTrace
1 parent a1942de commit 2096d15

File tree

3 files changed

+51
-31
lines changed

3 files changed

+51
-31
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,28 +104,28 @@ The documentation provides two measures of complexity:
104104
The complexities are described in terms of the following variables and
105105
constants:
106106

107-
- The variable *n* refers to the number of *physical* table entries. A
107+
- The variable $`n`$ refers to the number of *physical* table entries. A
108108
*physical* table entry is any key–operation pair, e.g., `Insert k v`
109109
or `Delete k`, whereas a *logical* table entry is determined by all
110-
physical entries with the same key. If the variable *n* is used to
110+
physical entries with the same key. If the variable $`n`$ is used to
111111
describe the complexity of an operation that involves multiple tables,
112112
it refers to the sum of all table entries.
113113

114-
- The variable *o* refers to the number of open tables and cursors in
114+
- The variable $`o`$ refers to the number of open tables and cursors in
115115
the session.
116116

117-
- The variable *s* refers to the number of snapshots in the session.
117+
- The variable $`s`$ refers to the number of snapshots in the session.
118118

119-
- The variable *b* usually refers to the size of a batch of
119+
- The variable $`b`$ usually refers to the size of a batch of
120120
inputs/outputs. Its precise meaning is explained for each occurrence.
121121

122-
- The constant *B* refers to the size of the write buffer, which is a
122+
- The constant $`B`$ refers to the size of the write buffer, which is a
123123
configuration parameter.
124124

125-
- The constant *T* refers to the size ratio of the table, which is a
125+
- The constant $`T`$ refers to the size ratio of the table, which is a
126126
configuration parameter.
127127

128-
- The constant *P* refers to the the average number of key–value pairs
128+
- The constant $`P`$ refers to the the average number of key–value pairs
129129
that fit in a page of memory.
130130

131131
#### Disk I/O cost of operations <span id="performance_time" class="anchor"></span>
@@ -273,22 +273,22 @@ schedule is listed as N/A.
273273
</tbody>
274274
</table>
275275

276-
(\*The variable *b* refers to the number of entries retrieved by the
276+
(\*The variable $`b`$ refers to the number of entries retrieved by the
277277
range lookup.)
278278

279279
TODO: Document the average-case behaviour of lookups.
280280

281281
#### In-memory size of tables <span id="performance_size" class="anchor"></span>
282282

283283
The in-memory size of an LSM-tree is described in terms of the variable
284-
*n*, which refers to the number of *physical* database entries. A
284+
$`n`$, which refers to the number of *physical* database entries. A
285285
*physical* database entry is any key–operation pair, e.g., `Insert k v`
286286
or `Delete k`, whereas a *logical* database entry is determined by all
287287
physical entries with the same key.
288288

289-
The worst-case in-memory size of an LSM-tree is *O*(*n*).
289+
The worst-case in-memory size of an LSM-tree is $`O(n)`$.
290290

291-
- The worst-case in-memory size of the write buffer is *O*(*B*).
291+
- The worst-case in-memory size of the write buffer is $`O(B)`$.
292292

293293
The maximum size of the write buffer on the write buffer allocation
294294
strategy, which is determined by the `confWriteBufferAlloc` field of
@@ -299,7 +299,7 @@ The worst-case in-memory size of an LSM-tree is *O*(*n*).
299299
The maximum size of the write buffer is the maximum number of entries
300300
multiplied by the average size of a key–operation pair.
301301

302-
- The worst-case in-memory size of the Bloom filters is *O*(*n*).
302+
- The worst-case in-memory size of the Bloom filters is $`O(n)`$.
303303

304304
The total in-memory size of all Bloom filters is the number of bits
305305
per physical entry multiplied by the number of physical entries. The
@@ -318,15 +318,15 @@ The worst-case in-memory size of an LSM-tree is *O*(*n*).
318318
The false-positive rate scales exponentially with the number of bits
319319
per entry:
320320

321-
| False-positive rate | Bits per entry |
322-
|---------------------|----------------|
323-
| 1 in 10 |  ≈ 4.77 |
324-
| 1 in 100 |  ≈ 9.85 |
325-
| 1 in 1, 000 |  ≈ 15.79 |
326-
| 1 in 10, 000 |  ≈ 22.58 |
327-
| 1 in 100, 000 |  ≈ 30.22 |
321+
| False-positive rate | Bits per entry |
322+
|---------------------------|--------------------|
323+
| $`1\text{ in }10`$ | $`\approx 4.77 `$ |
324+
| $`1\text{ in }100`$ | $`\approx 9.85 `$ |
325+
| $`1\text{ in }1{,}000`$ | $`\approx 15.79 `$ |
326+
| $`1\text{ in }10{,}000`$ | $`\approx 22.58 `$ |
327+
| $`1\text{ in }100{,}000`$ | $`\approx 30.22 `$ |
328328

329-
- The worst-case in-memory size of the indexes is *O*(*n*).
329+
- The worst-case in-memory size of the indexes is $`O(n)`$.
330330

331331
The total in-memory size of all indexes depends on the index type,
332332
which is determined by the `confFencePointerIndex` field of
@@ -346,7 +346,7 @@ The worst-case in-memory size of an LSM-tree is *O*(*n*).
346346
a negligible amount of memory for tie breakers. The total in-memory
347347
size of all indexes is approximately 66 bits per memory page.
348348

349-
The total size of an LSM-tree must not exceed 2<sup>41</sup> physical
349+
The total size of an LSM-tree must not exceed $`2^{41}`$ physical
350350
entries. Violation of this condition *is* checked and will throw a
351351
`TableTooLargeError`.
352352

scripts/generate-readme.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-depends:
77
, pandoc ^>=3.6.4
88
, text >=2.1
99
-}
10-
{-# LANGUAGE LambdaCase #-}
10+
{-# LANGUAGE LambdaCase #-}
1111
{-# LANGUAGE OverloadedStrings #-}
1212

1313
module Main (main) where

src/Database/LSMTree.hs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,6 @@ module Database.LSMTree (
156156
resolveValidOutput,
157157
resolveAssociativity,
158158

159-
-- * Tracer
160-
Tracer,
161-
LSMTreeTrace (..),
162-
TableTrace (..),
163-
CursorTrace (..),
164-
165159
-- * Errors #errors#
166160
SessionDirDoesNotExistError (..),
167161
SessionDirLockedError (..),
@@ -178,6 +172,24 @@ module Database.LSMTree (
178172
BlobRefInvalidError (..),
179173
CursorClosedError (..),
180174
InvalidSnapshotNameError (..),
175+
176+
-- * Traces #traces#
177+
Tracer,
178+
LSMTreeTrace (..),
179+
TableTrace (..),
180+
CursorTrace (..),
181+
MergeTrace (..),
182+
CursorId (..),
183+
TableId (..),
184+
AtLevel (..),
185+
LevelNo (..),
186+
NumEntries (..),
187+
RunNumber (..),
188+
MergePolicyForLevel (..),
189+
LevelMergeType (..),
190+
RunParams (..),
191+
RunDataCaching (..),
192+
IndexType (..),
181193
) where
182194

183195
import Control.Concurrent.Class.MonadMVar.Strict (MonadMVar)
@@ -203,17 +215,25 @@ import qualified Database.LSMTree.Internal.BlobRef as Internal
203215
import Database.LSMTree.Internal.Config
204216
(BloomFilterAlloc (AllocFixed, AllocRequestFPR),
205217
DiskCachePolicy (..), FencePointerIndexType (..),
206-
MergePolicy (..), MergeSchedule (..), SizeRatio (..),
207-
TableConfig (..), WriteBufferAlloc (..),
218+
LevelNo (..), MergePolicy (..), MergeSchedule (..),
219+
SizeRatio (..), TableConfig (..), WriteBufferAlloc (..),
208220
defaultBloomFilterAlloc, defaultTableConfig,
209221
serialiseKeyMinimalSize)
210222
import Database.LSMTree.Internal.Config.Override
211223
(OverrideDiskCachePolicy (..))
224+
import Database.LSMTree.Internal.Entry (NumEntries (..))
212225
import qualified Database.LSMTree.Internal.Entry as Entry
226+
import Database.LSMTree.Internal.Merge (LevelMergeType (..))
227+
import Database.LSMTree.Internal.MergeSchedule (AtLevel (..),
228+
MergePolicyForLevel (..), MergeTrace (..))
213229
import Database.LSMTree.Internal.Paths (SnapshotName,
214230
isValidSnapshotName, toSnapshotName)
215231
import Database.LSMTree.Internal.Range (Range (..))
216232
import Database.LSMTree.Internal.RawBytes (RawBytes (..))
233+
import Database.LSMTree.Internal.RunBuilder (IndexType (..),
234+
RunDataCaching (..), RunParams (..))
235+
import Database.LSMTree.Internal.RunNumber (CursorId (..),
236+
RunNumber (..), TableId (..))
217237
import qualified Database.LSMTree.Internal.Serialise as Internal
218238
import Database.LSMTree.Internal.Serialise.Class (SerialiseKey (..),
219239
SerialiseKeyOrderPreserving, SerialiseValue (..),

0 commit comments

Comments
 (0)