Skip to content

Wip/perf diagnostics - #3345

Merged
danoswaltCL merged 5 commits into
devfrom
wip/perf_diagnostics
Sep 30, 2026
Merged

danoswaltCL merged 5 commits into
devfrom
wip/perf_diagnostics

Conversation

@danoswaltCL

Copy link
Copy Markdown
Collaborator

when PERF_DIAG_ENABLED is true, this will give us a heartbeat every 10 seconds per instance some diagnostic info about event loop and db pool, so we can try and catch what's really going on inside the instances.

so will want to add these to param store:

TYPEORM_MAX_CONNECTION_POOL_SIZE=20
PERF_DIAG_ENABLED=true

{"tag":"perfdiag","ts":"2026-09-29T19:32:22.664Z","instanceId":"b2d945d5","eventLoopBusyPct":39.3,"eventLoopDelayMs":{"p50":0.3,"p99":12,"max":16.6},"garbageCollection":{"major":{"count":1,"totalMs":4.5,"maxMs":4.5},"minor":{"count":272,"totalMs":200.5,"maxMs":4.4}},"dbPool":{"maxWaitingForConnection":0,"maxConnectionsInUse":8,"poolSize":10},"heapUsedMb":164}

@danoswaltCL
danoswaltCL requested review from bcb37 and zackcl and a balanced review from Copilot September 29, 2026 19:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Non-minor GC events are incorrectly reported as minor collections, producing misleading diagnostics.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds opt-in backend diagnostics for investigating request latency and database pool saturation.

Changes:

  • Emits 10-second JSON heartbeats with event-loop, GC, heap, and PostgreSQL pool metrics.
  • Enables diagnostics through PERF_DIAG_ENABLED.
  • Adds unit coverage for reporting and shutdown behavior.
File Description
packages/​backend/​src/​env.ts Adds the diagnostics feature flag.
packages/​backend/​src/​lib/​perfDiagnostics.ts Collects and emits performance metrics.
packages/​backend/​src/​loaders/​typeormLoader.ts Starts diagnostics after database initialization.
packages/​backend/​test/​unit/​lib/​perfDiagnostics.test.ts Tests output, missing pools, and stopping.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/backend/src/lib/perfDiagnostics.ts Outdated
danoswaltCL and others added 3 commits September 30, 2026 11:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The diagnostics are opt-in, failure-isolated, tested, and introduce no identified correctness issues.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@danoswaltCL
danoswaltCL merged commit 4bcbe06 into dev Sep 30, 2026
6 checks passed
@danoswaltCL
danoswaltCL deleted the wip/perf_diagnostics branch September 30, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants