Skip to content

osd: Modify erasure code plugins ready for new EC - #61804

Merged
aainscow merged 9 commits into
ceph:mainfrom
aainscow:erasure_code_chunks
Apr 3, 2025
Merged

aainscow merged 9 commits into
ceph:mainfrom
aainscow:erasure_code_chunks

Conversation

@aainscow

@aainscow aainscow commented Feb 13, 2025 •

Copy link
Copy Markdown
Contributor

This is all the changes required for the EC plugins for new EC. This is a fairly significant list:

  • Add flag sets to switch on/off various optimisations in the new code
  • Add support in plugins (but do not call) parity delta writes.
  • Minimum granularity interface, which allows a plugin to specify the size of data that needs to be encoded/decoded at once.
  • Improve behaviour when invalid values are provided to plug (fail to use, rather than panic)
  • Update to use shard_id_t, shard_id_set and shard_id_map

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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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
  • jenkins test rook e2e

@rzarzynski rzarzynski left a comment

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.

First part of the review.

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.

nit: I would just drop the commented code.

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.

Will do. Was left in by mistake

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.

ack

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.

nit: ditto.

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.

ack

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 verifying these properties.

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.

ack

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.

nit: too aggressive line wrapping; around 78th column would be fine.

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/erasure-code/ErasureCodeInterface.h Outdated

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.

Is there a reason for using an output-param instead just returning the new ptr?

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.

This is to allow the caller to re-use the same buffer for both old_data and delta.

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.

Understood. If want to avoid the ref counter management, then fine. However, please be aware buffer::ptr is only a kind-of smart pointer managing the buffer::raw.

Comment thread src/erasure-code/ErasureCodeInterface.h Outdated

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 the immutability.

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.

ack

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.

Oh, I see.

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.

Not sure what you are seeing here?

Comment thread src/erasure-code/isa/ErasureCodeIsa.cc Outdated

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.

nit: continue in new line.

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.

list.front().

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.

ditto.

@rzarzynski rzarzynski left a comment

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.

Reivewi for common: bitset_set and mini_flat_map. Looks good, mostly nits + a question.

Comment thread src/common/bitset_set.h Outdated

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.

nit: NumBitsV and KeyT?

Comment thread src/common/bitset_set.h Outdated

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.

ACK.

Comment thread src/common/bitset_set.h Outdated

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.

Is there a use case for this int-specific overload?

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.

Yes. This was required for some compatibility issues when coverting from old code with set to bitset_sets. Potentially we can eventually refactor all of those out and delete this overload, but it is required for now.

Comment thread src/common/bitset_set.h Outdated

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.

nit: separated line.

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.

ack.Old habits die hard.

Comment thread src/common/bitset_set.h Outdated

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.

nit: new line.

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.

ack.

Comment thread src/common/mini_flat_map.h Outdated

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.

nit: let's not try to save on new lines.

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.

I will reformat the file according to code standards.

Comment thread src/common/mini_flat_map.h Outdated

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.

nit.

Comment thread src/common/mini_flat_map.h Outdated

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.

nit.

Comment thread src/common/mini_flat_map.h Outdated

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.

nit.

Comment thread src/test/common/test_bitset_set.cc Outdated

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.

nit: GH signals lack of \n?

ghost left a comment

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.

First round finished!

