History

Probe a real outbound fetch alongside the local probes (#1673)

Cache and timer probes come back in single-digit ms while the same requests take 4-6s wall, so local I/O is not the cost. Neither probe leaves the isolate. Time a real outbound subrequest, the class the docs proxy implicates (0.098s direct vs 3-6s through the Worker).

Rhys Sullivan committed 2 months ago

Commit fde44501 parent 72778331 file · +15 −0Browse files

Unified · Split

apps/cloud/src/server.ts+15−0
@@ -210,6 +210,20 @@ const cloudflareHandler: ExportedHandler<Env> = { · 209 unmodified lines
210 await scheduler.wait(1);210 await scheduler.wait(1);
211 const timerProbeMs = Date.now() - timerStartedAt;211 const timerProbeMs = Date.now() - timerStartedAt;
212 212
213 // The cache and timer probes are LOCAL. Neither leaves the isolate, and
214 // both come back in single-digit ms while the same requests take 4-6s.
215 // This one is a real outbound network subrequest to a small, fast,
216 // unrelated endpoint — the only class of I/O not yet measured, and the
217 // one the docs proxy (0.098s direct, 3-6s through the Worker) implicates.
218 const fetchStartedAt = Date.now();
219 // oxlint-disable-next-line executor/no-try-catch-or-throw -- temporary diagnostic: a probe failure must not affect the request
220 try {
221 await fetch("https://cloudflare.com/cdn-cgi/trace", { method: "GET" });
222 } catch {
223 // ignored — the timing is the signal, not the result
224 }
225 const fetchProbeMs = Date.now() - fetchStartedAt;
226
213 console.log(227 console.log(
214 JSON.stringify({228 JSON.stringify({
215 probe: "clock-sync",229 probe: "clock-sync",
@@ -217,6 +231,7 @@ const cloudflareHandler: ExportedHandler<Env> = { · 1 unmodified line
217 preWorkMs,231 preWorkMs,
218 cacheProbeMs,232 cacheProbeMs,
219 timerProbeMs,233 timerProbeMs,
234 fetchProbeMs,
220 }),235 }),
221 );236 );
222 237