test(scriptworker): tight-heartbeat tests warm the worker before arming the 3-interval silence kill (#827 audit)

A_burst_of_cold_compiles_does_not_starve_the_heartbeat (50 ms heartbeat) and
A_caller_that_blocks_after_its_result_does_not_starve_the_reader (100 ms)
launched their worker under the tight silence kill, so its cold start (launch,
first compile, Roslyn JIT) had to stay within 150/300 ms of silence. Under 28
busy processes on 14 cores that failed 2 in 10 runs in the WARM-UP, killed
for ~165 ms of silence, and replacement workers were killed the same way.

New test seam: WorkerLaunchSpec.HeartbeatSilenceLimit (runner internal ctor
heartbeatSilenceLimit) and WorkerConnection.SilenceLimit. The tests launch
with a 30 s limit, warm, then tighten to three intervals for the phase they
are about; the assertions on that phase are unchanged.
This commit is contained in:
Joseph Doherty
2026-11-11 01:59:11 -05:00
parent f7ca2c5826
commit 30c6c3a0bf
3 changed files with 59 additions and 14 deletions
@@ -141,6 +141,9 @@ public sealed class OutOfProcessScriptRunner : IScriptRunner, IAsyncDisposable,
private readonly string? _peCacheDirectory;
private readonly byte[]? _peCacheKey;
private readonly int _compileThreads;
/// <summary>Test seam: the launched workers' initial silence limit (null = three heartbeat intervals).</summary>
private readonly TimeSpan? _heartbeatSilenceLimit;
private long _peCacheHits;
private long _peCacheMisses;
private long _peCacheRejected;
@@ -159,9 +162,10 @@ public sealed class OutOfProcessScriptRunner : IScriptRunner, IAsyncDisposable,
internal OutOfProcessScriptRunner(ScriptingOptions options, ILogger? log, ILogger? scriptRoot,
TimeSpan heartbeatInterval, TimeSpan loadTimeout, TimeSpan? maintenanceInterval = null, string? markerDirectory = null,
int compileThreads = 0, int evalThreads = 0)
int compileThreads = 0, int evalThreads = 0, TimeSpan? heartbeatSilenceLimit = null)
{
_compileThreads = compileThreads;
_heartbeatSilenceLimit = heartbeatSilenceLimit;
ArgumentNullException.ThrowIfNull(options);
_options = options.Sanitized(out _);
_worker = _options.Worker;
@@ -719,7 +723,8 @@ public sealed class OutOfProcessScriptRunner : IScriptRunner, IAsyncDisposable,
MarkerDirectory: _markerDirectory,
LoadTimeout: LoadTimeout,
CompileThreads: _compileThreads,
WorkerSid: WorkerSid);
WorkerSid: WorkerSid,
HeartbeatSilenceLimit: _heartbeatSilenceLimit);
return new WorkerShard(label, isolation,
(onExiting, ct) => WorkerConnection.StartAsync(spec, _log, OnLogs, onExiting, ct),
OnWorkerExit, _log);