Measurement · 10 October 2026
Where a soft-PLC's scans wait: a lock census, from 113,972 sync waits to 31
Eight-second execution-trace censuses of a 27–32-task runtime on a PREEMPT_RT kernel, taken across a series of releases that moved the bulk of external reading and writing off the scan's locks.
Question
On a PREEMPT_RT kernel, any load burst re-formed a convoy in which every scan task stalled together. Where do the scan threads actually wait, and which of those waits can be removed?
Method
The standing instance ran the same demonstration project throughout: 32 tasks
in September, 27 in October. On each build, an 8-second Go execution trace was
taken and every goroutine synchronization wait was attributed to the lock and
call site that caused it (trace-sync-census.py). Every census was taken on
the same instance, on a PREEMPT_RT kernel throughout; the kernel build changed
between the September and October series. Real-time thread scheduling for the
scan tasks was turned on between them too. CPU profiles
and the runtime’s own counters were read alongside it to explain each number.
Each release changed one lock family, and the census was read again before the next change. The table shows the releases that moved the number and the two that did not; both flat results were kept and explained.
Result
| Build | Sync waits / 8 s | What changed |
|---|---|---|
| 1.0.1529 | 111,749 | the convoy, before this series |
| 1.0.1530 | 113,972 | cheaper reads — and no change in the total |
| 1.0.1531 | 36,654 | the historian sampler taken off the variable walk |
| 1.0.1532 | 6,685 | output synchronization |
| 1.0.1535 | 5,549 | first phase complete |
| 1.0.1536 | 5,619 | external writes land at the scan boundary, on the task’s own thread — no change |
| 1.0.1537 | 3,451 | the writers’ routing walks removed |
| 1.0.1540 | 3,142 | compute-tier marshalling batched; global writes take one lock |
| 1.0.1543 | 1,150 | one lock per global array (1.0.1541), then per scalar member; 3,638 historian tags removed |
| 1.0.1778 | 609 | (27 tasks) |
| 1.0.1780 | 31 | 53,312 dead historian tags removed |
Three results matter more than the total:
- 1.0.1530 did not move, and that was the most useful number in the series. Each read had become cheaper, but the historian sampler (3,697 tags on a 20 ms tick, with a pass taking about 57 ms) ran back to back, so its read rate was set by how fast the runtime answered. Cheaper reads produced more reads. Making the reader cheaper could not fix a reader with no budget.
- 1.0.1536 did not move either. Writes from outside now landed at the scan boundary, as designed, but the writer’s cost had been the walks it made to find each variable’s owner. Removing those walks in 1.0.1537 moved the number.
- The last large drop was not code. The 1.0.1780 lock change did not measurably move the census by itself (942–980 waits against 609 on 1778, at higher load). The drop to 31 came when a new report showed that 53,318 of 57,034 registered historian tags named variables no task still had. Each one was being re-probed across every interpreter. 53,312 were removed; six that had recorded samples since the restart were kept.
Limits
- The two ends of the series are not the same experiment: 32 tasks on 1.0.1530 and 27 on 1.0.1780, with real-time thread scheduling added in between. The 1.0.1529 reading was taken inside the convoy, the 1.0.1778 reading did not record the load, and the final reading was taken with a test suite running. The series shows direction and scale on one standing instance; it is not a controlled benchmark.
- The 1.0.1543 reading came right after the CFD tiles and 3,638 of the historian’s 7,335 tags left the project, and the record does not separate that removal from the lock change.
- Not every external read is off the scan’s locks: after 1.0.1780 about 50 walks a second still reach the interpreters.
- A sync-wait count measures contention, not scan latency. The jitter results are recorded separately.
- One machine (6 cores, 12 threads), one kernel, one project.
What it rests on
Sources
Repository paths name records in the ControlForge repository, which is private and not available for review.
- Design record: the interpreter/executor lock family, §1–§13
docs/design/INTERPRETER_LOCKING.md - The census tool
scripts/bench/trace-sync-census.py - Real-time jitter report that started the investigation
docs/perf/rt-jitter/2026-09-01/REPORT.md