Skip to content

os/transaction: page align write data buffers to improve performance - version 2 - #57740

Merged
ljflores merged 2 commits into
ceph:mainfrom
bill-scales:wip-bscales-align-write-buffers-v2
Apr 18, 2025
Merged

ljflores merged 2 commits into
ceph:mainfrom
bill-scales:wip-bscales-align-write-buffers-v2

Conversation

@bill-scales

Copy link
Copy Markdown
Contributor

Align write data in Objectstore::Transaction encoded buffers so that RepOp and ECSubOpWrite messages align data on the receiving OSD to avoid a later memmove. Also fix ECSubOpReadReply messages in a similar way so that read data is aligned on the receiving OSD.

Version 2 - A more complicated set of changes to Transaction.h to allow all write data to be aligned by avoiding placing the data buffer length in the data buffer. This requires the transaction to be created with two sets of bufferlists, one for the old format (used for backwards compatibility) and one for the new format.

More detail

See #57738 (version 1) for details of why data alignment is a performance issue and the concept of encoding/decoding ObjectStore::Transaction's into the payload buffer and data buffer to allow data to be aligned.

Version 2 resolves the issue of version 1 by putting lengths in the payload buffer rather than the data buffer and by correcting the alignment of all writes in the transaction, not just the longest write. The challenge is how to do this while still being able to create backwards compatible encodings that include the lengths interspersed with write data. It solves this problem by creating two sets of buffer lists when an ObjectStore::Transaction is build - one set will be used to encode messages for downlevel OSDs (and has lengths interspersed with data), the other set will be used to encode messages for OSDs running new code (the reference counting in Ceph buffers means there are low overheads for having two sets of bufferlists). On the sending OSD the transaction maintains both formats, this is called a dual format transaction. On the receiving OSD the transaction will be either old or new format depending what encoding was used by the sending OSD. Code such as the iterator need to cope with all formats.

This code does not translate between old and new format (this is technically possible, but gets very messy because you have to iterate across the transaction and build a new set of bufferlists). Because of this there are two limitations on mixing different format transactions which will cause an assert:

Limitation on append

It is not possible to append a new format and old format transaction or versa versa. Transactions of the same format or if either one of the transactions is in dual format can be appended. Code inspection shows the only current use of Transaction::append is for creating EC rollback transactions, both these transactions will be in dual format. There is also one existing test program that tests Transaction::append which also only uses transactions in dual format. In practice no code is going to receive transactions from two different OSDs (one running new code and one running old code) and then try and append these transactions together, so this limitations is not going to be an issue.

Limitation on encode

It is not possible to encode a new format transaction in old format. Code inspection shows the only current uses of Transaction::encode/decode is when sending inter-OSD messages and by the ceph-dencoder tool. In practice no code is going to receive a transaction in a message from another OSD and then attempt to encode the transaction in old format to send to a downlevel OSD, so this limitation won’t be an issue.

Version 2 gets rid of yucky code in transaction.h to track the largest block of data in the Transaction, new code in write() optimizes the alignment of write data being added to the transaction and the iterator function decode_bl performs the reverse transformation. The extra code to deal with different transaction formats is not beautiful, but a nice feature of the implementation is that this is only required until backwards compatibility with older code levels is dropped.

New unit tests are added to fully exercise building, encoding, decoding, iterating and appending ObjectStore transactions and to validate the improvement in aligning buffers. The rbd bench utility is extended with extra options to provide more flexibility in generating I/O requests.



The RepOp, ECSubWriteOp and ECSubReadReplyOp messages have been modified to align the write data buffers they send. Manual testing has confirmed that these buffers are correctly page aligned on the receiving OSD.


The performance benchmark ceph_perf_objectstore was run on old and new code and shows negligible difference in performance for the typical set of operations performed on ObjectStore::Transaction’s.

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

@bill-scales bill-scales left a comment

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've annotated a few details where I'd appreciate some feedback form reviewers

Comment thread src/include/encoding.h Outdated

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.

Reviewer feedback requested:

I've only implemented a minimal set of encode/decode templates using two buffers which is sufficient for ObjectStore::Transaction and the messages MOSDRepOp, MOSDECSubWrite and MOSDECSubReadReply. Should the addition of further templates be left until they are required or should this pull request cover the other standard types in encoding.h and denc.h?

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.

Nah, I wouldn't add things until they are really necessary.
With this being said, I'm thinking on whether we truly need to (extensively) touch the dencoding framework.

Comment thread src/messages/MOSDECSubOpReadReply.h Outdated

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.

Reviewer feedback requested:

The PR is currently using the feature SERVER_SQUID to select new/old version encoding for MOSDECSubOpReadReply, MOSDECSubOpWrite and MOSDRepOp. Should this be SERVER_TENTACLE? Is there a better way of checking compatibility of remote OSDs?

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.

SERVER_SQUID is and SERVER_TENTACLE will be instances of so called features bits (see include/ceph_features.h). When a connection is established, features of a peer are recognized. This lets dencoders to change / switch between formats beyond the usual extend at the end and drop if not understandable idiom.

An important change may get its own, dedicated feature bit which, by decoupling from the release-wide bits, allows backporting.

Comment thread src/messages/MOSDECSubOpReadReply.h Outdated

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.

Reviewer feedback requested:

MOSDECSubOpReadReply and MOSDECSubOpWrite now encode write data into the data bl of the message, and now return the length of this buffer for get_cost(), previously these messages returned a cost of 0. This will change how these messages are prioritized by the scheduler. Should they return a cost of 0 instead to preserve old behavior, or was the old behavior a bug?

An aside is that all the ECSubOp* messages and the RepOp message unnecessarily override get_cost when the default method which returns data.length() would provide the same behavior - should these unnecessary overrides be deleted?

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.

It looks like a bug. However, the 0-returning behavior is present since the very beginning of EC support in 2013. Yet, the recently introduced mClockScheduler might have changed a lot in the matter of impact:

void mClockScheduler::enqueue(OpSchedulerItem&& item)
{
  // ...
  } else {
    auto cost = calc_scaled_cost(item.get_cost());
    item.set_qos_cost(cost);
  }

I think the best would be to dissected the change, send it as a separate PR and let @sseshasa know.

Comment thread src/messages/MOSDRepOp.h Outdated

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.

Reviewer feedback requested:

I’ve moved an ObjectStore::Transaction into the MOSDRepOp message so that it can be encoded when the message is sent rather than when the message is built. I added a clear_buffers() method (copying what is done in MOSDECSubOpWrite) to clean up the transaction and avoid buffers being held referenced. Is this correct?

Comment thread src/os/Transaction.h Outdated

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.

Reviewer feedback requested:

I've deleted these helper functions to decode Transactions because there are now two decode functions (with one or two buffers) and I wanted code to be more explicit about which decode function to use. These functions were not being used by the current code.

Just want to check that there isn't a coding convention for having these type of decode helper functions?

@rzarzynski rzarzynski Jun 23, 2024 •

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 think there is a particular convention here.
What I would recommend is just to perform such clean-ups through separated commits.

@idryomov idryomov 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.

Same as in #57738, I'd suggest breaking additions to rbd bench command out into a separate PR for easier review.

@bill-scales

Copy link
Copy Markdown
Contributor Author

Here is a profile of a build containing the version 2 fix:

Screenshot 2024-05-31 at 13 44 37

and for reference the profile before the fix:

Screenshot 2024-05-28 at 08 12 13

We can see that the fix has had the desired effect of eliminating the memmove to realign data without causing any other adverse effects to performance when decoding and applying the transaction.

@bill-scales
bill-scales requested a review from a team as a code owner June 5, 2024 09:16

@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.

Review-in-progress.

Comment thread src/messages/MOSDECSubOpReadReply.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.

It looks like a bug. However, the 0-returning behavior is present since the very beginning of EC support in 2013. Yet, the recently introduced mClockScheduler might have changed a lot in the matter of impact:

void mClockScheduler::enqueue(OpSchedulerItem&& item)
{
  // ...
  } else {
    auto cost = calc_scaled_cost(item.get_cost());
    item.set_qos_cost(cost);
  }

