Skip to content

rgw: migrate from boost::variant to std::variant - #63179

Merged
cbodley merged 2 commits into
ceph:mainfrom
tchaikov:rgw-std-variant
Jun 26, 2025
Merged

cbodley merged 2 commits into
ceph:mainfrom
tchaikov:rgw-std-variant

Conversation

@tchaikov

@tchaikov tchaikov commented May 8, 2025 •

Copy link
Copy Markdown
Contributor

replacing boost::variant with std::variant throughout the rgw codebase. This change is part of our ongoing effort to reduce third-party dependencies by leveraging C++ standard library alternatives where possible.

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

@tchaikov
tchaikov requested a review from a team as a code owner May 8, 2025 07:42
@tchaikov
tchaikov force-pushed the rgw-std-variant branch from 43eb07c to c766472 Compare May 9, 2025 14:14
@cbodley
cbodley requested a review from mattbenjamin May 9, 2025 14:25
@mattbenjamin

Copy link
Copy Markdown
Contributor

I think replacing boost::variant with std::variant doesn't have a large benefits being claimed. I don't mind doing it, but I somewhat object to the propaganda

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

please restore the inlining of RGWListBucketsRequest::eof() and RGWReaddirRequest::eof()

Comment thread src/rgw/rgw_file.cc Resolved
Comment thread src/rgw/rgw_file.cc Resolved
@mattbenjamin

Copy link
Copy Markdown
Contributor

to clarify, I support the change to std::variant, it's always generally preferable to use the std forms when comparable

@tchaikov

Copy link
Copy Markdown
Contributor Author

I think replacing boost::variant with std::variant doesn't have a large benefits being claimed. I don't mind doing it, but I somewhat object to the propaganda

i dropped the "benefits" section from the commit message. hope it's less exaggerating now.

@tchaikov

Copy link
Copy Markdown
Contributor Author

please restore the inlining of RGWListBucketsRequest::eof() and RGWReaddirRequest::eof()

done.

@tchaikov

Copy link
Copy Markdown
Contributor Author

v2:

  • dropped the "benefits" section in the commit message
  • added inline specifier to the previously inlined functions
  • added a dedicated commit to move the eof() member functions to .cc file. the commit is accompanied with the commit message explaining why we should extract them into .cc file.

@tchaikov

Copy link
Copy Markdown
Contributor Author

@mattbenjamin hi Matt, thank you for your review. could you please take another look?

@tchaikov
tchaikov requested a review from mattbenjamin May 12, 2025 03:49
@tchaikov

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@tchaikov

Copy link
Copy Markdown
Contributor Author
apt-get install -y clang-19 lldb-19 lld-19 clangd-19
Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python3-lldb-13 : Conflicts: python3-lldb-x.y
 python3-lldb-19 : Conflicts: python3-lldb-x.y
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
Build step 'Execute shell' marked build as failure

see https://jenkins.ceph.com/job/ceph-pull-requests/158067/consoleFull#724108817fa534114-2506-4c16-be9c-09c932a5aa49

@ivancich ivancich added wip-eric-testing-1 for ivancich testing needs-review and removed needs-qa wip-eric-testing-1 for ivancich testing labels May 29, 2025
@tchaikov

tchaikov commented Jun 2, 2025

Copy link
Copy Markdown
Contributor Author

@mattbenjamin hi Matt, could you please take a look?

Comment thread src/rgw/rgw_file_int.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.

Can we add std:: to the get_if calls for consistency?

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, we can! updated.

tchaikov added 2 commits June 14, 2025 06:14
Move RGWListBucketsRequest::eof() and RGWReaddirRequest::eof()
implementations from header to rgw/rgw_file.cc for better consistency
with our custom  RGWFileHandle::readdir_offset formatting.

Previously, these functions relied on boost::variant's global operator<<,
but we have our own specialized operator<< for readdir_offset in rgw_file_int.h.
Our implementation is optimized for the case where readdir_offset contains a
const char* and uses unlikely() for performance, unlike boost's default
formatter.

By moving implementations to the .cc file (after our custom operator<<
definition), we ensure they use our formatting logic and resolve potential
conflicts. This also properly addresses the fact that friend declarations
don't serve as function declarations. This change also paves the road to
migrate from boost::variant to std::variant, which does not provide the
global operator<<, so we will have to use our operator<< overload.

To preserve the previous inline behavior, both functions are explicitly
marked with the 'inline' keyword. Verification of inlining was performed
using:

```
readelf -s -W --demangle build/src/rgw/CMakeFiles/rgw_a.dir/rgw_file.cc.o | grep "Request::eof"
```
With `CMAKE_BUILD_TYPE=RelWithDebInfo`, both functions are confirmed to be
inlined as they don't appear in the symbol table, maintaining existing
behavior.

Signed-off-by: Kefu Chai <[email protected]>
Replacing boost::variant with std::variant throughout the cephfs related
codebase. This change is part of our ongoing effort to reduce
third-party dependencies by leveraging C++ standard library alternatives
where possible.

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov

Copy link
Copy Markdown
Contributor Author

changelog:

  • add std:: qualifier to get_if() calls to be more consistent.

@tchaikov

Copy link
Copy Markdown
Contributor Author

@mattbenjamin @ceph/rgw hi rgw developers, could you please help review this change?

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

@adamemerson

Copy link
Copy Markdown
Contributor

jenkins test api

@cbodley

cbodley commented Jun 26, 2025

Copy link
Copy Markdown
Contributor

@cbodley
cbodley merged commit 0225e67 into ceph:main Jun 26, 2025
@tchaikov
tchaikov deleted the rgw-std-variant branch June 27, 2025 01:43
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.

6 participants