Repository navigation
os/bluestore: implement get_free_extents - #69039
Naveenaidu merged 12 commits into
Conversation
644a71b to
73c4383
Compare
adb572a to
ff2f690
Compare
5dcb735 to
e2ba1a2
Compare
cafbf4f to
b5cb34b
Compare
505a7a7 to
171ad20
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
171ad20 to
9148846
Compare
30cf4b2 to
d6e5b84
Compare
| * - cursor >= range_end: the window is fully enumerated, stop. | ||
| * - cursor < range_end: pass it as range_begin to resume. The cursor is a | ||
| * valid resume point but is NOT guaranteed to land on a free extent; it | ||
| * may point into allocated space. An extra call that returns zero extents |
There was a problem hiding this comment.
An extra call that returns zero extents
and advances cursor to range_end is possible when max_count is reached
exactly at the last free extent in the window.
I don't get it.
There was a problem hiding this comment.
The cursor is a
valid resume point but is NOT guaranteed to land on a free extent; it
may point into allocated space. An extra call that returns zero extents
and advances cursor to range_end is possible when max_count is reached
exactly at the last free extent in the window.
Is it intended to mean:
The cursor is a
valid resume point but is NOT guaranteed there are any free extent
in range <cursor, range_end).
There was a problem hiding this comment.
yes, that is what I meant.
I wrote it to mean that (more as a note to myself): an implementation is allowed to hit max_count right as it closes the very last free extent in the window, without doing a look ahead to check whether anything follows, in which case the next call would just confirm "nothing left" with an empty batch and cursor snapped to range_end.
In all our current implementations (StupidAllocator, AvlAllocator, Btree2Allocator, BitmapAllocator's get_free_extents_internal) each one does do that lookahead, so none of them actually exercises this path today; they all detect "that was the last extent" and return range_end immediately instead of an extra empty round-trip.
I'll simplify the comment, thanks!
| size_t ci = 0; | ||
| const bool unbounded = (max_count == 0); | ||
| while (((it != range_tree.end() && it->first < range_end) || ci < cached.size()) && | ||
| (unbounded || n < max_count)) { |
There was a problem hiding this comment.
If you add last element to cached {range_end, 1} then ci < cached.size() will be always true.
Another hack. Its up to you if you like it.
| } | ||
|
|
||
| // Fetch up to max_count from each sub-allocator independently. | ||
| // Both return extents sorted by offset; we merge them in O(n+m). |
There was a problem hiding this comment.
I would like to propose a different algorithmic approach.
- take free range from tree -> Astart, Aend
- add range <Astart, Aend> to output
- take next free range from tree -> Bstart, Bend
- ask bitmap for get_free_extents(Aend, Bstart)
- A = B, goto 2
There could be some locks to avoid, but I think it should work. If reentrance cost for bitmap.get_free_extents is not too large, it should be faster.
We care for HybridAllocator performance.
There was a problem hiding this comment.
implemented the approach!
d6e5b84 to
6c8c6bd
Compare
|
jenkins test make check |
|
|
||
| size_t free_count = | ||
| std::min<size_t>(count_1s(pattern, p), p_end - p); | ||
| if (free_count > 0) { |
There was a problem hiding this comment.
free_count == 0 is only achievable if p == p_end at the beginning of the loop.
But there already is a guarantee that lo < ho.
There was a problem hiding this comment.
Sorry do not understand the comment, trying to clarify: were you talking about the case where free_count == 0 also when p == p_end ?
If yes, then I think there is no need to worry about running off the edge of bits while scanning this word because we already have the check of p < p_end even before we check for free_count.
6c8c6bd to
eadba8a
Compare
… allocator Fixes: https://tracker.ceph.com/issues/76420 Signed-off-by: Naveen Naidu <[email protected]>
Add three parameterized tests that exercise get_free_extents through the real allocate()/release() code paths rather than just init_add_free(): - verify free extents don't overlap allocated regions after allocation - verify released extents become visible in the free set after release - verify correct free-set accounting under maximum fragmentation created by allocating all blocks one-by-one and releasing every other one Fixes: https://tracker.ceph.com/issues/76420 Signed-off-by: Naveen Naidu <[email protected]>
AvlAllocator::get_free_extents used lower_bound({range_begin, range_begin})
which skips any free extent that starts before range_begin even if it extends
into the query window. Step back one iterator position before the walk loop
so that straddling extents are found; the existing lo=max(start, range_begin)
clipping already handles trimming the left edge correctly.
Add three adversarial parameterized tests:
- clipping_range_begin: free [0,6b), query [4b,end) must return [4b,2b)
- massive_fragmentation: 5000 alternating free/allocated blocks via cursor walk
- needle_at_end: free space only in the last block of a 10000-block device
Fixes: https://tracker.ceph.com/issues/76420
Signed-off-by: Naveen Naidu <[email protected]>
eadba8a to
6ed9e61
Compare
|
This is an automated message by src/script/redmine-upkeep.py. I have resolved the following tracker ticket due to the merge of this PR: No backports are pending for the ticket. If this is incorrect, please update the tracker |
Tracker: https://tracker.ceph.com/issues/76420
Allocator::foreach()holds the allocator lock for the entire walk over all free extents. On a fragmented OSD this can block for several seconds.BlueStore::MempoolThread::entry()callsAllocator::get_fragmentation_score(), which internally callsforeach()every hour, causing a visible write-latency spike where all OSD writes appear stalled.This PR introduces two new primitives to break the full-walk lock hold into bounded batches.
get_free_extents(range_begin, range_end, max_count, out) → cursor, A ranged, batched enumeration primitive added to theAllocatorinterface as a pure-virtual function. Each call:max_countextents).cursor >= range_end.*outin ascending offset order, clipped to[range_begin, range_end).foreach()when an exact, consistent snapshot is required.Allocator.h.foreach_interruptible(notify)Allocatorthat drivesget_free_extents()in 1024-extent batches over[0, device_size). This is the lock-releasing replacement forforeach()for best-effort consumers.Implementation Status
get_free_extentsis implemented for:AVLAllocatorBTreeAllocatorBitMapAllocatorStupidAllocatorHybridAllocatorBtree2AllocatorTODO (In follow-up PR)
foreach_interruptibleis not yet wired intoMempoolThread/get_fragmentation_score(). That wiring will be done in a follow-up once all allocators are covered or a fallback toforeach()for unsupported allocators is in place.Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.