Skip to content

kv/RocksDBStore: Add minimum key limit before invoking DeleteRange. - #31442

Merged
liewegas merged 1 commit into
ceph:masterfrom
markhpc:wip-rocksdb-deleterange-keys
Dec 2, 2019
Merged

liewegas merged 1 commit into
ceph:masterfrom
markhpc:wip-rocksdb-deleterange-keys

Conversation

@markhpc

@markhpc markhpc commented Nov 6, 2019 •

Copy link
Copy Markdown
Member

This is a spiritual resurrection of #27317 after the changes were reverted in #15183. It turns out that DeleteRange is still incredibly problematic. Multiple range tombstones will very quickly fragment RocksDB's memtables leading to exceptionally bad RocksDB performance and ultimately extremely slow and resource intensive OSDs. This PR works the same way as #27317 by creating a threshold where N (1024 by default) keys must be deleted at once before DeleteRange is invoked.

An easy to reproduce test that showcases this behavior is to create 10000 RGW buckets, then immediately delete them. Optionally a subsequent workload can be immediately invoked to showcase that performance continues to suffer in general until a memtable flush is invoked.

hsbench -b 10000 -d -1 -m ixi -n 1 -t 128 -z 4K -s <secret> -a <access> -u http://127.0.0.1:7480

Creating 10000 buckets is relatively fast in both cases...

master wip-kv-deleterange-keys
Duration (seconds) 3.04 3.09
Buckets/Second 3290.77 3239
Avg Latency (ms) 38.53 39.2
99% Latency (ms) 65.84 60.94
Max Latency (ms) 127.14 104.96

...However deleting 10000 buckets is roughly 67 times slower when DeleteRange is used... (Note: this is across multiple DeleteRange calls rather than a single call based on bucket deletion works)

master wip-kv-deleterange-keys
Duration (seconds) 675.39 9.42
Buckets/Second 14.81 1061.83
Avg Latency (ms) 8600.9 120.12
99% Latency (ms) 33540.28 150.14
Max Latency (ms) 50655 171.89

...Worse, after many RangeTombstones are placed in the memtable subsequent operations are also slow until the memtable is flushed. Creating 10000 new buckets in master is now 144 times slower...

master wip-kv-deleterange-keys
Duration (seconds) 444.97 3.1
Buckets/Second 22.47 3228.76
Avg Latency (ms) 5672.44 39.45
99% Latency (ms) 11055.03 67.43
Max Latency (ms) 13682.59 87.4

...And even worse, the OSD will consume massive amounts of CPU when this is happening. Deleting 10000 buckets used ~10 cores for 675 seconds on master and ~2-3 cores for 9 seconds with this PR applied. The reason for this is that DeleteRange induced fragmentation in the memtables causes a huge amount of iterator overhead as can be seen by a wallclock profile of the TP_OSD_TP threads:

+ 41.72% rocksdb::DBImpl::NewInternalIterator
  + 41.72% rocksdb::MemTable::NewRangeTombstoneIterator
    + 41.72% std::make_shared<rocksdb::FragmentedRangeTombstoneList, std::unique_ptr<rocksdb::InternalIteratorBase<rocksdb::Slice>, std::default_delete<rocksdb::InternalIteratorBase<rocksdb::Slice> > >, rocksdb::InternalKeyComparator const&>

This PR fixes the current issue by essentially never or rarely invoking DeleteRange. If we start using it more often again in the future (say by regularly deleting >1024 keys at once) we will also need to flush the memtables after concurrent DeleteRange calls to avoid fragmentation.

Signed-off-by: Mark Nelson [email protected]

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard backend
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@cbodley cbodley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @markhpc, i think this is a reasonable compromise until rocksdb improves on its design here

@jdurgin

jdurgin commented Nov 7, 2019

Copy link
Copy Markdown
Member

How is the behavior with objects with >1024 keys?

Comment thread src/kv/RocksDBStore.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just twiddling the in-memory transaction/WriteBatch, right? it's not creating a snapshot view on the db?

@liewegas

liewegas commented Nov 7, 2019

Copy link
Copy Markdown
Member

credit @Aran85 in the commit message?

@markhpc
markhpc force-pushed the wip-rocksdb-deleterange-keys branch from bad2ae4 to b493e96 Compare November 7, 2019 17:31
@markhpc

markhpc commented Nov 7, 2019

Copy link
Copy Markdown
Member Author

credit @Aran85 in the commit message?

Yes absolutely! I added a "co-authored-by" line with @Aran85's email address.

neha-ojha added a commit to neha-ojha/ceph that referenced this pull request Nov 14, 2019
This reverts commit 29bafe5.

We have observed drastically poor performance when rocksdb_rmrange is
used for every key deletion.

This change is specific to nautilus, since we are experimenting with rocksdb_rmrange
along with ceph#31442 in master.

Signed-off-by: Neha Ojha <[email protected]>
liewegas added a commit that referenced this pull request Dec 2, 2019
* refs/pull/31442/head:
	kv/RocksDBStore: Add minimum key limit before invoking DeleteRange.

Reviewed-by: Sage Weil <[email protected]>
Reviewed-by: Casey Bodley <[email protected]>
@liewegas
liewegas merged commit b493e96 into ceph:master Dec 2, 2019
alfonsomthd pushed a commit to rhcs-dashboard/ceph that referenced this pull request Dec 13, 2019
This reverts commit 29bafe5.

We have observed drastically poor performance when rocksdb_rmrange is
used for every key deletion.

This change is specific to nautilus, since we are experimenting with rocksdb_rmrange
along with ceph#31442 in master.

Signed-off-by: Neha Ojha <[email protected]>
(cherry picked from commit 8758697)

Resolves: rhbz#1773137
@vumrao

vumrao commented Jan 30, 2020

Copy link
Copy Markdown
Contributor

nautilus backport - #30949

@clwluvw

clwluvw commented Mar 17, 2025

Copy link
Copy Markdown
Member

Hi @markhpc - Can the bench described in this PR still be valid for testing https://tracker.ceph.com/issues/70108?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants