Skip to content

os/bluestore: faster bluefs allocations in avl/hybrid allocators - #48640

Closed
ifed01 wants to merge 2 commits into
ceph:mainfrom
ifed01:wip-ifed-faster-avl
Closed

ifed01 wants to merge 2 commits into
ceph:mainfrom
ifed01:wip-ifed-faster-avl

Conversation

@ifed01

@ifed01 ifed01 commented Oct 27, 2022 •

Copy link
Copy Markdown
Contributor

When operating in best-fit mode allocator performs chunk lookups through size-sorted "range_size_tree" container. This is done in two stages:

  1. Use container's lower_bound() to search for the first available
    long enough chunk.
  2. Iterate sequentially to locate properly aligned chunk,
    starting from the position obtained at step 1)

Step 2) might require significant efforts for bluefs allocations (which uses longer allocation unit than bluestore min_alloc_size, e.g. 64K vs. 4K) if space is highly fragmented. Plenty of potentially available chunks might be unaligned to 64K boundary and once aligned they aren't long enough any more.
Hence the proposed solution is to prepend original sorting key (full_size + offset) with "aligned" chunk size. Hence range_size_tree will group chunks using bluefs aligned sizes and then sort them within each group using full size + chunk offset. E.g. chunks will be sorted in the following manner for bluefs and bluestore alloc sizes equal to 0x10000 and 0x1000 respectively

...
0x200000~10000
0x210000~10000
0x10f000~10000
0x15f000~10000
0x12f000~11000
0x38000~18000
...
0x0~20000
0x400000~20000
0x501000~21000
0x101000~22000
0x601000~22000
...

Fixes: https://tracker.ceph.com/issues/62815
Signed-off-by: Igor Fedotov [email protected]

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • 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 cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@tchaikov

Copy link
Copy Markdown
Contributor

jenkins test make check

@ifed01
ifed01 force-pushed the wip-ifed-faster-avl branch 2 times, most recently from a9dc532 to 5e05898 Compare October 27, 2022 13:18
@aclamk

aclamk commented Oct 27, 2022

Copy link
Copy Markdown
Contributor

I like the idea, but I am skeptical if it can work.
I always believed that if we have a sorted container M "map" and relation R on keys to this map,
then this relation R determines how we organize data internally.
We then need to use exactly this relation R to properly find elements.
If replace R with R1 for searching we might not find something that is actually is present in M.

Is boost::intrusive::avl_set immune to this behaviour?

@ifed01

ifed01 commented Oct 27, 2022

Copy link
Copy Markdown
Contributor Author

I like the idea, but I am skeptical if it can work. I always believed that if we have a sorted container M "map" and relation R on keys to this map, then this relation R determines how we organize data internally. We then need to use exactly this relation R to properly find elements. If replace R with R1 for searching we might not find something that is actually is present in M.

Is boost::intrusive::avl_set immune to this behaviour?

Hi Adam. May be I'm missing something your comment but the idea is that I switch to different sorting order (R1) completely. So R isn't in use any more. And R1 is
<align(end) - align(start), e - s, s> while R was just <e - s, s>

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

When operating in best-fit mode allocator performs chunk lookups
through size-sorted "range_size_tree" container. This is done in
two stages:
1) Use container's lower_bound() to search for the first available
   long enough chunk.
2) Iterate sequentially to locate properly aligned chunk,
   starting from the position obtained at step 1)
Step 2) might require significant efforts for bluefs allocations (which
uses longer allocation unit than bluestore min_alloc_size, e.g. 64K vs. 4K)
if space is highly fragmented. Plenty of potentially available chunks might
be unaligned to 64K boundary and once aligned they aren't long enough
any more.
Hence the proposed solution is to prepend original sorting key
(full_size + offset) with "aligned" chunk size. Hence range_size_tree
will group chunks using bluefs aligned sizes and then sort
them within each group using full size + chunk offset.
E.g. chunks will be sorted in the following manner for bluefs and
bluestore alloc sizes equal to  0x10000 and 0x1000 respectively

...
0x200000~10000
0x210000~10000
0x10f000~10000
0x15f000~10000
0x12f000~11000
0x38000~18000
...
0x0~20000
0x400000~20000
0x501000~21000
0x101000~22000
0x601000~22000
...

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

ifed01 commented Jan 27, 2023

Copy link
Copy Markdown
Contributor Author

@aclamk @markhpc - ping.

@markhpc

markhpc commented Feb 2, 2023

Copy link
Copy Markdown
Member

@ifed01 sorry, Iv'e been swamped (not a new problem, but the truth). If Adam can't review I will try to do one as soon as I can.

@ifed01

ifed01 commented Jun 2, 2023

Copy link
Copy Markdown
Contributor Author

@markhpc @aclamk - any feedback on this PR?

@markhpc

markhpc commented Jun 8, 2023

Copy link
Copy Markdown
Member

@ifed01 only comment right now is that this looks like it should be reviewable as it's not terribly complex. What do you think about Adam's comment? Can we prove or disprove his concerns through testing?

@ifed01

ifed01 commented Jun 19, 2023

Copy link
Copy Markdown
Contributor Author

@ifed01 only comment right now is that this looks like it should be reviewable as it's not terribly complex. What do you think about Adam's comment? Can we prove or disprove his concerns through testing?

@markhpc - either I didn't get Adam's comment or he didn't get the idea behind the patch :)
As I replayed to Adam the idea is to switch to a differing mapping scheme completely. Hence I don't see any conflicts between R and R1 mapping schemes. @aclamk - please elaborate if you think I'm still missing something...

template<typename KeyType1, typename KeyType2>
bool compare(const KeyType1& lhs, const KeyType2& rhs,
uint64_t unit) const {
if (unit) {

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.

For shorter_t the ordering is:

  1. aligned size
  2. normal size
  3. offset

This has following consequences:
A) when allocating for BlueFS 128K
aligned 128K, normal size 136K (4K pre, 4K post alignment)
has priority over
aligned 128K, normal size 140K (12K pre)
B) when allocating for BlueStore 132K
aligned 64K, normal size 132K (32K pre, 36K post alignment)
will not be found by lower_bound() that is in invoked with range_t{0, 132K, 64K}

I think that A is a just a nuisance, it does not make it worse then baseline.
The B accelerates fragmentation more then in baseline.

@github-actions

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.

@github-actions github-actions Bot added the stale label Aug 26, 2023
@github-actions

github-actions Bot commented Oct 4, 2023

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

github-actions Bot commented Dec 3, 2023

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.

@github-actions github-actions Bot added the stale label Dec 3, 2023
@github-actions

github-actions Bot commented Jan 2, 2024

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions Bot closed this Jan 2, 2024
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