Skip to content

os/bluestore: support RocksDB prefetch in buffered read mode - #27782

Merged
liewegas merged 6 commits into
ceph:masterfrom
ifed01:wip-ifed-kv-prefetch
May 10, 2019
Merged

liewegas merged 6 commits into
ceph:masterfrom
ifed01:wip-ifed-kv-prefetch

Conversation

@ifed01

@ifed01 ifed01 commented Apr 25, 2019 •

Copy link
Copy Markdown
Contributor

RocksDB needs Prefetch method implementation in BlueRocksEnv class to perform read ahead for buffered reads (i.e. when use_direct_reads = false).
The regular call sequence from RocksDB to perform read-ahead is:
Prefetch()
Read (random)
Read (random)
Read (random)
Prefetch()
Read (random)
...

Implementing Prefetch via BlueFS::_read call to propagate reader's buffer.
And extend BlueFS::_read_random to use this buffer.

Here are some statistics showing the improvement. The following command has been executed using the same store but different code base. This store contains known-to-cause-slow-omap-enumeration object:
ceph-objectstore-tool --data-path /mnt/ceph --pgid 7.24 10000609512.00000000 list-omap --no-mon-config

Original luminous HEAD:
Total execution time: 99 seconds

Luminous + my Read-Ahead implementations (see #24861):
Total execution time: 33 seconds

Master branch (as of May 2 2019):
Total execution time: 54 seconds
Embedded slow op detector (which is pure listing duration without tool startup overhead): 46 seconds

Master branch + my Read-Ahead implementation ( #24861):
Total execution time: 30 seconds
Embedded slow op detector: 22 seconds

Master branch + RocksDB prefetch and backed by this PR:
Total execution time: 32 seconds
Embedded slow op detector: 22 seconds

Improves: http://tracker.ceph.com/issues/36482
Signed-off-by: Igor Fedotov [email protected]

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

@ifed01

ifed01 commented May 2, 2019

Copy link
Copy Markdown
Contributor Author

And here are some hit/miss/disk access statistics for both RocksDB prefetch and my Read-Ahead. Unfortunately they aren't directly comparable.

Master branch + RocksDB prefetch and backed by this PR:
prefetch reads (disk reads):
"read_prefetch_count": 17218,
"read_prefetch_bytes": 4548859645
total random reads:
"read_random_count": 1050195,
"read_random_bytes": 4128560737,
miss count (disk reads):
"read_random_disk_count": 25823,
"read_random_disk_bytes": 195723557,
hit count:
"read_random_buffer_count": 1024394,
"read_random_buffer_bytes": 3932837180,
disk reads:
"read_prefetch_count": 17218 + "read_random_disk_count": 25823 = 43041
"read_prefetch_bytes": 4548859645 + "read_random_disk_bytes": 195723557 = 4744583202

Master branch + my Read-Ahead implementation
total random reads:
"read_random_count": 1046529,
"read_random_bytes": 4022834940,
hit count:
"read_random_buffer_count": 1046438,
"read_random_buffer_bytes": 3904812557
miss count:
"read_random_count": 1046529 - "read_random_buffer_count": 1046438 = 91
"read_random_bytes": 4022834940 - "read_random_buffer_bytes": 3904812557 = 118022383
disk reads:
"read_random_disk_count": 61402,
"read_random_disk_bytes": 4024029184,

@ifed01
ifed01 requested review from liewegas and markhpc May 2, 2019 14:25
@liewegas

liewegas commented May 6, 2019

Copy link
Copy Markdown
Member
2019-05-02T23:21:14.680 INFO:tasks.ceph.osd.8.smithi122.stderr:*** Caught signal (Segmentation fault) **
2019-05-02T23:21:14.681 INFO:tasks.ceph.osd.8.smithi122.stderr: in thread 7f38adb31700 thread_name:tp_osd_tp
2019-05-02T23:21:14.681 INFO:tasks.ceph.osd.8.smithi122.stderr:/build/ceph-15.0.0-981-g96be1a9/src/common/buffer.cc: In function 'char* ceph::buffer::v14_2_0::ptr::c_str()' thread 7f38b0b37700 time 2019-05-02 23:21:14.682224
2019-05-02T23:21:14.681 INFO:tasks.ceph.osd.8.smithi122.stderr:/build/ceph-15.0.0-981-g96be1a9/src/common/buffer.cc: 525: FAILED ceph_assert(_raw)
2019-05-02T23:21:14.682 INFO:tasks.ceph.osd.4.smithi088.stderr:/build/ceph-15.0.0-981-g96be1a9/src/common/buffer.cc: In function 'char* ceph::buffer::v14_2_0::ptr::c_str()' thread 7f042ff81700 time 2019-05-02 23:21:14.682947
2019-05-02T23:21:14.682 INFO:tasks.ceph.osd.4.smithi088.stderr:/build/ceph-15.0.0-981-g96be1a9/src/common/buffer.cc: 525: FAILED ceph_assert(_raw)
2019-05-02T23:21:14.683 INFO:tasks.ceph.osd.4.smithi088.stderr:/build/ceph-15.0.0-981-g96be1a9/src/common/buffer.cc: In function 'char* ceph::buffer::v14_2_0::ptr::c_str()' thread 7f0430782700 time 2019-05-02 23:21:14.684476
2019-05-02T23:21:14.683 INFO:tasks.ceph.osd.4.smithi088.stderr:/build/ceph-15.0.0-981-g96be1a9/src/common/buffer.cc: 525: FAILED ceph_assert(_raw)
2019-05-02T23:21:14.695 INFO:tasks.ceph.osd.4.smithi088.stderr:/build/ceph-15.0.0-981-g96be1a9/src/common/buffer.cc: In function 'void ceph::buffer::v14_2_0::ptr::copy_in(unsigned int, unsigned int, const char*, bool)' thread 7f0431f85700 time 2019-05-02 23:21:14.
694181
2019-05-02T23:21:14.695 INFO:tasks.ceph.osd.4.smithi088.stderr:/build/ceph-15.0.0-981-g96be1a9/src/common/buffer.cc: 628: FAILED ceph_assert(o+l <= _len)
2019-05-02T23:21:14.696 INFO:tasks.ceph.osd.8.smithi122.stderr:/build/ceph-15.0.0-981-g96be1a9/src/common/buffer.cc: In function 'char* ceph::buffer::v14_2_0::ptr::c_str()' thread 7f38afb35700 time 2019-05-02 23:21:14.693052
2019-05-02T23:21:14.696 INFO:tasks.ceph.osd.8.smithi122.stderr:/build/ceph-15.0.0-981-g96be1a9/src/common/buffer.cc: 525: FAILED ceph_assert(_raw)
2019-05-02T23:21:14.708 INFO:tasks.ceph.osd.4.smithi088.stderr: ceph version 15.0.0-981-g96be1a9 (96be1a99d6ab25101f9eddc475990d8d6e207a91) octopus (dev)
2019-05-02T23:21:14.708 INFO:tasks.ceph.osd.4.smithi088.stderr: 1: (ceph::__ceph_assert_fail(char const*, char const*, int, char const*)+0x152) [0x84535e]
2019-05-02T23:21:14.708 INFO:tasks.ceph.osd.4.smithi088.stderr: 2: (ceph::__ceph_assertf_fail(char const*, char const*, int, char const*, char const*, ...)+0) [0x845539]
2019-05-02T23:21:14.708 INFO:tasks.ceph.osd.4.smithi088.stderr: 3: (ceph::buffer::v14_2_0::ptr::end_c_str() const+0) [0x1159510]
2019-05-02T23:21:14.708 INFO:tasks.ceph.osd.4.smithi088.stderr: 4: (ceph::buffer::v14_2_0::list::rebuild(std::unique_ptr<ceph::buffer::v14_2_0::ptr_node, ceph::buffer::v14_2_0::ptr_node::disposer>)+0x48) [0x115b2a8]
2019-05-02T23:21:14.709 INFO:tasks.ceph.osd.4.smithi088.stderr: 5: (ceph::buffer::v14_2_0::list::rebuild()+0xdf) [0x115db9f]
2019-05-02T23:21:14.709 INFO:tasks.ceph.osd.4.smithi088.stderr: 6: (ceph::buffer::v14_2_0::list::c_str()+0x17) [0x115dc87]
2019-05-02T23:21:14.709 INFO:tasks.ceph.osd.4.smithi088.stderr: 7: (BlueFS::_read_random(BlueFS::FileReader*, unsigned long, unsigned long, char*)+0x165) [0xf26075]
2019-05-02T23:21:14.709 INFO:tasks.ceph.osd.4.smithi088.stderr: 8: (BlueRocksRandomAccessFile::Read(unsigned long, unsigned long, rocksdb::Slice*, char*) const+0x20) [0xf53530]
2019-05-02T23:21:14.709 INFO:tasks.ceph.osd.4.smithi088.stderr: 9: (rocksdb::RandomAccessFileReader::Read(unsigned long, unsigned long, rocksdb::Slice*, char*) const+0x988) [0x1551d28]
2019-05-02T23:21:14.709 INFO:tasks.ceph.osd.4.smithi088.stderr: 10: (rocksdb::BlockFetcher::ReadBlockContents()+0x432) [0x15088f2]
2019-05-02T23:21:14.709 INFO:tasks.ceph.osd.4.smithi088.stderr: 11: ceph-osd() [0x14f3b43]
2019-05-02T23:21:14.710 INFO:tasks.ceph.osd.4.smithi088.stderr: 12: (rocksdb::BlockBasedTable::MaybeLoadDataBlockToCache(rocksdb::FilePrefetchBuffer*, rocksdb::BlockBasedTable::Rep*, rocksdb::ReadOptions const&, rocksdb::BlockHandle const&, rocksdb::Slice, rocksdb::BlockBasedTable::CachableEntry<rocksdb::Block>*, bool, rocksdb::GetContext*)+0x32e) [0x14f61de]

/a/sage-2019-05-02_21:28:34-rados-wip-sage-testing-2019-05-02-0940-distro-basic-smithi/3919397

there were a couple other bulestore changes in the batch, but i'm guessing it's this one

@ifed01
ifed01 force-pushed the wip-ifed-kv-prefetch branch from c82cdee to 4f89409 Compare May 9, 2019 16:20
Now this buffer might be accessed from BlueRocksRandomAccessFile
which is intended for multi-threading access. Hence we need a
proper protection for the buffer.

Signed-off-by: Igor Fedotov <[email protected]>
@ifed01

ifed01 commented May 9, 2019

Copy link
Copy Markdown
Contributor Author

@liewegas - I think it lacked multi-threading protection as BlueRocksRandomAccessFile might be used this way. Added another commit to fix that, please take a look.

@ifed01 ifed01 added the needs-qa label May 9, 2019
@liewegas
liewegas merged commit 0543559 into ceph:master May 10, 2019
liewegas added a commit that referenced this pull request May 10, 2019
* refs/pull/27782/head:
	os/bluestore: protect BlueFS::FileReader::buf
	os/bluestore: log 'buffered' in KernelDevice::read_random
	os/bluestore: support RocksDB prefetching at BlueFS
	os/bluestore: call BlueFS::_init_logger earlier.
	tools/ceph-objectstore-tool: dump perf counters on competion.
	os/bluestore: optimize mapping offset to extent in BlueFS.

Reviewed-by: Sage Weil <[email protected]>
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.

2 participants