On the live resolution path collectRootJsonlSessionIds already stat()s each root jsonl for its mtime-window filter, then fileBelongsToTeam stat()ed the very same file again for its cache validation -- two fs.stat syscalls (plus two Stats allocations) per file, every poll. fileBelongsToTeam now takes an optional precomputed stat and the mtime-filter caller passes the stat it already has, so the file is statted once. Measured 20 files -> 20 stat calls on the mtime path (was ~40). Using a single stat snapshot is also slightly more consistent than two reads that could straddle a concurrent write. The other call site (subagent scan) passes no stat and is unchanged (fileBelongsToTeam stats it itself). Adds a regression test that a caller-supplied stat is the one recorded in the affinity cache. |
||
|---|---|---|
| .. | ||
| build | ||
| features | ||
| http | ||
| ipc | ||
| services | ||
| utils | ||
| sentry.test.ts | ||