Skip to content

[RFC] os/bluestore: optimize BlueFS reads - #24861

Closed
ifed01 wants to merge 5 commits into
ceph:masterfrom
ifed01:wip-ifed-bluefs-ra
Closed

ifed01 wants to merge 5 commits into
ceph:masterfrom
ifed01:wip-ifed-bluefs-ra

Conversation

@ifed01

@ifed01 ifed01 commented Oct 31, 2018 •

Copy link
Copy Markdown
Contributor

This is an intermediate result for an attempt to improve BlueFS read performance.
It includes 2 major fixes:

  1. Eliminate sequential lookup over fnode's bluefs extents. This list might be quite long (I could see 100+ items per fnode from time to time).
  2. Try to do some prefetch for "semi-random" reads. Quite often one can see sequential reads using small (and unaligned to block size) chunks. This patch introduces simple sequence detection and read prefetch mechanics similar to buffered read implementation in BlueFS::_read()

Unfortunately I don't see any visible performance difference in my (quite limited) benchmark. Perhaps the reason is that BlueFS reads don't impact overall performance that much. Although these "semi-random" patterns are quite observable.

And it seems that introduced performance counters show inappropriate numbers (maybe concurrency issue?). Which I'll investigate anyway.

Wondering if this work in general deserves any prolongation?

Signed-off-by: Igor Fedotov [email protected]

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

Comment thread src/os/bluestore/bluefs_types.h 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.

a comment indicating what teh values mean?

Comment thread src/os/bluestore/bluefs_types.h 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.

wouldn't this also adjust all of the extents_index values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, indeed. Will fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment thread src/os/bluestore/BlueRocksEnv.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.

i think this will be ambiguous in the SEEQUENTIAL, WILLNEED, WONTNEED cases.. I think only call _got_hint for RANDOM and SEQUENTIAL

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, thanks. Missed that there are more than 2 hint values

Comment thread src/os/bluestore/BlueFS.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.

whitespace

Comment thread src/os/bluestore/BlueFS.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.

dead code

Comment thread src/os/bluestore/BlueFS.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.

i'm having trouble following what the bheavior here is supposed to be here.. there is track_read that remembers the previous sequence, and then this here that indicates whether the current recently is more than 2 sequential reads. Is the idea that if you do _buffered here, then the OS-level prefetching will kick in?

@ifed01 ifed01 Oct 31, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

track_read increments active sequence counter if sequence is in progress and resets it on sequence termination (and returns true to indicate the end and memorize prev sequence to be able to dump it). While sequence is in progress (3+ hits occurred) we can read longer chunks and buffer them and use previously buffered data, all this stuff is handled within _ read_random_buffered().

@ifed01
ifed01 force-pushed the wip-ifed-bluefs-ra branch from c6cee1a to ad592a8 Compare October 31, 2018 21:55
@stale

stale Bot commented Dec 31, 2018

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you are a maintainer or core committer, please follow-up on this issue to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@stale stale Bot added the stale label Dec 31, 2018
@ifed01
ifed01 force-pushed the wip-ifed-bluefs-ra branch from ad592a8 to 6fe1daf Compare February 28, 2019 14:15
@stale stale Bot removed the stale label Feb 28, 2019
@ifed01
ifed01 force-pushed the wip-ifed-bluefs-ra branch from cf4c75d to 475d065 Compare March 1, 2019 12:08
@ifed01
ifed01 force-pushed the wip-ifed-bluefs-ra branch from 475d065 to 907a4f8 Compare March 5, 2019 18:00
@ifed01

ifed01 commented Mar 19, 2019

Copy link
Copy Markdown
Contributor Author

Some observations we've got attempting this patch during debug session at production cluster facing slow omap key enumeration.
Without the patch 'ceph-objectstore-tool list-omap' takes 1min 52s - 2 min to complete for 'broken' object and 8-10 seconds for arbitrary selected "good" one.
After applying the patch and using default bluefs prefetch settings (3 sequential requests to initiate the prefetching and 64K max prefetch size) the command for 'broken' object takes 39 seconds.
Increasing max prefetch size to 512K reduced duration to 35 seconds, further increasing has either negative or no effect.
Some read stats collected for omap enumeration for the broken object using new prefetching approach:
(default settings, i.e. max_prefetch_size = 64K)
"read_random_count": 1116939, - amount of read_random requests from RocksDB
"read_random_bytes": 4297025184, - total amount read in bytes
"read_random_disk_count": 65587, - amount of disk read requests
"read_random_disk_bytes": 4298309632, - totally bytes read from disks
"read_random_buffer_count": 1116838, - read requests served from the buffer thanks to prefetching
"bluefs_read_random_buffer_bytes": 4170842522 - totally bytes read from buffer

(max_prefetch_size = 128K)
"read_random_count": 1116940,
"read_random_bytes": 4297033467,
"read_random_disk_count": 32802,
"read_random_disk_bytes": 4299411456,
"read_random_buffer_count": 1116851,
"bluefs_read_random_buffer_bytes": 4233632561

One can see pretty large amount of read requests needed to process single object omap listing with just two records.
IMO proposed prefetching is quite beneficial but probably it's still not enough to eliminate the issue completely. Most probably the root cause is ineffective data layout at RocskDB resulting in a huge amount of small read requests to Bluefs.

@ifed01

ifed01 commented Mar 19, 2019

Copy link
Copy Markdown
Contributor Author

