Skip to content

Conversation

@gastonfournier
Copy link
Contributor

@gastonfournier gastonfournier commented Sep 2, 2025

This was a short investigation into the startup performance. These are the findings:

  1. Server binds in ~2.9 s, yet dev workflow shows ~20 s wall (includes build + watcher).
  2. Startup profiler highlighted large async churn and heavy synchronous module initialization before the first listen.

Some suggestions (from ChatGPT that I think are relevant but I don't feel we'll gain much):

  1. Migration gating: requires migration scans ~350 migration files and runs db-migrate logic every boot (FS + promise storm) before listen; no cached manifest or version fast path.
  2. OpenAPI boot cost: OpenApiService constructs full schema and pulls in @wesleytodd/openapi + swagger-parser stack even if docs are never hit during early life; validators compiled at runtime each boot.
  3. Validation coupling: API route validation tightly coupled to heavy OpenApiService instance; cannot partially initialize (validators vs docs UI). Lazy-load swagger UI & parser only on /docs
  4. Heavy module loads: date-fns root import (~275 ms chain) and openapi/swagger, unleash-client, knex stack each ~80–130 ms; some appear twice (path + bare specifier) causing duplicate parse/compile.
  5. Promise churn: ~38k PROMISE async ops (massive summed duration) dominated by trivial then/new Promise chains from library initialization (Bluebird transitive usage, swagger, date-fns aggregation).
  6. Repetitive runtime computation: Simple helpers (e.g. secondsToMilliseconds) imported from full date-fns bundle; no tree-shaking in CommonJS/ESM mixed environment.
  7. Precompile validators: generate AJV compiled code at build

@vercel
Copy link

vercel bot commented Sep 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Updated (UTC)
unleash-docs Ignored Ignored Sep 2, 2025 7:21am

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@@ -0,0 +1,402 @@
Node v22.17.1 | PID 2141941
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output of the report

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file can be loaded in https://ui.perfetto.dev/ for a timeline but it's not really useful IMO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants