Repository navigation
common/options: build option tables in place - #71665
Merged
SrinivasaBharath merged 1 commit intoNov 13, 2026
Merged
Conversation
Contributor
Author
|
@ceph/core hi maintainers , could you help review this change? |
Contributor
Author
|
@ceph/core hi maintainers , just a gentle ping? |
rzarzynski
approved these changes
Oct 14, 2026
rzarzynski
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Looks like a workaround for https://tracker.ceph.com/issues/81551 – perhaps Fixes would be adequate.
y2c.py generates each get_{name}_options() as one braced list:
return std::vector<Option>({ Option(...)..., Option(...)..., ... });
This is expensive in two ways.
Every Option backing the initializer_list is live at once in a single
frame. -fstack-usage reports 746192 bytes for get_global_options()
(857 entries) and 404736 for get_rgw_options() (458), far larger than
any other function in these libraries.
initializer_list elements are const, so vector cannot move out of
them. Every Option is built on the stack, copied to the heap, then
destroyed, duplicating each name, description, tag and service string.
Use reserve() and emplace_back() instead. emplace_back() returns a
reference to the new element, so the .set_...() chain applies to it
directly: each Option is built in the vector, with no stack temporary
and no copy.
On x86-64 (gcc 14.2.0, -O2 -fstack-clash-protection
-fstack-protector-strong) get_global_options() goes from a 746192 to a
1136 byte frame, from 445856 to 85884 bytes of .text, and compiles in
3.5s instead of 18.8s. get_rgw_options() goes from 404736 to 3792
bytes of frame.
The frame size also breaks unwinding on arm64. A frame that large
makes gcc emit stack-clash probing as a loop, and gcc 14 (up to at
least Debian's 14.2.0-19) gets the unwind info for that loop wrong by
the callee-save size [0]. gdb, C++ exceptions, and full tcmalloc
taking a heap-growth backtrace then read garbage instead of the return
address. Where pointer authentication is enforced this traps, and
ceph-mon/ceph-osd have been seen dying with SIGILL at startup, even
for `--version` [1]. A small frame avoids the probing loop without
waiting for a compiler fix to reach stable distros.
The generated definitions do not change: --raw output (for pasting
option definitions elsewhere, not used by the build) and the generated
legacy option headers are byte-identical across all 13 tables, and the
.cc differs only in how each Option is appended.
[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119610
[1] https://bugzilla.proxmox.com/show_bug.cgi?id=7941
Fixes: https://tracker.ceph.com/issues/81551
Signed-off-by: Kefu Chai <[email protected]>
tchaikov
force-pushed
the
wip-options-avoid-stack-init-list
branch
from
October 22, 2026 01:02
8e42ea1 to
4755987
Compare
Contributor
Author
thanks. added "Fixes" tag. |
Contributor
|
This PR has been added to wip-bharath11-testing-20261027.070430-main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
y2c.py generates each get_{name}_options() as one braced list:
This is expensive in two ways.
Every Option backing the initializer_list is live at once in a single frame.
-fstack-usagereports 746192 bytes forget_global_options()(857 entries) and 404736 forget_rgw_options()(458), far larger than any other function in these libraries.initializer_listelements areconst, so vector cannot move out of them. Every Option is built on the stack, copied to the heap, then destroyed, duplicating each name, description, tag and service string.Use
reserve()andemplace_back()instead.emplace_back()returns a reference to the new element, so the.set_...()chain applies to it directly: each Option is built in the vector, with no stack temporary and no copy.On x86-64 (gcc 14.2.0,
-O2-fstack-clash-protection-fstack-protector-strong)get_global_options()goes from a 746192 to a 1136 byte frame, from 445856 to 85884 bytes of.text, and compiles in 3.5s instead of 18.8s.get_rgw_options()goes from 404736 to 3792 bytes of frame.The frame size also breaks unwinding on arm64. A frame that large makes gcc emit stack-clash probing as a loop, and gcc 14 (up to at least Debian's 14.2.0-19) gets the unwind info for that loop wrong by the callee-save size [0]. gdb, C++ exceptions, and full tcmalloc taking a heap-growth backtrace then read garbage instead of the return address. Where pointer authentication is enforced this traps, and
ceph-mon/ceph-osdhave been seen dying with SIGILL at startup, even for--version[1]. A small frame avoids the probing loop without waiting for a compiler fix to reach stable distros.The generated definitions do not change:
--rawoutput (for pasting option definitions elsewhere, not used by the build) and the generated legacy option headers are byte-identical across all 13 tables, and the .cc differs only in how each Option is appended.[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119610
[1] https://bugzilla.proxmox.com/show_bug.cgi?id=7941
Fixes: https://tracker.ceph.com/issues/81551
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.