I think the best would be to dissected the change, send it as a separate PR and let @sseshasa know.

Comment thread src/messages/MOSDECSubOpReadReply.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.

SERVER_SQUID is and SERVER_TENTACLE will be instances of so called features bits (see include/ceph_features.h). When a connection is established, features of a peer are recognized. This lets dencoders to change / switch between formats beyond the usual extend at the end and drop if not understandable idiom.

An important change may get its own, dedicated feature bit which, by decoupling from the release-wide bits, allows backporting.

Comment thread src/os/Transaction.h Outdated

@rzarzynski rzarzynski Jun 23, 2024 •

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 think there is a particular convention here.
What I would recommend is just to perform such clean-ups through separated commits.

Comment thread src/include/encoding.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: no space after a comma.

Comment thread src/include/encoding.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.

Nah, I wouldn't add things until they are really necessary.
With this being said, I'm thinking on whether we truly need to (extensively) touch the dencoding framework.

Comment thread src/include/encoding.h Outdated

@rzarzynski rzarzynski Jun 23, 2024 •

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: space after comma (here and in a few similar places in the file).

Comment thread src/include/encoding.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.

IIUC the main driving factor behind the new primitives is separating head (typically size) from non-head (actual data).
If that's the case, maybe we could reuse the {encode, decode}_nohead variants to save us some code duplication.

The obvious problem with applying this on broad scale is about containers and preserving the head vs no-head distinction down the nested encodes. However, do we really need to worry? Isn't the optimization targeting basically several instances of bufferlist known to carry big data?

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.

The reason why I ended up creating new primitives is because of the ECSubReadReply structure/message. This needs to encode/decode a map that contains a list that contains pairs that have the data buffers that we want to keep aligned.

  std::map >> buffers_read;

We could write a custom encode/decode method for this structure, duplicating code from encoding.h/denc.h to handle the map, list, pair and buffer::list and call encode/decode_nohead for the data buffers we want to align, but this will end up duplicating code outside of the header files. My viewpoint is that it is better to keep all the encode/decode for containers in one place in the header files, rather than spread custom versions of this through the code, especially as I suspect we will find other places in the code base where this technique can be used to improve data buffer alignment.

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 see your points. Have you considered an approach with if constexpr() and a head-nohead trait (a template parameter; we already make use of the traits concept in the dencoding frameworks) passed down the stack? It would require two passes (one with matadata bl, one with data bl) but maybe we could simplify even already existing code (by streamlining {de,en}code_nohead()).

Just thinking loudly.

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 really liked that idea and did a bit of prototyping. My observations:

  1. The extra if statements in the {de,en}code functions are a bit messy, but perhaps 1 template with some ifs is still better than 2 templates for each type
  2. I could write generic templates for encode_nohead, encode_headonly, encode that pass a different trait to the encode templates which means some of the nohead templates could be deleted
  3. Decoding doesn't work :-( For compound types like a map you can't do the decode in two passes, you need to interleave the decode of the two buffers. This is also why decode_nohead requires extra parameters.

But the prototyping taught me that I don't need to duplicate all the templates - I can just have {de,en}code templates for types that take 2 bufferlists for payload and data buffers and then write a generic template like this to continue supporting encoding with a single bufferlist:

template<class T> inline void encode(T& t,bufferlist &bl) { encode(t,bl,bl); }

This will tidy things up a lot and I think achieves what you were looking for. Will do this for the next commit

@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.

In progress.

Comment thread src/crimson/osd/replicated_backend.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.

ACK. This enables the per-OSD encoding – we can end with different schema for each replica.

Comment thread src/messages/MOSDECSubOpReadReply.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.

Hmm, do we need to worry about the 2nd version – it has been introduced by 152dfdd in 2017.

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.

Good point, but we are ok:

  • The decode function can decode all 3 versions.
  • The encode function can encode version 2 (compatible with version 1 as it is just appending a field) or version 3. It uses a feature bit to determine when the receiving OSD can cope with version 3

