Skip to content

Make the server coroutine stack size a build setting - #148

Merged
dallison merged 4 commits into
mainfrom
coroutine-stack-size
Oct 31, 2026
Merged

dallison merged 4 commits into
mainfrom
coroutine-stack-size

Conversation

@dallison

Copy link
Copy Markdown
Owner

Summary

  • Server and shadow coroutines take their stack size from a build setting. The default stays 64 KiB.
  • Set it with subspace.coroutine_stack_size(bytes = N), --//:coroutine_stack_size=N, or -DSUBSPACE_COROUTINE_STACK_SIZE=N. N must be a positive multiple of 4096. Clients do not need the same value, because this is process memory rather than shared memory.
  • AddressSanitizer builds still use at least 256 KiB. A configured size larger than that is kept.

Test plan

  • bazelisk test //common/async:async_test //shadow:shadow_test --config=macos_arm64
  • bazelisk test //common/async:async_test --//:coro_backend=asio --config=macos_arm64
  • --//:coroutine_stack_size=16384 shows up as -DSUBSPACE_COROUTINE_STACK_SIZE=16384 on the server compile
  • --//:coroutine_stack_size=1000 is rejected at analysis time

The default stays 64 KiB, and AddressSanitizer builds still use at least 256 KiB, so a deployment can choose a smaller stack without changing shared memory.
The statistics check was reading a backlog that can skip a retired slot, and the recovery test was walking the server channel map from another thread.
…buffers on recovery.

The lock only existed so tests could inspect server state from another thread. On Android the buffer count can outlive the memfd, which left the recovered telemetry publisher unable to attach.
A late subscriber can see a skipped sequence in messages that were already published, and that backlog can arrive after the first read. Compare a message that shows up only after the subscriber has waited.
@dallison
dallison merged commit fc10a6e into main Oct 31, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant