Repository navigation
Serialize the nlp-engine model-loading tests and bound model load with a timeout - #1769
Merged
Merged
Conversation
…h a timeout (closes #1761) cargo test -p nodespace-nlp-engine hung at 0% CPU: the parallel harness ran the 11 model-loading integration tests concurrently, racing to initialize the process-global llama.cpp/Metal backend and deadlocking. Serialize those tests with serial_test's #[serial] so first-time backend init cannot race, and bound the backend-init + model-load on a dedicated worker thread with a 120s timeout so a genuinely stuck load fails fast with an error instead of hanging forever. The Mutex-based drop-at-exit backend design is unchanged; the guard never leaves the worker thread. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
4 tasks
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.
Summary
cargo test -p nodespace-nlp-enginehung indefinitely at 0% CPU: the parallel harness ran the 11 model-loading integration tests concurrently, racing to initialize the process-global llama.cpp/Metal backend and deadlocking.--test-threads=1passed all 11 in ~13s.Change
serial_test's#[serial](added as a dev-dependency) on all 11 integration tests, so first-time backend init can no longer race under the parallel harness. The 3 stub tests are untouched.load_model_with_timeoutruns the blocking backend-init + model-load on a dedicated worker thread with a 120s budget, returning an error instead of hanging forever if a first-time Metal/GPU init genuinely stalls.The deliberate
Mutex<Option<LlamaBackend>>drop-at-exit design is unchanged — the backendMutexGuardis created and dropped entirely inside the worker thread and never crosses a thread boundary; only theSendLlamaModelis returned. Loads across services stay serialized exactly as before.Verification
cargo test -p nodespace-nlp-engine(no--test-threads) passes — 108 lib + 11 integration tests, process pinned at ~95% CPU (the decisive contrast with the 0% hang).cargo clippy -p nodespace-nlp-engine --all-targets -- -D warnings+cargo fmt --checkclean, no suppression.Closes #1761.