Skip to content
TypeScript

perf(server): stop tracing routine port polling helpers (#30678)

Elliot Drel9304d843e59b
diff --git a/apps/server/src/preview/PortScanner.ts b/apps/server/src/preview/PortScanner.ts
index b2b6e1ac9fb..a75603ec02c 100644
--- a/apps/server/src/preview/PortScanner.ts
+++ b/apps/server/src/preview/PortScanner.ts
@@ -684,7 +684,8 @@ export const make = Effect.gen(function* PortDiscoveryMake() {
// Only configured URLs are requested. Owned listeners are listed as plain HTTP without a
// request: owning a process says nothing about its protocol, and HTTP or TLS bytes break
// binary ones such as Unity's test runner or Steam's IPC.
- const probeWebServers = Effect.fn("PortDiscovery.probeWebServers")(function* (
+ // Idle polls omit this span; requested scans and uncached probes retain their own spans.
+ const probeWebServers = Effect.fnUntraced(function* (
servers: ReadonlyArray<DiscoveredLocalServer>,
configuredUrls: ReadonlyArray<string>,
) {
@@ -781,9 +782,8 @@ export const make = Effect.gen(function* PortDiscoveryMake() {
platform: hostPlatform,
}).pipe(Effect.as(null));
- const scanUnlocked = Effect.fn("PortDiscovery.scanUnlocked")(function* (
- configuredUrls: ReadonlyArray<string>,
- ) {
+ // Routine polling helpers share operation/probe spans instead of tracing every tick.
+ const scanUnlocked = Effect.fnUntraced(function* (configuredUrls: ReadonlyArray<string>) {
if (!listenerDiscovery) return yield* probeWebServers([], configuredUrls);
const state = yield* Ref.get(stateRef);
const terminalOwners = new Map<number, ServerOwner>();
@@ -860,19 +860,18 @@ export const make = Effect.gen(function* PortDiscoveryMake() {
return yield* probeWebServers(fromProc ?? [], configuredUrls);
});
- const scanSnapshot = Effect.fn("PortDiscovery.scanSnapshot")(
- (configuredUrls: ReadonlyArray<string>) =>
- scanSemaphore.withPermits(1)(scanUnlocked(configuredUrls)),
- );
+ const scanSnapshot = (configuredUrls: ReadonlyArray<string>) =>
+ scanSemaphore.withPermits(1)(scanUnlocked(configuredUrls));
const scanOnce: PortDiscovery["Service"]["scan"] = (configuredUrls = []) => {
const normalized = normalizeConfiguredUrls(configuredUrls);
return scanSnapshot(normalized).pipe(
Effect.map((snapshot) => projectWebProbeSnapshot(snapshot, normalized)),
+ Effect.withSpan("PortDiscovery.scan"),
);
};
- const pollTick = Effect.fn("PortDiscovery.pollTick")(
+ const pollTick = Effect.fnUntraced(
function* () {
const configuredUrls = [
...new Set(