Skip to content

Raise test thread stacks from 2 MiB to 8 MiB - #335

Open
EnRaiha wants to merge 1 commit into
mainfrom
chore/test-thread-stack-8mib
Open

EnRaiha wants to merge 1 commit into
mainfrom
chore/test-thread-stack-8mib

Conversation

@EnRaiha

@EnRaiha EnRaiha commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Why

Rust gives spawned threads a 2 MiB stack; the Linux main thread gets 8 MiB. The bootstrap runtime already raises this for the server, but the runtimes the test macros build keep the default, so debug-profile runs of the native suite abort with thread ... has overflowed its stack:

RUST_MIN_STACK native_error_code_classification
2 MiB (default) 6/7 abort (24 overflow reports)
4 MiB 7/7 pass
8 MiB 7/7 pass

CI passes at the default because the ci profile has smaller frames; this change is for the debug profile every contributor runs locally.

What changed

  • .cargo/config.toml (new): [env] RUST_MIN_STACK = "8388608" — every process cargo runs gets the main-thread size, so cargo test, cargo nextest run and cargo run behave the same without an exported variable.

The file is added with git add -f: .cargo/ is gitignored in this repository, and this is a config file's intended home (it changes no source and no dependency).

Platform

Tested on Linux (x86_64): the main thread gets an 8 MiB stack (ulimit -s), while Rust spawns its own threads with 2 MiB — the mismatch the change removes. The abort ladder above was measured with a debug build on that host; CI's ci profile already fits the default. The setting is a floor for cargo-run processes, so other platforms keep their own defaults when it is not the binding limit.

Steps to test

  1. env -u RUST_MIN_STACK cargo nextest run -p nodedb --test native -E 'test(native_error_code_classification)' → 7 passed
  2. env -u RUST_MIN_STACK cargo nextest run -p nodedb --test native -E 'test(vector_search_serializes_distance)' → 1 passed

Without the change, both abort at the default stack on a debug build.

Behaviour changes

None in the product. The change raises the stack floor for the processes cargo runs (tests, cargo run); no query path changes.

No issue to close: the stack default is the task.

Rust spawns threads with a 2 MiB stack; the Linux main thread gets 8 MiB.
The bootstrap runtime raises this for the server, but test runtimes are built
by the tokio test macro and keep the default, so debug-profile runs of the
native and wire suites abort with "thread ... has overflowed its stack"
(2 MiB: 6/7 abort; 4 MiB and above: clean). Set RUST_MIN_STACK for every
process cargo runs, so a local run needs no exported environment variable.
Copilot AI lite review requested due to automatic review settings September 17, 2026 06:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@EnRaiha EnRaiha added the run-ci Opt this PR into the full test suite; re-add to force a re-run label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci Opt this PR into the full test suite; re-add to force a re-run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants