Skip to content

Commit 9de966d

Browse files
d-csclaude
andcommitted
perf(webapp): mollifier hot-path — debug-level buffered log + skip off-state token alloc
triggerTask.server.ts: mollifier.buffered logs at debug, not info — it fires per mollified trigger during a burst, exactly when info-level would flood aggregation. idempotencyClaim.server.ts: move the buffer-null fall-open check above token generation so the mollifier-OFF path skips the default randomUUID() for idempotency-keyed triggers (triggerTask is the highest-throughput path). Injected test generators still honoured. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 16bfff0 commit 9de966d

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

apps/webapp/app/runEngine/services/triggerTask.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ export class RunEngineTriggerTaskService {
475475
taskIdentifier: taskId,
476476
});
477477

478-
logger.info("mollifier.buffered", {
478+
logger.debug("mollifier.buffered", {
479479
runId: runFriendlyId,
480480
envId: environment.id,
481481
orgId: environment.organizationId,

apps/webapp/app/v3/mollifier/idempotencyClaim.server.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,22 @@ export type ClaimOrAwaitInput = IdempotencyLookupInput & {
5959
// IdempotencyKeyConcern PG-first lookup.
6060
export async function claimOrAwait(input: ClaimOrAwaitInput): Promise<ClaimOrAwaitOutcome> {
6161
const buffer = input.buffer === undefined ? getMollifierBuffer() : input.buffer;
62+
if (!buffer) {
63+
// Mollifier disabled / buffer construction failed. Fall open —
64+
// caller proceeds with the trigger pipeline (PG unique constraint
65+
// backstop). The token is never read in this case (publish/release
66+
// are buffer-null no-ops downstream), so we skip the default
67+
// `randomUUID()` to keep the mollifier-OFF hot path allocation-free
68+
// for idempotency-keyed triggers — `triggerTask` is the
69+
// highest-throughput code path in the system. A test-injected
70+
// generator is still honoured for deterministic assertions.
71+
return { kind: "claimed", token: input.generateToken ? input.generateToken() : "" };
72+
}
6273
const generateToken = input.generateToken ?? randomUUID;
6374
// Generate the ownership token up front so the retry loop reuses it
6475
// — we're the same logical claimant across attempts; only the slot
6576
// owner changes between releases.
6677
const token = generateToken();
67-
if (!buffer) {
68-
// Mollifier disabled / buffer construction failed. Fall open —
69-
// caller proceeds with the trigger pipeline (PG unique constraint
70-
// backstop). Without the claim machinery the race-window scenarios
71-
// from the plan doc revert to today's behaviour. Token is still
72-
// generated so callers don't have to branch on the "no buffer" case
73-
// — publish/release become buffer-null no-ops downstream.
74-
return { kind: "claimed", token };
75-
}
7678
const ttlSeconds = input.ttlSeconds ?? DEFAULT_CLAIM_TTL_SECONDS;
7779
const safetyNetMs = input.safetyNetMs ?? DEFAULT_CLAIM_WAIT_MS;
7880
const pollStepMs = input.pollStepMs ?? DEFAULT_CLAIM_POLL_MS;

0 commit comments

Comments
 (0)