github.com/cockroachdb/pebble@v0.0.0-20231214172447-ab4952c5f87b/internal/batchskl/README.md (about) 1 # batchskl 2 3 Fast, non-concurrent skiplist implementation in Go that supports 4 forward and backward iteration. 5 6 ## Limitations 7 8 * The interface is tailored for use in indexing pebble batches. Keys 9 and values are stored outside of the skiplist making the skiplist 10 awkward for general purpose use. 11 * Deletion is not supported. Instead, higher-level code is expected to 12 add deletion tombstones and needs to process those tombstones 13 appropriately. 14 15 ## Pedigree 16 17 This code is based on Andy Kimball's arenaskl code. 18 19 The arenaskl code is based on the skiplist found in Badger, a Go-based 20 KV store: 21 22 https://github.com/dgraph-io/badger/tree/master/skl 23 24 The skiplist in Badger is itself based on a C++ skiplist built for 25 Facebook's RocksDB: 26 27 https://github.com/facebook/rocksdb/tree/master/memtable 28 29 ## Benchmarks 30 31 The benchmarks consist of a mix of reads and writes executed in parallel. The 32 fraction of reads is indicated in the run name: "frac_X" indicates a run where 33 X percent of the operations are reads. 34 35 ``` 36 name time/op 37 ReadWrite/frac_0 1.03µs ± 2% 38 ReadWrite/frac_10 1.32µs ± 1% 39 ReadWrite/frac_20 1.26µs ± 1% 40 ReadWrite/frac_30 1.18µs ± 1% 41 ReadWrite/frac_40 1.09µs ± 1% 42 ReadWrite/frac_50 987ns ± 2% 43 ReadWrite/frac_60 1.07µs ± 1% 44 ReadWrite/frac_70 909ns ± 1% 45 ReadWrite/frac_80 693ns ± 2% 46 ReadWrite/frac_90 599ns ± 2% 47 ReadWrite/frac_100 45.3ns ± 3% 48 ``` 49 50 Forward and backward iteration are also fast: 51 52 ``` 53 name time/op 54 IterNext 4.49ns ± 3% 55 IterPrev 4.48ns ± 3% 56 ```