Generally speaking this looks sane. Most comments are about nits (please take a look on https://github.com/ceph/ceph/blob/main/CodingStyle); some are questions.

Comment thread src/common/hobject.cc Outdated

ghost Feb 21, 2025

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.

🥇
I very, very like the idea of improving type safety.

Comment thread src/include/types.h Outdated

ghost Feb 21, 2025

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.

nit: they don't need to be oneliners.

Comment thread src/osd/ECTypes.h Outdated

ghost Feb 21, 2025

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.

Is the lack of versioning facilities intentional?

Comment thread src/common/mini_flat_map.h Outdated

ghost Feb 21, 2025

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.

I think this chunk should be dissected and get squashed with the commits that introduces and container.

ghost Feb 26, 2025

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.

will do

Comment thread src/erasure-code/ErasureCode.cc Outdated

ghost Feb 21, 2025

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.

nit: oops!

ghost Feb 21, 2025

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.

Doesn't this deserve a dedicated commit and description?

Comment thread src/erasure-code/lrc/ErasureCodeLrc.cc Outdated

ghost Feb 21, 2025

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.

nit.

Comment thread src/erasure-code/lrc/ErasureCodeLrc.cc Outdated

ghost Feb 21, 2025

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.

nit: } else {.

Comment thread src/osd/ECCommonL.cc Outdated

ghost Feb 21, 2025

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.

Maybe let's introduce a temporary to make this condition easier to read.

ghost Feb 21, 2025

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.

👍

@aainscow

ghost commented Feb 26, 2025

Copy link
Copy Markdown
Contributor Author

I have found some significant teuthology failures in this PR and am doing some refactoring. Hopefully I will have these in the next couple of days.

@aainscow
aainscow force-pushed the erasure_code_chunks branch 3 times, most recently from a15e870 to 722d922 Compare March 6, 2025 07:51
@JonBailey1993

ghost commented Mar 6, 2025

Copy link
Copy Markdown
Contributor

Pushed rebase to include fixes from comments in #61754 and #61404

@aainscow

ghost commented Mar 6, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test api

@github-actions

ghost commented Mar 7, 2025

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

ghost commented Mar 9, 2025

Copy link
Copy Markdown

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

Jamie Pryde and others added 9 commits March 19, 2025 11:03
Add flags to erasure code plugins to report supported optimizations
and new unittest_erasure_code_plugins to test these flags for many
permutations of plugins and profiles.

Signed-off-by: Bill Scales <[email protected]>

[Taken from Bill's fork with permission]
Signed-off-by: Jamie Pryde <[email protected]>
This commit adds FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION to the list of
optimizations supported by the ISA plugin, and encode_delta and
apply_delta functions to ISA. Stubs for these functions are added to
the other plugins.
Two new tests have been added to TestErasureCodePlugins.cc to test the
encode_delta and apply_delta functions. The first new test updates a
single parity chunk using a single delta. The second new test updates
all parity chunks with a delta for every data chunk.

Signed-off-by: Jamie Pryde <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
This commit adds FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION to the list of
optimizations supported by the Jerasure plugin, and encode_delta and
apply_delta functions for all Jerasure techniques.

Signed-off-by: Jamie Pryde <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
This commit adds FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION to the list of
optimizations supported by the SHEC plugin, and encode_delta and
apply_delta functions.

Signed-off-by: Jamie Pryde <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
Add get_minimum_granularity() function to the EC plugin interface,
which returns the minimum size in bytes that can be used for partial writes.
This is based on the minimum size of coding chunk update
that the particular technique supports.

Signed-off-by: Jamie Pryde <[email protected]>
… are supplied in erasure code profiles

Signed-off-by: Jon Bailey <[email protected]>
We have changed the encode_chunks interface to take an in map and an out map.
The in map contains the data shards to be encoded. The out map contains the
empty buffers that the plugin will write the parity data to.
The old non-optimized EC path has been updated to call the new encode_chunks
interface from erasurecode.cc
The new EC optimizations path calls the encode_chunks interface from ECUtils.

Signed-off-by: Jamie Pryde <[email protected]>
Signed-off-by: Alex Ainscow <[email protected]>
@aainscow
aainscow force-pushed the erasure_code_chunks branch from 110a374 to 6b733e9 Compare March 19, 2025 11:04
@aainscow aainscow changed the title Refactor erasure code chunks osd: Modify erasure code plugins ready for new EC Mar 19, 2025

ghost left a comment

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.

LGTM. Nits but not blockers. I'm fine with merging assuming follow-ups to fix them.


private:
int chunk_index(unsigned int i) const;
};

ghost Mar 21, 2025

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.

I assume the changes above were only about reidentation.

ghost Mar 31, 2025

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.

Yep

Comment thread src/erasure-code/ErasureCodeInterface.h Outdated

ghost Mar 21, 2025

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.

Understood. If want to avoid the ref counter management, then fine. However, please be aware buffer::ptr is only a kind-of smart pointer managing the buffer::raw.

// Otherwise, use byte_xor()
bool aligned = true;
for (int i = 0; i <= data_vectors; i++) {
aligned &= is_aligned(xor_bufs[i], EC_ISA_ADDRESS_ALIGNMENT);

ghost Mar 21, 2025

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.

Hmm, this is the bitwise AND. Can this be anyhow harmful, particularly on exotic archs?

ghost Mar 31, 2025

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.

We could exit the loop early too.

ghost Apr 3, 2025

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.

Note that we have always used
aligned &= is_aligned(xor_bufs[i], EC_ISA_ADDRESS_ALIGNMENT);
This code was moved from xor_op.cc in #58594

I think
if (!is_aligned... might be safer though

const bufferptr &new_data,
bufferptr *delta)
{
constexpr int data_vectors = 2;

ghost Mar 21, 2025

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.

nit: per the convention it would better (more readable) to capitalize the name (NUM_DATA_VECTORS)

const unsigned blocksize = first->second.length();

for (auto const& [datashard, databuf] : in) {
if (datashard < k) {

ghost Mar 21, 2025

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.

nit: flapping the condition and using continue could save one indentation level.

ghost Mar 31, 2025

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.

Ack

erasures.insert(i);
} else {
(*decoded)[i] = chunks.find(i)->second;
(*decoded)[i].rebuild_aligned(SIMD_ALIGN);

ghost Mar 21, 2025

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.

I don't recall whether rebuld_aligned early-exists if the buffer is already aligned.

ghost Mar 31, 2025

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.

It returns true if a rebuild was required, so there is an early exit here. There might however be some optimisations here for a later date, as new EC should always supply 4k-aligned buffers. I will explore later.

(*decoded)[i].rebuild_aligned(SIMD_ALIGN);
}
bufferlist &bl = (*decoded)[i];
if (bl.length() != bl.begin().get_current_ptr().length()) {

ghost Mar 21, 2025

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.

nit: bufferlist has all the getters. Right now I recall get_num_buffers() but with 90% certainty I think is_contigous() is already in place.

ghost Mar 31, 2025

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.

is_contiguous does exist. I will update.

shard_id_map<bufferptr> in(get_chunk_count());
shard_id_map<bufferptr> out(get_chunk_count());
for (auto&& [shard, list] : *decoded) {
auto bp = list.begin().get_current_ptr();

ghost Mar 21, 2025

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.

nit: list.front().

ghost Mar 31, 2025

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.

list.front() returns a ptr_node, rather than a ptr, so this would not a simple drop in replacement. I am going to leave this one for now... I think the above is clear in its intention.

unsigned int width = get_chunk_count() * get_chunk_size(in.length());
bufferptr pad(width - in.length());
pad.zero(0, get_data_chunk_count());
out.push_back(pad);

ghost Mar 21, 2025

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.

nit: bufferlist::append_zero().

ghost Mar 31, 2025

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.

WIll do. Strange that zero length and pad size are not the same.

// OSD and if CPU is cheap, it could make sense to recover
// instead of fetching the chunk.
//
shard_id_map<int> c2c(available);

ghost Mar 21, 2025

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.

nit: looks a bit duplicative. Perhaps worth deduplicating later.

ghost Mar 31, 2025

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.

This will be deleted when we remove legacy EC

@aainscow

ghost commented Mar 31, 2025

Copy link
Copy Markdown
Contributor Author

Some of the "nits" I think deserve some further testing, so I will keep them for a later commit.

@shraddhaag

ghost commented Apr 3, 2025

Copy link
Copy Markdown
Contributor

@aainscow
aainscow merged commit 1798676 into ceph:main Apr 3, 2025
@aainscow aainscow added the no-backport-required Label that can be optionally added to show that we do not need to backport. label Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build/ops common core crimson needs-qa no-backport-required Label that can be optionally added to show that we do not need to backport. performance tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants