perf(runtime): split trigger evals from the blocking pool; bounded, deadline-aware execution

This commit is contained in:
Joseph Doherty
2026-08-14 22:36:15 -04:00
parent 312216ff2b
commit c4fc1f8ecd
42 changed files with 3673 additions and 1251 deletions
@@ -1028,14 +1028,22 @@ public class AlarmActorTests : TestKit, IDisposable
}
[Fact]
public void ExpressionAlarm_EvaluatesOnSchedulerThread_AndActivates()
public void ExpressionAlarm_EvaluatesOffTheBlockingScriptPool_AndActivates()
{
// TRUE only when evaluated on a script-execution thread. Before P1 the
// expression ran on the actor dispatcher (name is NOT "script-execution-*")
// → false → alarm never activates. After P1 it runs on the script scheduler.
// WP3.1 retarget of the former P1 assertion, whose sense is deliberately INVERTED.
//
// P1 moved the evaluation off the actor's dispatcher and onto the dedicated
// script-execution scheduler, and this test asserted exactly that. WP3.1 (finding #4)
// proved that destination wrong for alarms in particular: sharing the blocking pool
// meant an alarm that should raise in milliseconds queued behind blocked script bodies
// for an unbounded time, and its 2 s evaluation timeout did not even start ticking
// until it was dequeued. Evaluations now run on the shared .NET thread pool behind
// TriggerEvalGate.
//
// TRUE only when evaluated OFF a script-execution thread.
var expr = CompileRawTriggerExpression(
"System.Threading.Thread.CurrentThread.Name != null && " +
"System.Threading.Thread.CurrentThread.Name.StartsWith(\"script-execution-\")");
"System.Threading.Thread.CurrentThread.Name == null || " +
"!System.Threading.Thread.CurrentThread.Name.StartsWith(\"script-execution-\")");
var alarmConfig = new ResolvedAlarm
{
CanonicalName = "ExprAlarm",