You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(webapp,run-engine): cut CPU on the engine-facing worker-action routes
Three changes from a CPU profile of the worker-action request path, together
taking on-CPU time per completed run from 9.07ms to 6.59ms (-27%) at ~300 req/s,
with every worker-action p50 down 23-27%.
Split the event-loop monitor in two. The blocked-loop detector installs an
async_hooks hook that fires for every async resource the process creates, and
enabling any async hook also puts V8 on the slow path for promise
instrumentation process-wide; it measured ~14% of on-CPU time plus roughly half
of all GC. It is now opt-in via EVENT_LOOP_MONITOR_ENABLED (default 0). The
event-loop utilization gauge is a single interval timer with no per-request
cost, so it moves to EVENT_LOOP_UTILIZATION_MONITOR_ENABLED (default 1) and
stays on.
Bucket route matching by first static path segment. The existing router patch
removed the per-request re-flatten and regex rebuild, but matching was still a
linear scan over the whole 521-route table. Route-matching self time drops 64%.
Ordering is preserved exactly and equivalence was verified over 20,050
pathnames; apps/webapp/test/routeMatchingPatch.test.ts pins the semantics.
Demote the per-heartbeat and per-dequeue info logs to debug. These are the two
highest-rate engine calls and each wrote a synchronous structured log line on
every request.
Cut webapp CPU usage by about a quarter on the routes that workers call most, freeing headroom at the same request rate. Detailed event-loop blocking diagnostics are now off by default (set `EVENT_LOOP_MONITOR_ENABLED=1` to restore them); the event-loop utilization metric is unaffected.
@@ -1115,6 +1193,12 @@ function compilePath(path, caseSensitive, end) {
34
120
if (end === void 0) {
35
121
end = true;
36
122
}
@@ -43,7 +129,7 @@ index 6aa7db6fb5a7182afcdf17b16a3356abfa1e7945..95edbde228beff8dbd13fb2800302e31
43
129
warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), "Route path \"" + path + "\" will be treated as if it were " + ("\"" + path.replace(/\*$/, "/*") + "\" because the `*` character must ") + "always follow a `/` in the pattern. To get rid of this warning, " + ("please change the route path to \"" + path.replace(/\*$/, "/*") + "\"."));
44
130
let params = [];
45
131
let regexpSource = "^" + path.replace(/\/*\*?$/, "") // Ignore trailing / and /*, we'll handle it below
46
-
@@ -1147,7 +1163,11 @@ function compilePath(path, caseSensitive, end) {
132
+
@@ -1147,7 +1231,11 @@ function compilePath(path, caseSensitive, end) {
47
133
regexpSource += "(?:(?=\\/|$))";
48
134
} else ;
49
135
let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
0 commit comments