Context
Every SDK method that supports progress callbacks constructs a runWithFeedback options object on every call, even when no callback is provided:
write(request, progressCallback?, feedbackConfig?) {
return this.#run("write.submit", () => ..., progressCallback, feedbackConfig);
}
// #run builds: { operationKind, metadata: {}, progressCallback, feedbackConfig, operation }
The runWithFeedback function has an early return when progressCallback is undefined, but the call-site allocation (options bag + metadata: {} literal) still occurs.
Impact
Low — the allocation is a single small object per call and V8 is very efficient at short-lived allocations. Only matters for extremely high-frequency operations (thousands of writes/queries per second).
Proposed Fix
Check progressCallback before calling runWithFeedback at all:
#run<T>(operationKind: string, operation: () => T, pc?: ProgressCallback, fc?: FeedbackConfig): T {
if (!pc) return operation();
return runWithFeedback({ operationKind, metadata: {}, progressCallback: pc, feedbackConfig: fc, operation });
}
This eliminates the options-bag allocation entirely on the fast path.
Files
typescript/packages/fathomdb/src/engine.ts (#run)
typescript/packages/fathomdb/src/query.ts (#run)
typescript/packages/fathomdb/src/admin.ts (#run)
Context
Every SDK method that supports progress callbacks constructs a
runWithFeedbackoptions object on every call, even when no callback is provided:The
runWithFeedbackfunction has an early return whenprogressCallbackis undefined, but the call-site allocation (options bag +metadata: {}literal) still occurs.Impact
Low — the allocation is a single small object per call and V8 is very efficient at short-lived allocations. Only matters for extremely high-frequency operations (thousands of writes/queries per second).
Proposed Fix
Check
progressCallbackbefore callingrunWithFeedbackat all:This eliminates the options-bag allocation entirely on the fast path.
Files
typescript/packages/fathomdb/src/engine.ts(#run)typescript/packages/fathomdb/src/query.ts(#run)typescript/packages/fathomdb/src/admin.ts(#run)