inspect: allow overriding the shared pool thread count - #207
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
The inspect pool is process-wide and its width derives from available_parallelism, so there is no way to reproduce a different thread regime on one machine. glibc allocates arenas per contending thread, so pool width changes how allocations interleave -- which is the variable under investigation in cortexkit#205. AFT_INSPECT_POOL_THREADS overrides the derivation at pool init: parsed as usize, clamped to 1..=512, with anything absent or unparseable falling through to the existing derivation unchanged. Deliberately undocumented and not a config field -- a dev knob in the same class as AFT_STORM_SCALE and AFT_SEMANTIC_QUIET_WINDOW_MS, per the standing rule against low-value config surface.
46b0a30 to
dd44bb4
Compare
|
Both cubic findings were valid. Fixed in P2 — the race is real and I verified the path rather than taking it on trust. Split the parsing out of the env read: fn default_pool_size() -> usize {
resolve_pool_size(std::env::var("AFT_INSPECT_POOL_THREADS").ok().as_deref())
}
fn resolve_pool_size(override_value: Option<&str>) -> usize { … }Tests now call P3 — renamed to Re-verified after the change: |
The dev knob you specced on #205. Built to your shape:
default_pool_size(), parsed asusize,clamp(1, 512)docs/config— dev knob, same class asAFT_STORM_SCALEandAFT_SEMANTIC_QUIET_WINDOW_MSTests cover override-wins, the floor clamp, the 512 cap, and both unparseable shapes (
"wide","-4") falling through to the derivation. Each assertion was watched fail before being trusted — removing the cap givesleft: 100000, right: 512.Two notes on how the test is built, since the trap here is real:
INSPECT_POOLis a process-globalLazyLock, so anything testing through the pool would silently pass once another test touched it first. The tests calldefault_pool_size()directly instead — the parsing and clamping is the logic worth covering and it's pure.They take
crate::test_env::process_env_lock()before mutating the env, matchingtool_path.rs. libtest runs unit tests concurrently in one process, so without that lock these would race any other env-mutating test in the binary. TheEnvGuardrestores the prior value on drop, including the unset case.Verification:
cargo nextest run -p agent-file-tools --lib2284 passed, 6 skipped ·-E 'test(inspect)'344 passed · release build clean ·cargo fmt --checkclean · clippy 18 findings on this branch and 18 onmainat8bd35ff4, so the change adds none.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Allow overriding the inspect shared pool thread count via
AFT_INSPECT_POOL_THREADSto reproduce thread-regime issues in #205. Unset or invalid values leave the current derivation unchanged.New Features
AFT_INSPECT_POOL_THREADSat pool init.usize; clamp to 1..=512.available_parallelism()capped at 8.AFT_STORM_SCALEandAFT_SEMANTIC_QUIET_WINDOW_MS.Refactors
resolve_pool_size()for testable parsing/clamping; added unit tests for overrides, clamping, and invalid fallbacks.Written for commit dd44bb4. Summary will update on new commits.
Greptile Summary
The PR adds a bounded, development-only environment override for the inspect shared pool size while preserving the existing derivation for absent or invalid values.
AFT_INSPECT_POOL_THREADSwhen initializing the shared pool.usizeand clamps it to1..=512.Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Reviews (2): Last reviewed commit: "inspect: allow overriding the shared poo..." | Re-trigger Greptile