I am however being lax about setting the compat_verison - this is always being set to 1. When sending a version 3 message compat_version should be set to 3 because this cannot be decoded by OSDs running version 1 or 2. We should never send them a version 3 message, but it would be better to set compat_version so they assert if this happened. I'll fix that

Comment thread src/messages/MOSDECSubOpWrite.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.

Ditto.

Comment thread src/messages/MOSDRepOp.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: I guess we've crossed the 80th column.

Comment thread src/messages/MOSDRepOp.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: missed space after {.

Comment thread src/os/Transaction.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.

Could be more readable if these exits are placed on top, as early exits.

Comment thread src/os/Transaction.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: mixed indentation.

Comment thread src/os/Transaction.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.

... so we're referencing write_data in old_data_bl unconditionally. IIUC we do this as, on the time a txn is being filled, we simply don't know what will be our peers. This will be concretized later, at the of the envelope's encoding.

Comment thread src/os/Transaction.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.

OK, so the idea is align middle parts even for multiple writes. 👍

Comment thread src/os/Transaction.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.

ver, ver for 10 means we require a peer's decoder to be the current one. What about the upgrade scenario?

If this is addressed at call-site (by p_bl == &d_bl?), then this place deserves at least a comment.

@github-actions

github-actions Bot commented Aug 6, 2024

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 Oct 5, 2024

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 Oct 5, 2024
@github-actions

github-actions Bot commented Nov 4, 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 Nov 4, 2024
@athanatos athanatos reopened this Nov 5, 2024
@athanatos

Copy link
Copy Markdown
Contributor

@rzarzynski @bill-scales Is this still in progress?

@github-actions github-actions Bot removed the stale label Nov 5, 2024
@rzarzynski

Copy link
Copy Markdown
Contributor

@athanatos, @bill-scales: IIRC the controversial / complex thing was os::Transaction started encoding ops in two formats the same time, just to tackle the upgrade case.

I hope 7858030 and #59979 could help with that.

@github-actions

github-actions Bot commented Jan 4, 2025

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 Jan 4, 2025
@rzarzynski

Copy link
Copy Markdown
Contributor

We talked off-line about this one. If my memory serves me right, @bill-scales is going to revive the PR squeezing the double encoding out.

@github-actions github-actions Bot removed the stale label Jan 13, 2025
@bill-scales

Copy link
Copy Markdown
Contributor Author

Working on cleaning this up.

  1. Current version uses the peer OSD version when sending a transaction to another OSD to work out what format transaction to encode. This gets messy when OSDs are running different code levels - in particular for replica pools where ideally we want to encode the transaction once and send it to multiple OSDs. Next attempt will use min_peer_features which is a set features supported by all the OSDs in a PG and is calculated early in Peering (before I/O starts) to decide how to encode the transactions

  2. Current version makes quite a few changes to encoding.h to allow data structures such as sets of buffers to be encoded with buffers encoded into a data buffer and the rest of the data encoded into a metadata buffer. This turns out to be a lot of boilerplate code and still requires changes when encoding a data structure because it isn't really possible to distinguish data buffers for things like attributes from data buffers for I/O. The code will be simpler just by writing a special case encode function for the ECSubReadReply message.

@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.

@bill-scales

Copy link
Copy Markdown
Contributor Author

WARNING: Transaction.h has a #ifdef WITH_SEASTORE that will need to be updated to WITH_CRIMSON before being merged because of 23c33f6

@bill-scales
bill-scales force-pushed the wip-bscales-align-write-buffers-v2 branch from 9af3b69 to 404bb0d Compare April 7, 2025 11:59
@bill-scales

Copy link
Copy Markdown
Contributor Author

Rebased - only other change is s/WITH_SEASTAR/WITH_CRIMSON because of 23c33f6

@bill-scales

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

1 similar comment
@bill-scales

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

Comment on lines +1193 to +1217
auto p = const_cast<bufferlist&>(m->get_middle()).cbegin();
auto d = const_cast<bufferlist&>(m->get_data()).cbegin();
rm->opt.decode(m->get_middle().length() != 0 ? p : d, d);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing a teuthology error around this area of the code:
/a/lflores-2025-04-10_15:17:40-rados-wip-lflores-testing-2-2025-04-09-1400-distro-default-smithi/8234757

2025-04-10T18:16:11.557 INFO:tasks.ceph.osd.15.smithi135.stderr:terminate called after throwing an instance of 'ceph::buffer::v15_2_0::malformed_input'
2025-04-10T18:16:11.638 INFO:tasks.ceph.osd.15.smithi135.stderr:  what():  void ceph::os::Transaction::decode(ceph::buffer::v15_2_0::list::const_iterator&, ceph::buffer::v15_2_0::list::const_iterator&) decode past end of struct encoding: Malformed input [buffer:3]
2025-04-10T18:16:11.638 INFO:tasks.ceph.osd.15.smithi135.stderr:*** Caught signal (Aborted) **
2025-04-10T18:16:11.638 INFO:tasks.ceph.osd.15.smithi135.stderr: in thread 7fdbeb491640 thread_name:tp_osd_tp
2025-04-10T18:16:11.644 INFO:tasks.ceph.osd.15.smithi135.stderr: ceph version 20.0.0-1326-ga86028d6 (a86028d68e7921896709e151a2ea1a7c9fc0be14) tentacle (dev)
2025-04-10T18:16:11.644 INFO:tasks.ceph.osd.15.smithi135.stderr: 1: /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fdc065b7520]
2025-04-10T18:16:11.644 INFO:tasks.ceph.osd.15.smithi135.stderr: 2: pthread_kill()
2025-04-10T18:16:11.644 INFO:tasks.ceph.osd.15.smithi135.stderr: 3: raise()
2025-04-10T18:16:11.644 INFO:tasks.ceph.osd.15.smithi135.stderr: 4: abort()
2025-04-10T18:16:11.644 INFO:tasks.ceph.osd.15.smithi135.stderr: 5: /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa2bbe) [0x7fdc06948bbe]
2025-04-10T18:16:11.644 INFO:tasks.ceph.osd.15.smithi135.stderr: 6: /lib/x86_64-linux-gnu/libstdc++.so.6(+0xae24c) [0x7fdc0695424c]
2025-04-10T18:16:11.644 INFO:tasks.ceph.osd.15.smithi135.stderr: 7: /lib/x86_64-linux-gnu/libstdc++.so.6(+0xae2b7) [0x7fdc069542b7]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 8: /lib/x86_64-linux-gnu/libstdc++.so.6(+0xae518) [0x7fdc06954518]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 9: ceph-osd(+0x3c7b27) [0x55e8bcab1b27]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 10: (ReplicatedBackend::do_repop(boost::intrusive_ptr<OpRequest>)+0x477) [0x55e8bce2e537]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 11: (ReplicatedBackend::_handle_message(boost::intrusive_ptr<OpRequest>)+0x1d7) [0x55e8bce3c1d7]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 12: (PGBackend::handle_message(boost::intrusive_ptr<OpRequest>)+0x56) [0x55e8bce495f6]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 13: (PrimaryLogPG::do_request(boost::intrusive_ptr<OpRequest>&, ThreadPool::TPHandle&)+0x7ed) [0x55e8bcd963dd]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 14: (OSD::dequeue_op(boost::intrusive_ptr<PG>, boost::intrusive_ptr<OpRequest>, ThreadPool::TPHandle&)+0x197) [0x55e8bccd1837]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 15: (ceph::osd::scheduler::PGOpItem::run(OSD*, OSDShard*, boost::intrusive_ptr<PG>&, ThreadPool::TPHandle&)+0x69) [0x55e8bcf22339]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 16: (OSD::ShardedOpWQ::_process(unsigned int, ceph::heartbeat_handle_d*)+0xa76) [0x55e8bcce5b36]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 17: (ShardedThreadPool::shardedthreadpool_worker(unsigned int)+0x292) [0x55e8bd2412e2]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 18: ceph-osd(+0xb57864) [0x55e8bd241864]
2025-04-10T18:16:11.645 INFO:tasks.ceph.osd.15.smithi135.stderr: 19: /lib/x86_64-linux-gnu/libc.so.6(+0x94b43) [0x7fdc06609b43]
2025-04-10T18:16:11.646 INFO:tasks.ceph.osd.15.smithi135.stderr: 20: /lib/x86_64-linux-gnu/libc.so.6(+0x126a00) [0x7fdc0669ba00]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

rzarzynski and others added 2 commits April 11, 2025 13:30
Align write data in Objectstore::Transaction encoded buffers so that
RepOp and ECSubOpWrite messages align data on the receiving OSD to
avoid a later memmove. Also fix ECSubOpReadReply messages in a
similar way so that read data is aligned on the receiving OSD.

Signed-off-by: Radoslaw Zarzynski <[email protected]>
Signed-off-by: Bill Scales <[email protected]>
@bill-scales
bill-scales force-pushed the wip-bscales-align-write-buffers-v2 branch from 404bb0d to a0c9fec Compare April 11, 2025 12:33
@bill-scales

Copy link
Copy Markdown
Contributor Author

Reproduced, debugged and fixed the issue causing QA failures.

Change is to MOSDop::encode_payload

- set_middle(txn_payload);
+ bufferlist middle(txn_payload);
+ set_middle(middle);

It was only teuthology tests that had messenger error inject that were failing. The error inject caused messenger to have two attempts at encoding and sending the message. The call to set_middle does a bufferlist assignment that empties the source bufferlist, so encoding the message twice meant the middle buffer wasn't sent causing a decode problem on the receiving osd. The fix makes a shallow copy of the bufferlist (will be a single buffer) so that it is safe to call encode_payload multiple times.

@rzarzynski

Copy link
Copy Markdown
Contributor

@ljflores: let's retake this into the T testing.

@kamoltat

Copy link
Copy Markdown
Member

@ljflores

Copy link
Copy Markdown
Member

@ljflores
ljflores merged commit 7530afa into ceph:main Apr 18, 2025
batrick pushed a commit that referenced this pull request May 28, 2026
PeeringState calculates the minimum set of features for the set
of OSDs within a PG. There is a bug when the peer info has
already been cached where these peers features are not included
in the calculation. This can lead to the min feature set
including features that not all OSDs have.

Previously this just made some asserts less aggressive than they
should have been. Pull request #57740
uses min_peer_features to decide how to encode messages to other OSDs.

Midway through an upgrade this bug can cause an OSD to send
the wrong version of a message to a downlevel OSD causing
it to abort.

Fixes: https://tracker.ceph.com/issues/76600

Signed-off-by: Bill Scales <[email protected]>
batrick pushed a commit that referenced this pull request Jun 8, 2026
PeeringState calculates the minimum set of features for the set
of OSDs within a PG. There is a bug when the peer info has
already been cached where these peers features are not included
in the calculation. This can lead to the min feature set
including features that not all OSDs have.

Previously this just made some asserts less aggressive than they
should have been. Pull request #57740
uses min_peer_features to decide how to encode messages to other OSDs.

Midway through an upgrade this bug can cause an OSD to send
the wrong version of a message to a downlevel OSD causing
it to abort.

Fixes: https://tracker.ceph.com/issues/76600

Signed-off-by: Bill Scales <[email protected]>
(cherry picked from commit ce58827)
mertsunacoglu pushed a commit to mertsunacoglu/ceph that referenced this pull request Aug 26, 2026
PeeringState calculates the minimum set of features for the set
of OSDs within a PG. There is a bug when the peer info has
already been cached where these peers features are not included
in the calculation. This can lead to the min feature set
including features that not all OSDs have.

Previously this just made some asserts less aggressive than they
should have been. Pull request ceph#57740
uses min_peer_features to decide how to encode messages to other OSDs.

Midway through an upgrade this bug can cause an OSD to send
the wrong version of a message to a downlevel OSD causing
it to abort.

Fixes: https://tracker.ceph.com/issues/76600

Signed-off-by: Bill Scales <[email protected]>
(cherry picked from commit ce58827)
ming1 added a commit to ming1/ceph that referenced this pull request Sep 19, 2026
a0c9fec (ceph#57740) split a Transaction's payload into data_aligned_bl
and data_misaligned_bl for the aligned (version 10) encoding, but left
get_encoded_bytes() summing only data_misaligned_bl. For an
aligned-format transaction the page-aligned body of every write() is
therefore invisible to the size estimate: a 12 KiB page-aligned write
comes out as 221 bytes.

BlueStore::queue_transactions() feeds get_num_bytes() into txc->bytes,
and _txc_calc_cost() turns that into the cost charged against
bluestore_throttle_bytes and bluestore_throttle_deferred_bytes, so an
aligned-format transaction is undercharged by its payload on both the
primary and the replica. Today only the recovery push/pull paths build
aligned-format transactions; the next commit makes every replicated
client write do so, which would turn the undercount into the common
case.

Count both payload bufferlists, and while here make the estimate exact:
size the ENCODE_START header and the bufferlist length prefixes for
whichever layout encode() emits for the transaction's own data_features
(version 9 for legacy-format, version 10 for aligned-format). Keep
get_encoded_bytes_test() in step, and extend unittest_transaction to
check both against the length of a real encode() for a legacy and an
aligned transaction, the latter covering the aligned, prefix and suffix
branches of write().

Measured on a two-OSD, size 2 vstart cluster with the next commit applied,
from BlueStore's _txc_calc_cost log line: a 128 KiB replicated client
write was costed as 2171 bytes on the primary and 1262 on the replica
before this change, 133282 and 132355 after; a 16 KiB write at offset 1
(prefix + two aligned pages + suffix) went from about 6 KiB to about
18 KiB on both, for the direct and the deferred path alike.

Signed-off-by: Ming Lei <[email protected]>
AnuragRaut08 pushed a commit to AnuragRaut08/ceph that referenced this pull request Sep 30, 2026
PeeringState calculates the minimum set of features for the set
of OSDs within a PG. There is a bug when the peer info has
already been cached where these peers features are not included
in the calculation. This can lead to the min feature set
including features that not all OSDs have.

Previously this just made some asserts less aggressive than they
should have been. Pull request ceph#57740
uses min_peer_features to decide how to encode messages to other OSDs.

Midway through an upgrade this bug can cause an OSD to send
the wrong version of a message to a downlevel OSD causing
it to abort.

Fixes: https://tracker.ceph.com/issues/76600

Signed-off-by: Bill Scales <[email protected]>
tomo-rapidspace pushed a commit to tomo-rapidspace/ceph that referenced this pull request Oct 12, 2026
a0c9fec (ceph#57740) split a Transaction's payload into data_aligned_bl
and data_misaligned_bl for the aligned (version 10) encoding, but left
get_encoded_bytes() summing only data_misaligned_bl. For an
aligned-format transaction the page-aligned body of every write() is
therefore invisible to the size estimate: a 12 KiB page-aligned write
comes out as 221 bytes.

BlueStore::queue_transactions() feeds get_num_bytes() into txc->bytes,
and _txc_calc_cost() turns that into the cost charged against
bluestore_throttle_bytes and bluestore_throttle_deferred_bytes, so an
aligned-format transaction is undercharged by its payload on both the
primary and the replica. Today only the recovery push/pull paths build
aligned-format transactions; the next commit makes every replicated
client write do so, which would turn the undercount into the common
case.

Count both payload bufferlists, and while here make the estimate exact:
size the ENCODE_START header and the bufferlist length prefixes for
whichever layout encode() emits for the transaction's own data_features
(version 9 for legacy-format, version 10 for aligned-format). Keep
get_encoded_bytes_test() in step, and extend unittest_transaction to
check both against the length of a real encode() for a legacy and an
aligned transaction, the latter covering the aligned, prefix and suffix
branches of write().

Measured on a two-OSD, size 2 vstart cluster with the next commit applied,
from BlueStore's _txc_calc_cost log line: a 128 KiB replicated client
write was costed as 2171 bytes on the primary and 1262 on the replica
before this change, 133282 and 132355 after; a 16 KiB write at offset 1
(prefix + two aligned pages + suffix) went from about 6 KiB to about
18 KiB on both, for the direct and the deferred path alike.

Signed-off-by: Ming Lei <[email protected]>
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.

7 participants