Skip to content

Commit aab8f58

Browse files
jamieprydeaainscow
authored andcommitted
erasure-code: Add parity delta write optimization to SHEC
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]>
1 parent 4527b8c commit aab8f58

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

src/erasure-code/shec/ErasureCodeShec.cc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,48 @@ int ErasureCodeShecReedSolomonVandermonde::shec_decode(int *erased,
273273
return shec_matrix_decode(erased, avails, data, coding, blocksize);
274274
}
275275

276+
void ErasureCodeShecReedSolomonVandermonde::encode_delta(const bufferptr &old_data,
277+
const bufferptr &new_data,
278+
bufferptr *delta_maybe_in_place)
279+
{
280+
if (&old_data != delta_maybe_in_place) {
281+
memcpy(delta_maybe_in_place->c_str(), old_data.c_str(), delta_maybe_in_place->length());
282+
}
283+
char *new_data_p = const_cast<char*>(new_data.c_str());
284+
char *delta_p = delta_maybe_in_place->c_str();
285+
galois_region_xor(new_data_p, delta_p, delta_maybe_in_place->length());
286+
}
287+
288+
void ErasureCodeShecReedSolomonVandermonde::apply_delta(const shard_id_map<bufferptr> &in,
289+
shard_id_map<bufferptr> &out)
290+
{
291+
auto first = in.begin();
292+
const unsigned blocksize = first->second.length();
293+
294+
for (auto const& [datashard, databuf] : in) {
295+
if (datashard < k) {
296+
for (auto const& [codingshard, codingbuf] : out) {
297+
if (codingshard >= k) {
298+
ceph_assert(codingbuf.length() == blocksize);
299+
char* input_data = const_cast<char*>(databuf.c_str());
300+
char* output_data = const_cast<char*>(codingbuf.c_str());
301+
switch (w) {
302+
case 8:
303+
galois_w08_region_multiply(input_data, matrix[static_cast<int>(datashard) + (k * (static_cast<int>(codingshard) - k))], blocksize, output_data, 1);
304+
break;
305+
case 16:
306+
galois_w16_region_multiply(input_data, matrix[static_cast<int>(datashard) + (k * (static_cast<int>(codingshard) - k))], blocksize, output_data, 1);
307+
break;
308+
case 32:
309+
galois_w32_region_multiply(input_data, matrix[datashard + (k * (codingshard - k))], blocksize, output_data, 1);
310+
break;
311+
}
312+
}
313+
}
314+
}
315+
}
316+
}
317+
276318
unsigned ErasureCodeShecReedSolomonVandermonde::get_alignment() const
277319
{
278320
return k*w*sizeof(int);

src/erasure-code/shec/ErasureCodeShec.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class ErasureCodeShec : public ceph::ErasureCode {
6464
uint64_t get_supported_optimizations() const override {
6565
return FLAG_EC_PLUGIN_PARTIAL_READ_OPTIMIZATION |
6666
FLAG_EC_PLUGIN_PARTIAL_WRITE_OPTIMIZATION |
67-
FLAG_EC_PLUGIN_ZERO_INPUT_ZERO_OUTPUT_OPTIMIZATION;
67+
FLAG_EC_PLUGIN_ZERO_INPUT_ZERO_OUTPUT_OPTIMIZATION |
68+
FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION;
6869
}
6970

7071
unsigned int get_chunk_count() const override {
@@ -144,6 +145,13 @@ class ErasureCodeShecReedSolomonVandermonde final : public ErasureCodeShec {
144145
char **data,
145146
char **coding,
146147
int blocksize) override;
148+
149+
void encode_delta(const ceph::bufferptr &old_data,
150+
const ceph::bufferptr &new_data,
151+
ceph::bufferptr *delta_maybe_in_place);
152+
void apply_delta(const shard_id_map<ceph::bufferptr> &in,
153+
shard_id_map<ceph::bufferptr> &out);
154+
147155
unsigned get_alignment() const override;
148156
size_t get_minimum_granularity() override
149157
{

0 commit comments

Comments
 (0)