Skip to content

tentacle: osd: Reduce reads when rebalancing healthy Erasure Coded PGs - #64891

Merged
yuriw merged 1 commit into
ceph:tentaclefrom
aainscow:wip-72372-tentacle
Sep 12, 2025
Merged

yuriw merged 1 commit into
ceph:tentaclefrom
aainscow:wip-72372-tentacle

Conversation

@aainscow

@aainscow aainscow commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

…upports it).

Plugins which support partial reads, should never need more than k shards
to read the data, even if some shards have failed. However, rebalancing commonly
requests k + m shards, as very frequently all shards are moved. If this occurs
and all k + m shards are online, the read will be achieved by reading ALL shards
rather than just reading k shards. This commit fixes that issue.

The problem is that we don't want to change the API to the old EC, so we cannot
update the plugin behaviour here.  Instead, the EC code itself will reduce
the number of shards it tells minimum_to_decode about.

In a comment we note that bitset_set performance could be improved using _pdep_u64.
This would require fiddly platform-specific code and would likely not show
any performance improvements for most applications. The majority of the calls to
this function will be with a bitset that has <=n set bits and will never enter this
if statement. When there are >n bits set we are going to save one or more read I/Os,
the cost of the for loop is insignificant vs this saving. I have left the comment
in as a hint to future users of this function.

Further notes were made in a review comment that are worth recording:

- If performance is limited by the drives, then less read I/Os is a clear advantage.
- If performance is limited by the network then less remote read I/Os is a clear advantage.
- If performance is limited by the CPU then the CPU cost of M unnecessary remote
  read I/Os (messenger+bluestore) is almost certainly more than the cost of doing an
  extra encode operation to calculate the coding parities.
- If performance is limited by system memory bandwidth the encode+crc generation
  has less overhead than the read+bluestore crc check+messenger overheads.

Longer term this logic should probably be pushed into the plugins, in particular
to give LRC the opportunity to optimize for locality of the shards. Reason for
not doing this now is that it would be messy because the legacy EC code cannot
support this optimization and LRC isn't yet optimizing for locality

Signed-off-by: Alex Ainscow <[email protected]>
(cherry picked from commit 52915db)
@aainscow
aainscow requested a review from a team as a code owner August 7, 2025 12:31
@aainscow aainscow added this to the tentacle milestone Aug 7, 2025
@aainscow aainscow added the core label Aug 7, 2025
@yuriw

yuriw commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

I suspect this PR broke the build

https://jenkins.ceph.com/job/ceph-dev-new-build/ARCH=x86_64,AVAILABLE_ARCH=x86_64,AVAILABLE_DIST=centos9,DIST=centos9,MACHINE_SIZE=gigantic/93527//consoleFull

build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos9/DIST/centos9/MACHINE_SIZE/gigantic/release/20.0.0-2864-g53cc9e7c/rpm/el9/BUILD/ceph-20.0.0-2864-g53cc9e7c/src/tools/erasure-code/ceph-erasure-code-tool.cc: In function ‘int do_encode(const std::vector<const char*>&)’:
/home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos9/DIST/centos9/MACHINE_SIZE/gigantic/release/20.0.0-2864-g53cc9e7c/rpm/el9/BUILD/ceph-20.0.0-2864-g53cc9e7c/src/tools/erasure-code/ceph-erasure-code-tool.cc:218:68: error: invalid conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘shard_id_set*’ {aka ‘bitset_set<128, shard_id_t>*’} [-fpermissive]
218 | r = encoded_data.encode(ec_impl, nullptr, encoded_data.get_ro_end());
| ~~~~~~~~~~~~~~~~~~~~~~~^~
| |
| uint64_t {aka long unsigned int}

@aainscow pls take a look

@aainscow

Copy link
Copy Markdown
Contributor Author

I suspect this PR broke the build

https://jenkins.ceph.com/job/ceph-dev-new-build/ARCH=x86_64,AVAILABLE_ARCH=x86_64,AVAILABLE_DIST=centos9,DIST=centos9,MACHINE_SIZE=gigantic/93527//consoleFull

build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos9/DIST/centos9/MACHINE_SIZE/gigantic/release/20.0.0-2864-g53cc9e7c/rpm/el9/BUILD/ceph-20.0.0-2864-g53cc9e7c/src/tools/erasure-code/ceph-erasure-code-tool.cc: In function ‘int do_encode(const std::vector<const char*>&)’: /home/jenkins-build/build/workspace/ceph-dev-new-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos9/DIST/centos9/MACHINE_SIZE/gigantic/release/20.0.0-2864-g53cc9e7c/rpm/el9/BUILD/ceph-20.0.0-2864-g53cc9e7c/src/tools/erasure-code/ceph-erasure-code-tool.cc:218:68: error: invalid conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘shard_id_set*’ {aka ‘bitset_set<128, shard_id_t>*’} [-fpermissive] 218 | r = encoded_data.encode(ec_impl, nullptr, encoded_data.get_ro_end()); | ~~~~~~~~~~~~~~~~~~~~~~~^~ | | | uint64_t {aka long unsigned int}

@aainscow pls take a look

Its not this PR. I see you included #64892 - which is more likely. I suspect we need #64794 too.

@connorfawcett

Copy link
Copy Markdown
Contributor

@yuriw
yuriw merged commit fae96c0 into ceph:tentacle Sep 12, 2025
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.

5 participants