Five AI coding sessions share one Linux workstation, and three of them are builders. Each builder runs a full test pipeline against the same PostgreSQL, Redis and object-storage services. Left unpartitioned, the builds compete for 12 hardware threads and 30 GiB of memory: timing tests stop meaning anything, and one run's memory spike can kill another's.
We copied the CI runner's resource envelope onto the workstation: every final gate gets 2 pinned CPUs and a 7 GB memory cgroup. Two locks of different kinds let only one gate run at a time, and lighter checks get CPU slots of their own. Since early November 2026, three builders have worked in parallel under this rule, with rare lock waits and with local gates that predicted CI.
The rule did not stop timing misses on GitHub's runners. On one identical source tree, a 400 ms limit passed once and missed twice, at 533 ms and 498 ms. The evidence points away from neighbouring processes and toward the state of a long-lived test process. Isolating CPUs and memory does not address that, but running the timing tests in a fresh process should.
Context
The product is a multi-tenant SaaS application in a TypeScript monorepo: an API, a background worker and a web app, backed by PostgreSQL, Redis for queues and sessions, and S3-compatible object storage.
The work is done by five Claude Code sessions with fixed roles. The CTO makes the product and architecture decisions and merges every pull request. The sessions message each other directly, and the CTO drives the workstation's sessions from a laptop over Remote Control.
| Session | Machine | Role | Load it puts on the machine |
|---|---|---|---|
| Radad | Laptop, Windows 11 | Architect: plans, briefs, decisions, deployment, directs the builders | Light: git and GitHub reads, research and critic sub-agents |
| Joudie on Legion | Workstation, Ubuntu | Builder | Heavy: builds, checks, database gates, exit proofs |
| Scarlett | Workstation | Builder | Heavy, as above |
| Meg | Workstation | Builder | Heavy, as above |
| Nicole | Workstation | Read-only reviewer | Light to medium: diff reading, review sub-agents |
Each builder works in its own git worktree on its own branch. It pushes after every phase and opens a draft pull request, and GitHub's CI runs on each push. On 8 November the three builders moved five pull requests between them, and Nicole reviewed all five. Every session can also start sub-agents, whose commands run on the same machine, so the real number of processes asking for CPU is higher than the five sessions suggest.
The workload
A builder's pipeline has four kinds of run, and the database gate dominates: about 12 minutes on two cores. The figures are from the builders' reports and the CI logs of 5 to 8 November. Test counts grow with every feature, so they are ranges.
| Run | What it does | Size | Wall time | Where it runs |
|---|---|---|---|---|
pnpm check | Type check, lint, module boundaries, unit tests | 4,364 to 5,077 tests | 240 to 296 s | A check slot on the workstation; CI's check job |
| Database gate | Integration specs against real PostgreSQL, Redis and S3 | 906 to 982 tests | 699 to 758 s | The workstation's final gate; on CI, three parallel shards of 4 to 8 min |
| Exit proof | Drives the built stack over HTTP with no JavaScript, as each type of user | 251 to 289 steps | 105 to 151 s | The workstation's final gate; CI's exit-proof job |
| Browser tests | Playwright against the built web app | 48 to 56 tests | 12 to 13.5 min | CI only: the workstation runs no browser |
Memory. The integration tier runs one Jest worker per job, and its heap grows from suite to suite. CI logs show 560 MB to 1,030 MB by the later suites. Since an out-of-memory failure on 3 November, a worker that ends a suite above 1 GB is replaced (workerIdleMemoryLimit). We have no peak-RSS figure for a whole workstation gate, because none ran under /usr/bin/time.
Demand against supply. At peak, each of three builders wants a check or a gate at the same moment. That is up to 3 × 2 cores against a six-core machine, before PostgreSQL, Redis, sub-agents and the desktop take their share.
The machine and its shared services
The workstation is a Lenovo Legion with an Intel Core i7-9750H: 6 physical cores, 2 hardware threads each, 2.6 GHz base and 4.5 GHz boost. It has 30 GiB of memory and 8 GiB of swap, and runs Ubuntu 26.04.1 on kernel 7.0 with cgroup v2 and systemd 259. Node is 24.21 and pnpm 10.34. The same services that production uses run here too, and every builder shares them.
| Service | On the workstation | On GitHub's CI |
|---|---|---|
| PostgreSQL | 18.6, a systemd service, always on, one server for all builders | postgres:18.6, a fresh container per job, through Testcontainers |
| Redis | 8.0.5, a systemd service, always on, no password (one spec that needs a password is skipped here) | redis:8.2-alpine, a fresh container per job |
| S3 storage | SeaweedFS 4.48, started only for a database gate, on loopback, with a fresh data folder and a key pair made for that run, then removed | SeaweedFS 4.48 in a container |
| Disks | A 915 GB ext4 NVMe for worktrees, and a 1.9 TB NTFS data drive (Linux's ntfs3 driver) for the main checkout and the lock | The runner's own disk |
On CI, the database containers share the runner's 2 vCPUs with the tests: Jest and PostgreSQL compete inside one envelope. On the workstation, a gate's 2 cores and 7 GB hold Node and Jest only. PostgreSQL and Redis serve the gate's queries from outside it, on any core. So a database-heavy test has more room on the workstation than on CI, and local timings are optimistic.
The CTO's laptop runs the same services natively on Windows: PostgreSQL 18, and Memurai, a Redis-compatible server for Windows. Neither starts by itself after a restart; each needs an administrator to start it.
What went wrong
The failures fall into three groups: resource contention, state left behind by a process, and the platform itself. Newest first.
| Date | Where | What happened | Cause | Response |
|---|---|---|---|---|
| 8 Nov | CI, integration branch | A 400 ms limit missed at 533 ms; on the rerun, another 400 ms limit missed at 498 ms | Not the code: the same tree passed on its own pull request | The timing specs run alone in a fresh process |
| 6 Nov | Workstation | The machine restarted during final gates, and the NTFS data drive didn't remount | Platform | Drive mounted by hand, all three gates rerun from the start |
| 6 Nov | CI | The same performance spec missed; the log was cut | As on 8 November | Rerun |
| 5 Nov | CI | 328 ms against a 300 ms limit | Judged a runner stall | Rerun, green |
| 5 Nov | CI | 282 ms against 300 ms: a pass, but a near miss | Same family | None |
| 5 Nov | Workstation | The web app's production build failed in worktrees on the NTFS drive | pnpm's links reach about 164 characters, and ntfs3 breaks links of about 146 or more | New worktrees on the ext4 disk; a relink script for old ones |
| 3 Nov | Integration tests | Out of memory | The Jest worker's heap grows suite by suite | Replace a worker that ends a suite above 1 GB |
| 27 Oct | Laptop | An interrupted build kept the shared gate lock, and the next build waited about 20 minutes before anyone noticed | A lock that outlived its owner | Owner lines on the lock, and a second lock the kernel frees when its process dies |
Two patterns stand out. Every timing miss happened on GitHub's runners; the workstation's gates reported none. And the costly failures were silent: a lock nobody owned, a build that stopped with no message.
Method: copy CI's envelope, then share what's left
The principle: a final gate on the workstation runs in the same envelope as a CI job, so a local pass predicts a CI pass. Our CI jobs run on GitHub's standard runner for a private repository, which we mirrored as 2 vCPUs and 7 GB. Four Linux mechanisms enforce it, and all four ship with a stock Ubuntu.
CPU pinning
taskset -c 0,1 sets the gate's CPU affinity, and every process it starts inherits it: Node, Jest and the build tools. The gate can't use more than two CPUs, and it can't spill onto anyone else's.
A memory cap
systemd-run --user --scope -p MemoryMax=7G runs the gate in a transient cgroup v2 scope. If the gate's processes together pass 7 GB, the kernel reclaims or kills inside that scope only, and the rest of the machine is untouched. We set no Node heap flag, so Node sizes its heap as it would on CI.
Two locks, one gate at a time
A gate takes both locks before it runs. The first is a directory, mkdir .gate.lock, holding an owner line: session, task, commit, folder and start time. mkdir is atomic, and the directory survives a crash, so a stale lock says whose it was. The second is a kernel lock, flock -n /tmp/gates.lock, which the kernel frees when its process dies, so it can't go stale.
The gate's command runs with that descriptor closed (9>&-), so a server it leaves running can't hold the lock, and a shell trap clears both on exit. A busy lock returns exit code 75, and the wrapper refuses a tree with uncommitted changes (exit 76), so every gate result names one commit. Clearing someone else's stale lock is the CTO's decision, never a builder's.
Check slots
pnpm check and single-spec runs don't take the gate lock. A helper tries slot A (CPUs 2 and 3) and then slot B (CPUs 4 and 5), each behind its own flock, and polls every 5 seconds while both are busy. Checks have no memory cap.
Each job owns two whole cores; their siblings stay free of pinned work
Intel i7-9750H, 6 cores with 2 threads each. Top row: a core's first thread. Bottom row: its hyperthread sibling.
lscpu -e and the check-slot and gate scripts on the workstation, 8 November 2026.The pairs are whole physical cores. On this CPU, logical CPUs 0 to 5 are cores 0 to 5, and 6 to 11 are their hyperthread siblings (0 with 6, 1 with 7, and so on). Pinned work uses 0 to 5 only, so no two pinned jobs share a core's execution units. The services aren't pinned, and the scheduler can still place them on a sibling. At most one gate and two checks run at once: six cores of work on a six-core machine.
The envelope makes local gates trustworthy, but they are also slow and serialised. So while a builder iterates, GitHub's CI is the gate: she pushes once pnpm check passes, and the workstation's gates run once, on a pull request's final head. CI was estimated at about $0.006 a runner-minute. Splitting the database tier into three parallel shards cut a CI run from about 17 minutes to about 7.
Results
The rule held memory and concurrency. It didn't make CI's timings stable. The figures cover the workstation's uptime from 7 November at 17:51 to 8 November, which includes every gate below.
| Measure | Result | Source |
|---|---|---|
| Out-of-memory kills | 0 | Kernel counter oom_kill since boot |
| Swap used | 0 B; 0 pages in or out | swapon --show, pswpin, pswpout |
| Concurrent builders | 3, plus a reviewer and an architect, moving 5 pull requests in a day | Session reports |
| Database gate, 2 cores and 7 GB | 727 s for 913 tests; 758 s for 982 | Wrapper logs |
| Exit proof, 2 cores and 7 GB | 124 s for 274 steps | Wrapper and proof logs |
pnpm check in a slot | 268 s | Wrapper log |
| Passed locally, failed a function on CI | 0 cases | Three pull requests |
| CI timing misses on a tree that passed elsewhere | 3, all on GitHub's runners | CI logs |
The envelope did what it was for. Every pull request whose workstation gates passed also passed CI's functional jobs, and no builder reported a run disturbed by another's gate. It didn't do two things.
- It isn't a perfect replica. PostgreSQL and Redis serve a local gate from outside its 2 cores, so database-heavy tests get more CPU locally than on CI. That makes local timings optimistic, and it may explain why the workstation never reported a timing miss while CI did.
- It caps memory but not swap.
MemoryMax=7Gsets noMemorySwapMax, so a gate over its cap could spill into swap and slow down before the kernel kills it. That hasn't happened since boot, but nothing in the rule prevents it.
Case study: a timing miss that wasn't the code
The strongest evidence came from an accident. A pull request passed CI. Merged into the integration branch, the same source tree failed CI twice. Git confirms the two commits hold an identical tree (7dec285fcbf3). Whatever failed, it wasn't the code.
The first run missed in the first timing spec: a write of 50 rows took 533 ms against a 400 ms limit. In the same run, the next measurement, a write of 500 rows, took 275 ms. Ten times the work took half the time. The rerun passed that spec and missed in the second: a state change took 498 ms against 400. On a healthy run these operations take 15 to 45 ms.
Four hypotheses, tested against that evidence
- RejectedThe code is slow.
The identical tree passed, and the cost didn't scale with the work.
- RejectedNeighbouring test suites took the CPU.
Each CI shard runs on its own virtual machine with
maxWorkers: 1, so no other suite ran beside the timing spec. We had first assumed this cause, and reading the configuration refuted it. - SupportedThe test process's own state.
By the time the timing specs ran, the single Jest worker had run every earlier suite in its shard, and its heap had grown to between 560 MB and 1 GB. A garbage-collection pause, or leftovers from earlier suites, would land on whichever measurement came first. That fits a small write costing more than a large one. On CI, PostgreSQL also shares the same 2 vCPUs.
- OpenThe virtual machine's host.
A cloud VM can lose CPU time to other tenants on its host, and nothing inside the job can observe that.
Each miss ran 9% to 33% over its limit; isolated, the same write used 11%
Measured time as a share of its limit, GitHub CI, 5 to 8 November 2026
The intervention. The CTO chose to isolate the timing specs and leave every limit unchanged. Raising a limit to absorb noise would also hide a real slowdown. The fix runs the two *-performance specs alone, in a fresh Jest process, after the shard's other suites. It runs them in band, which turns off the 1 GB worker guard, so it does this for those two files only.
First observation. In the fresh process, the write that had taken 533 ms took 42 ms, and the process's heap ended near 655 MB. That is one run, so it supports hypothesis 3 without proving it. The test is the next few weeks of runs: if misses mostly stop, the process's state was the cause; if they continue, the host was.
Can Windows do this?
Yes at the kernel level, and only partly at the command line. Windows has had per-process CPU affinity and Job Objects, its counterpart to cgroups, for over two decades. What Linux adds is composition: each mechanism is one stock command, and together they fit in two short shell scripts.
| Mechanism | Linux, as used here | Windows, natively | Windows, through WSL2 |
|---|---|---|---|
| Pin to CPUs | taskset -c 0,1 | start /affinity 3 in cmd (a hex mask for CPUs 0 and 1), or ProcessorAffinity from PowerShell; children inherit it | taskset, unchanged |
| Cap a process tree's memory | systemd-run --scope -p MemoryMax=7G | A Job Object with a job memory limit; no stock command, so a small PowerShell or C# tool | systemd-run, once systemd is enabled in wsl.conf |
| Cap a tree's CPU time | CPUQuota= on the same scope (not used here) | A Job Object's CPU rate control | As Linux |
| A lock that dies with its owner | flock | A named mutex: when its owner dies, the next waiter receives it marked abandoned | flock, unchanged |
| A lock that shows its owner | mkdir plus an owner file | mkdir is atomic on NTFS too | As Linux |
| Pin to whole physical cores | lscpu -e shows each CPU's core | Sysinternals Coreinfo or GetLogicalProcessorInformationEx show the pairs, and affinity can target them | Not controllable: WSL2's CPUs are a VM's virtual CPUs |
WSL2 runs the whole method unchanged, with two costs. The VM has its own CPU and memory budget (.wslconfig), and the method's caps sit inside it. And the VM hides the physical topology, so "two whole cores" becomes "two virtual CPUs". Repositories should live on WSL2's own ext4 disk: /mnt/c crosses into Windows through a much slower file protocol. That is the same lesson the workstation taught on its NTFS drive.
Until early November the builds ran on the CTO's Windows laptop, and the rule there was a count: at most two builds running gates at once, behind one shared lock, with no pinning and no memory caps. A count limits contention, but it doesn't make a run's resources predictable, and nothing tied the lock to a live process. That gap cost the 20-minute wait in section 04. Moving the builders to the Linux workstation, under the envelope and the two locks, addressed both.
Limitations
This is a field report, not a controlled experiment. Read its claims with these limits in mind.
- Small sample. One machine, a few days of runs, and four timing incidents. Nothing was run twice under controlled conditions.
- Self-reported numbers. The builders, which are AI sessions, reported most figures from their own logs. CI logs were checked directly. No peak memory was measured for a whole workstation gate.
- Two cores aren't two vCPUs. The laptop-class CPU boosts from 2.6 to 4.5 GHz with temperature and load, and a cloud vCPU is a shared hyperthread at its host's clock. The envelope matches count and memory, not speed.
- A partial envelope. The services run outside the cgroup; swap isn't capped; CPU time isn't capped. Each makes the workstation more generous than CI.
- An unobservable host. Contention on GitHub's hosts can't be tested from inside a job.
- One supporting run. The fresh-process result is a single observation.
Conclusions and a recipe
Several AI builders on one machine have the same problem as several engineers on one CI server: they share CPUs, memory, services and locks. They just hit it faster, and more quietly. They don't get tired, they start sub-agents, and none of them notices another's lock unless the lock says whose it is. Making each run's resources fixed and each lock's owner visible turned that from a source of silent failures into a queue.
The second lesson is about measurement. Isolating CPUs and memory makes a run's resources predictable. It doesn't make a long-lived process's state predictable. A timing test inherits whatever the process did before it, so it needs a fresh process as much as a quiet core.
The recipe, in the order we'd set it up again
- Mirror CI's envelope for final gates only.Pin to as many CPUs, and cap at as much memory, as a CI job gets. Iterate against CI itself.
- Partition by physical core.Read the topology with
lscpu -e, give each job whole cores, and keep pinned work off the hyperthread siblings. - Use two locks.One the filesystem keeps, with an owner line, and one the kernel frees when its process dies. Clearing a stale lock stays the CTO's call.
- Give light work its own slots.A check never waits behind a 12-minute gate, and a waiting job polls instead of oversubscribing.
- Make every result name one commit.Refuse a gate on a dirty tree, and log each run's exit code and duration.
- Decide where the services sit.Put the database inside the envelope for timing parity with CI, or accept that local timings are optimistic, and write that down.
- Run timing tests in a fresh process.Never raise a limit to absorb noise.
- On Windows, use WSL2.The same scripts run there; a native setup needs Job Object tooling.
The scripts and the machine
Both scripts are as they ran on 8 November 2026, with some header comments shortened and project names removed, and were checked for secrets first. Neither is in the repository. The gate wrapper sources a SeaweedFS start-and-stop helper, not shown here.
The check-slot helper, ~/check-slot.sh
#!/usr/bin/env bash
# The Legion's two shared check slots: pnpm check, and any spec run that isn't a gate,
# runs on A (CPUs 2,3) or B (CPUs 4,5), each held by a flock. Gates stay on CPUs 0-1
# under the gate lock; 6-11 stay idle. It never touches the gate lock or the cgroup.
check_slot() {
if [ $# -eq 0 ]; then
echo "usage: check_slot <cmd...>" >&2
return 2
fi
(
asked=$(date +%s)
told=
while :; do
for pair in A:2,3 B:4,5; do
slot=${pair%%:*}
cpus=${pair#*:}
exec {fd}>"/tmp/check-slot-$slot.lock" || exit 1
if flock -n "$fd"; then
began=$(date +%s)
echo "[check-slot] slot $slot (CPUs $cpus) taken at $(date -Is), after $((began - asked)) s" >&2
taskset -c "$cpus" "$@" {fd}>&-
rc=$?
echo "[check-slot] slot $slot released at $(date -Is), exit $rc, $(($(date +%s) - began)) s" >&2
exit "$rc"
fi
exec {fd}>&-
done
if [ -z "$told" ]; then
told=1
echo "[check-slot] both slots busy at $(date -Is): waiting" >&2
fi
sleep "${CHECK_SLOT_POLL:-5}"
done
)
}
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
check_slot "$@"
fi
A builder's gate wrapper
#!/usr/bin/env bash
# check-* pnpm check: a check slot, no lock, clean tree unit-* unit runs: a check slot, no lock
# gate-* db gate, exit proof: lock + cgroup, clean tree any other name: lock + cgroup
source "$HOME/check-slot.sh"
L=/run/media/alaa/Data/theDev/.gate.lock; N=$1; shift
SHA=$(git rev-parse --short HEAD); LOG=/tmp/gate-$N-$SHA.log
case "$N" in gate-*|check-*) [ -z "$(git status --porcelain)" ] || { echo "dirty tree: commit first"; exit 76; } ;; esac
s=$(date +%s)
case "$N" in
check-*|unit-*) check_slot "$@" > "$LOG" 2>&1; rc=$? ;;
*)
mkdir "$L" 2>/dev/null || { echo "busy: $(cat "$L/owner" 2>/dev/null || echo 'a lock with no owner file')"; exit 75; }
exec 9>/tmp/gates.lock
flock -n 9 || { rmdir "$L"; echo "busy: /tmp/gates.lock"; exit 75; }
echo "Joudie on Legion, $N on $SHA in $PWD, since $(date -Is)" > "$L/owner"
source "$HOME/s3-helper.sh"; S3=0; case "$N" in gate-db*) S3=1 ;; esac
trap 's3_stop; rm -f "$L/owner"; rmdir "$L" 2>/dev/null' EXIT
trap 'exit 130' INT TERM HUP
{ if [ "$S3" = 1 ]; then s3_start || exit 1; fi; systemd-run --user --scope -p MemoryMax=7G --quiet taskset -c 0,1 "$@"; } > "$LOG" 2>&1 9>&-; rc=$?
s3_stop ;;
esac
echo "exit=$rc duration=$(( $(date +%s) - s ))s" >> "$LOG"
echo "$LOG: exit=$rc"; exit "$rc"
| Item | Value |
|---|---|
| CPU | Intel Core i7-9750H, 6 cores, 2 threads each, 2.6 GHz base, 4.5 GHz boost |
| CPU numbering | CPUs 0 to 5 are cores 0 to 5; CPUs 6 to 11 are their siblings (0 with 6, 1 with 7, through 5 with 11) |
| Memory | 30 GiB, with 8 GiB of swap |
| System | Ubuntu 26.04.1, kernel 7.0.0, cgroup v2, systemd 259 |
| Toolchain | Node 24.21.0, pnpm 10.34.5 |
| Services | PostgreSQL 18.6, Redis 8.0.5, SeaweedFS 4.48 |
| Disks | 915 GB ext4 NVMe for worktrees; 1.9 TB NTFS through ntfs3 for the main checkout and the gate lock |