Files
outline/server/storage
Tom MoorandClaude Opus 4.8 3e4727d67c perf: Server startup time (#12680)
* perf: lazy-load jsdom in DocumentHelper to keep it off startup path

DocumentHelper is imported by the Document and Collection models, so its
eager `import { JSDOM } from "jsdom"` pulled jsdom (~140ms) into every
server process at boot. jsdom is only needed by toEmailDiff for HTML
export, so load it lazily there — matching the existing pattern in the
sibling ProsemirrorHelper.toHTML.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* perf: defer AWS CRT signer load out of the startup path

S3Storage had a top-level `import "@aws-sdk/signature-v4-crt"` side effect
that loaded the native CRT binding (~140ms) whenever the module was
imported — which happens at boot via the Attachment model in every
process, even for local-storage deployments that never construct S3Storage.

Move the import into the S3Storage constructor so the native binding only
loads when S3 storage is actually instantiated, keeping it off the startup
path for local-storage deployments.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* perf: load dd-trace only when APM is enabled

tracer.ts imported dd-trace unconditionally, so the library (which patches
Node internals on require, ~35-80ms) loaded at startup in every process —
including the common self-hosted case where DD_API_KEY is unset and APM
does nothing. tracer.ts is the first import in server/index.ts, so this
cost is fully serial on the boot path.

Require dd-trace only when DD_API_KEY is set; otherwise fall back to a
no-op tracer covering the surface used by callers (scope/startSpan and a
no-op span), so tracing.ts and the named helpers work unchanged. The
dd-trace/ext/tags import used by tracing.ts is a standalone constants
module and does not pull in the full tracer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 13:50:51 -04:00
..
2026-06-13 13:50:51 -04:00
2023-08-20 07:04:34 -07:00