Here is per-ino sequential read stats we collected:
(Columns: ino, sequential req count , sequence length in bytes, average read size)
ino 56061 16, 66914, 4182.12
ino 56064 3363, 13699986, 4073.74
ino 56065 8, 66180, 8272.5
ino 55915 204, 815661, 3998.34
ino 47652 3644, 14828955, 4069.42
ino 47499 2722, 11087267, 4073.21
ino 56002 9, 297062, 33006.9
ino 56073 16717, 67110981, 4014.53
ino 56074 13603, 54641428, 4016.87
ino 56075 16708, 67112039, 4016.76
ino 56076 16707, 67110253, 4016.89
ino 56077 15087, 60603258, 4016.92
ino 56078 16709, 67111301, 4016.48
ino 56079 16716, 67109333, 4014.68
ino 56080 8546, 34328191, 4016.87
ino 47947 1551, 6125354, 3949.29
ino 11821 3278, 13318531, 4063.01
ino 56083 6538, 24976501, 3820.21
ino 56084 7083, 27034736, 3816.85
ino 49635 17529, 67112958, 3828.68
ino 49720 17573, 67110887, 3818.98
ino 49721 17485, 67110116, 3838.15
ino 49722 17433, 67110077, 3849.6
ino 54228 17543, 67110135, 3825.47
ino 54229 7705, 29528152, 3832.34
ino 50849 17598, 67113086, 3813.68
ino 54185 12815, 49023074, 3825.44
ino 50112 17575, 67109463, 3818.46
ino 50569 17542, 67110600, 3825.71
ino 50154 17592, 67113293, 3814.99
ino 49789 17571, 67111621, 3819.45
ino 49791 17541, 67112269, 3826.02
ino 49790 17563, 67111367, 3821.18
ino 50005 17550, 67111639, 3824.03
ino 54227 12883, 49277615, 3825.01
ino 55849 698, 2656061, 3805.24
ino 51308 17544, 67110282, 3825.26
ino 51309 17549, 67110914, 3824.2
ino 51310 17578, 67110009, 3817.84
ino 51311 17620, 67110998, 3808.8
ino 51840 17532, 67110283, 3827.87
ino 51841 17592, 67110710, 3814.84
ino 51842 17555, 67112954, 3823.01
ino 51265 17533, 67111178, 3827.71
ino 55946 8303, 31703117, 3818.27
ino 51724 17528, 67112740, 3828.89
ino 51727 17574, 67112949, 3818.88
ino 51725 17564, 67112621, 3821.03
ino 53196 17577, 67111721, 3818.16
ino 51766 17545, 67111595, 3825.11
ino 53280 17515, 67109717, 3831.56
ino 51771 17589, 67112866, 3815.62
ino 55841 16412, 62626969, 3815.93
ino 52615 17490, 67110340, 3837.07
ino 52616 17531, 67110429, 3828.1
ino 52564 17555, 67110932, 3822.9
ino 52565 17553, 67110959, 3823.33
ino 52566 17566, 67109336, 3820.41
ino 52567 17567, 67112892, 3820.4
ino 55626 13059, 49735518, 3808.52
ino 55842 2956, 11244482, 3803.95
ino 52669 17571, 67109584, 3819.34
ino 52670 17576, 67109934, 3818.27
ino 52706 17557, 67110877, 3822.46
ino 52708 17571, 67111985, 3819.47
ino 52705 17552, 67112912, 3823.66
ino 52707 17575, 67110050, 3818.5
ino 55731 12275, 47056935, 3833.56
ino 55840 12916, 49492881, 3831.9
ino 52905 17550, 67110067, 3823.94
ino 52906 17609, 67110339, 3811.14
ino 52907 17547, 67109684, 3824.57
ino 52908 17573, 67111460, 3819.01
ino 52888 17579, 67112251, 3817.75
ino 52889 17403, 67112209, 3856.36
ino 55839 12763, 48807479, 3824.14
ino 52976 17576, 67109771, 3818.26
ino 52977 17572, 67109737, 3819.13
ino 55820 12513, 47868185, 3825.48

@liewegas

Copy link
Copy Markdown
Member

My understanding is that latest rocksdb master already implements readahead, so this PR is only relevant for luminous + mimic, right? If that' s the case, then this looks great and should be sufficient to mitigate the problem for those stable releases. Or do you think we should keep this in master, too?

@ifed01

ifed01 commented Mar 19, 2019

Copy link
Copy Markdown
Contributor Author

My understanding is that latest rocksdb master already implements readahead, so this PR is only relevant for luminous + mimic, right? If that' s the case, then this looks great and should be sufficient to mitigate the problem for those stable releases. Or do you think we should keep this in master, too?
That's an interesting question which I don't have answer for. Definitely RocksDB embedded Read-Ahead is preferred. Perhaps it will show better results as it might reduce BlueFS call count significantly. Unfortunately we don't have any real numbers to make a decision yet.

I'll try to arrange next debug session to verify the same case against Nautilus code base and share the results if any.

@markhpc

markhpc commented Mar 28, 2019 •

Copy link
Copy Markdown
Member

@liewegas Latest rocksdb does do iterator readahead (I believe older versions should do compaction readahead and we do make use of it). I'm not sure if we should consider backporting the latest release given some of the issues we've had in the past, but the performance gain with iterator readahead can be significant for us in some circumstances from what I recall when I looked into it.

@stale

stale Bot commented May 27, 2019

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@stale stale Bot added the stale label May 27, 2019
@stale stale Bot removed the stale label Jun 27, 2019
@liewegas liewegas closed this Jul 25, 2019
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.

4 participants