You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(python): synchronize live tenant allocations - #2952
Synchronize the Python tenant-isolation fixtures through host callbacks. Four tenants each hold 20 MiB before any are released.
Keep three neighbors’ allocations live while the greedy tenant exceeds its 32 MiB limit. Wait for both synchronization points within the test budget.
Before and after
Under AddressSanitizer, the previous fixture timed out at 20 seconds while spinning to keep its allocations live. Nightly log
All eight tenant-isolation tests passed locally with the Python feature enabled. The standard build took 0.84 seconds, and the AddressSanitizer build took 4.94 seconds with Nightly’s Rust toolchain and sanitizer settings.
Risk
Test fixtures only. The assertions still cover per-tenant memory accounting and rejection of an over-limit call.
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Verdict: Looks good — test-only change, no findings, nothing blocking.
What changed:crates/bashkit/tests/integration/python_tenant_isolation_tests.rs (sole file; diff was complete, not truncated). Both tenant-isolation tests replace the 3M-iteration CPU spin used to keep per-tenant 20 MiB / 8 MiB Python allocations alive with a host-callback rendezvous: a wait_for_tenants external function registered via python_with_external_handler, backed by tokio::sync::Barrier + tokio::time::timeout (TENANT_TIMEOUT 20 s).
Checks:
Barrier accounting is correct in both tests. Test 1: Barrier::new(4), exactly 4 tenant tasks wait once; the main task does not participate. Test 2: Barrier::new(4), each generation has exactly 4 arrivals (3 neighbors + main), twice; the over-limit greedy tenant uses a plain tenant() with no handler and never touches the barrier. tokio::sync::Barrier is reusable across generations, so this is sound.
Allocation-liveness argument holds: x is allocated before the wait_for_tenants() calls and referenced after them in print, so the interpreter must keep it live across both rendezvous points; the second generation in test 2 brackets the greedy 64 MiB over-limit attempt, preserving the original assertion (neighbors unaffected, greedy gets MemoryError).
Failure modes degrade to a clear assertion/timeout rather than a hang: a per-tenant-accounting regression means tenants fail before reaching the barrier and each exec still bounded by max_duration(TENANT_TIMEOUT); a sync failure surfaces via the expect("tenant sync ...") messages.
No production code touched, no sandbox/VFS boundary crossed, no new error paths in the interpreter — threat model and knowledge/ docs are unaffected. Test-only, so no new unit tests are owed (this is the test fix for the nightly ASan 20 s spin timeout cited in the description).
Context read beyond the diff:AGENTS.md, the full head version of the test file, and the python_with_external_handler builder plumbing (handler is cloned per python/python3 builtin, consistent with sharing one barrier Arc across tenants).
Could not review: nothing outstanding. (Per project rules I did not build or run tests — no cargo in this shell — so the local 0.84 s / ASan 4.94 s runs cited in the PR description are taken from the author.)
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
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.
What changed
Before and after
Under AddressSanitizer, the previous fixture timed out at 20 seconds while spinning to keep its allocations live. Nightly log
All eight tenant-isolation tests passed locally with the Python feature enabled. The standard build took 0.84 seconds, and the AddressSanitizer build took 4.94 seconds with Nightly’s Rust toolchain and sanitizer settings.
Risk
Test fixtures only. The assertions still cover per-tenant memory accounting and rejection of an over-limit call.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.