Skip to content

feat: add opt-in logPerformance timing logs - #408

Closed
JoviDeCroock wants to merge 1 commit into
mainfrom
feat/perf-logging
Closed

feat: add opt-in logPerformance timing logs#408
JoviDeCroock wants to merge 1 commit into
mainfrom
feat/perf-logging

Conversation

@JoviDeCroock

Copy link
Copy Markdown
Member

What/Why

Users reporting slow intellisense (#254) currently have no way to produce actionable data about where time is spent. This adds an opt-in logPerformance?: boolean plugin config option (default false). When enabled, GraphQLSP writes one timing line per operation to the tsserver project-service log:

[GraphQLSP] perf: getSemanticDiagnostics 5.3ms /path/to/file.ts
[GraphQLSP] perf: getCompletionsAtPosition 2.0ms /path/to/file.ts
[GraphQLSP] perf: schema load 8.5ms schema.graphql

Covered operations: getSemanticDiagnostics, getCompletionsAtPosition, getQuickInfoAtPosition, getDefinitionAtPosition, getDefinitionAndBoundSpan, getApplicableRefactors, getEditsForRefactor, plus schema loads (schema load) and reloads (schema reload) in graphql/getSchema.ts.

Implementation notes

  • A small withPerfLog(operation, filename, run) helper in create() wraps the plugin's work inside each existing guard() body. In every proxied method the GraphQLSP contribution is separable from the underlying info.languageService call (which runs outside the wrapper), so the logged duration covers only GraphQLSP's own work in all cases.
  • Zero overhead when disabled: withPerfLog is selected once at plugin creation — when logPerformance is off it's a plain run() passthrough with no timer calls or string building. In getSchema.ts timing is gated behind a single boolean.
  • Uses performance.now() from node:perf_hooks, durations rounded to one decimal.
  • README's Configuration section documents the new option, and a changeset (minor) is included.

Test plan

  • New e2e test test/e2e/perf-logging.test.ts: enables logPerformance: true in test/e2e/fixture-project/tsconfig.json (only additive for the other tests reusing that fixture — extra log lines, no behavior change), triggers semantic diagnostics and completions through the real forked tsserver, then reads the fixture's tsserver.log (deleted up-front so stale content from earlier test files can't satisfy the assertions; polled for flush) and asserts [GraphQLSP] perf: lines for schema load, getSemanticDiagnostics, and getCompletionsAtPosition.
  • pnpm --filter @0no-co/graphqlsp run build passes.
  • Full pnpm run test:e2e: 12 test files, 53 tests, all passing (including the new test).

🤖 Generated with Claude Code

Adds a `logPerformance` plugin config option (default: false). When
enabled, GraphQLSP logs a '[GraphQLSP] perf: <operation> <duration>ms
<file>' line to the tsserver log for each of its own language-service
contributions (diagnostics, completions, quick-info, definitions,
refactors) as well as schema loads and reloads, giving users actionable
data when investigating slow intellisense (#254).

The timing wrapper is a plain passthrough when the option is off, so the
default path gains no timer calls or string building.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant