fix(io_context): decouple concurrency_hint == 1 from lockless mode (#…#316
Draft
mvandeberg wants to merge 1 commit into
Draft
fix(io_context): decouple concurrency_hint == 1 from lockless mode (#…#316mvandeberg wants to merge 1 commit into
mvandeberg wants to merge 1 commit into
Conversation
|
An automated preview of the documentation is available at https://316.corosio.prtest3.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-07-10 22:53:56 UTC |
325c43c to
88bcce9
Compare
…ppalliance#310) A concurrency_hint of 1 silently enabled full single-threaded lockless mode: scheduler mutex/condvar, per-descriptor locks, IOCP dispatch mutex, and io_uring ring/dispatch mutexes were all disabled, plus io_uring got SINGLE_ISSUER/DEFER_TASKRUN. This made cross-thread post() undefined behavior, contrary to asio (where a plain integer hint never disables locking) and to what migrating users expect. A hint now only tunes performance and never changes the safety contract: - Remove the three hint == 1 -> single_threaded coupling sites (backend-tag template ctor, io_context(unsigned) ctor, and normalize_options, which is deleted along with the now-dead configure_single_threaded_() member). - Rename the public opt-in io_context_options::single_threaded -> single_threaded_lockless, which remains the sole way to enable lockless mode (still gating the io_uring SINGLE_ISSUER flags). The explicit, descriptive name replaces an innocuous flag that read like a mere performance tweak. - Default ctor clamp max(2u, hardware_concurrency()) -> max(1u, ...): the "2" floor existed only to dodge the removed trap; floor at 1 still guards a 0 return. Tests: the resolver/stream_file single-threaded restriction tests switch to explicit opts.single_threaded_lockless; new testHintOneIsThreadSafe proves cross-thread post() into a hint == 1 context is TSan-clean across all backends (verified: fails under TSan with the coupling restored). Docs and benchmarks: header Doxygen (option, Thread Safety, default ctor), the io-context and configuration guide pages, and all perf/bench/corosio sources updated for the new option name. Fixes cppalliance#310
88bcce9 to
9141d96
Compare
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.
…310)
A concurrency_hint of 1 silently enabled full single-threaded lockless mode: scheduler mutex/condvar, per-descriptor locks, IOCP dispatch mutex, and io_uring ring/dispatch mutexes were all disabled, plus io_uring got SINGLE_ISSUER/DEFER_TASKRUN. This made cross-thread post() undefined behavior, contrary to asio (where a plain integer hint never disables locking) and to what migrating users expect.
A hint now only tunes performance and never changes the safety contract:
Tests: the resolver/stream_file single-threaded restriction tests switch to explicit opts.single_threaded_unsafe; new testHintOneIsThreadSafe proves cross-thread post() into a hint == 1 context is TSan-clean across all backends (verified: fails under TSan with the coupling restored).
Docs: header Doxygen (option, Thread Safety, default ctor) plus the io-context and configuration guide pages updated.
Fixes #310