Skip to content

fix(registry): add large-thread-count feature to raise slab MAX_THREADS#4

Closed
Maxence Caron (mc-ditto) wants to merge 8 commits intodeprecate-macros-for-ditto-loggingfrom
large-thread-count
Closed

fix(registry): add large-thread-count feature to raise slab MAX_THREADS#4
Maxence Caron (mc-ditto) wants to merge 8 commits intodeprecate-macros-for-ditto-loggingfrom
large-thread-count

Conversation

@mc-ditto
Copy link
Copy Markdown

Summary

  • Adds a large-thread-count feature flag (off by default) to tracing-subscriber
  • When enabled, a custom SlabConfig raises MAX_THREADS from 4 096 to 131 072, preventing panics when large numbers of native threads are spawned on high-core nodes
  • When disabled, the trait default (4 096) applies — no behaviour change for existing consumers
  • This avoids the need for a separate sharded-slab fork or workspace-level [patch.crates-io] override

Test plan

  • cargo test -p tracing-subscriber --features large-thread-count — all tests pass
  • cargo test -p tracing-subscriber — all tests pass without the feature

🤖 Generated with Claude Code

Adds a `large-thread-count` feature (off by default) that raises the
sharded-slab MAX_THREADS limit from 4 096 to 131 072. This prevents
tracing_subscriber from panicking on high-core nodes where large numbers
of native threads are spawned (e.g. by the Ditto SDK in load-gen pods).

When the feature is disabled the upstream default of 4 096 is used via
the Config trait's default impl, so there is no behaviour change for
existing consumers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… enabled

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…l init

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gate

The large-thread-count Cargo feature caused complex activation problems
across multiple workspace boundaries in the Ditto monorepo. Since this
fork is always used with Ditto builds, raise MAX_THREADS = 131_072
unconditionally — no feature flag required.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Make MAX_THREADS = 131_072 conditional on the `large-thread-count` feature
flag rather than unconditional. The feature was previously removed to work
around a cross-workspace patch issue in the ditto monorepo (now fixed by
updating .cargo/config.toml patches).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
On 32-bit targets (e.g. wasm32-unknown-unknown), MAX_THREADS = 131 072
requires 17 bits for thread IDs, which exhausts sharded-slab's bit-packing
budget (total usize width = 32 bits) and causes a compile-time overflow in
slot::Generation::LEN. Guard the raised constant behind
`target_pointer_width = "64"` so wasm32 and other 32-bit targets fall back
to the sharded-slab default of 4 096.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

The logic is fine, but I'd prefer my comments to be addressed before we start using this.

Comment thread tracing-subscriber/src/registry/sharded.rs Outdated
Comment thread tracing-subscriber/src/registry/sharded.rs Outdated
@maddiemort Madel​eine Mortensen (maddiemort) dismissed their stale review April 17, 2026 18:03

My top concern was addressed

Comment on lines +931 to +935
// Confirm the Registry pool is actually parameterised on SlabConfig —
// this is a compile-time check: if `Registry::spans` ever changes to a
// different Config type, the type annotation below will fail to compile.
let registry = Registry::default();
let _: &Pool<DataInner, SlabConfig> = &registry.spans;
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.

Nice, that should do the trick - thanks

@mc-ditto Maxence Caron (mc-ditto) marked this pull request as draft April 17, 2026 18:07
@mc-ditto Maxence Caron (mc-ditto) marked this pull request as ready for review April 17, 2026 18:07
@mc-ditto Maxence Caron (mc-ditto) deleted the large-thread-count branch April 17, 2026 18:08
@mc-ditto Maxence Caron (mc-ditto) restored the large-thread-count branch April 17, 2026 18:08
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.

2 participants