Commit 272f42d
authored
fix: fallback to normal delete when deleting a small ranges (#644)
### Motivation
In the current implementation, we will get terrible performance for
iterator-related operations when we have many small `DeleteRange`
ranges.
FYI: https://rocksdb.org/blog/2018/11/21/delete-range.html
It will make our `putWithSequence` method execute very slowly. (based on
the current memtable size)
The reason is that the implementation of pebble(rocksDB) will create the
fragmented range deletion tombstones for range deletion. Even Pebble
will cache the tombstones, but it will invalidate when you get a new
delete range operation. Therefore, we need to rebuild the deletion
iterator after the new `DeleteRange` operation. And it will get worse
along with more `DeleteRange` operations.
FYI:
https://github.com/cockroachdb/pebble/blob/dbc1c128682f7efcdb76352432249780b12447f7/mem_table.go#L248-L251
Also, rocksdb
[article](https://rocksdb.org/blog/2018/11/21/delete-range.html) also
mentioned that in `Future Work` section.
### Modification
- To support atomic operation for the user side, we can fallback the
`DeleteRange` operation back to the normal delete if the actual keys are
lower than `DeleteRangeThreshold(default 100)`.
### Next
1. Introduce policies to make `DeleteRangeThreshold` configurable.
2. Introduce policies to configure the memtable size. because the
smaller size can trigger flush and compact the deletion tombstones.
3. other small improvements.1 parent f4a877c commit 272f42d
2 files changed
+85
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
| 596 | + | |
| 597 | + | |
596 | 598 | | |
597 | 599 | | |
598 | 600 | | |
599 | 601 | | |
600 | 602 | | |
601 | | - | |
| 603 | + | |
| 604 | + | |
602 | 605 | | |
603 | 606 | | |
604 | | - | |
605 | | - | |
606 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
607 | 631 | | |
608 | 632 | | |
609 | 633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
0 commit comments