feat: add opt-in logPerformance timing logs - #408
Closed
JoviDeCroock wants to merge 1 commit into
Closed
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?: booleanplugin config option (defaultfalse). When enabled, GraphQLSP writes one timing line per operation to the tsserver project-service log:Covered operations:
getSemanticDiagnostics,getCompletionsAtPosition,getQuickInfoAtPosition,getDefinitionAtPosition,getDefinitionAndBoundSpan,getApplicableRefactors,getEditsForRefactor, plus schema loads (schema load) and reloads (schema reload) ingraphql/getSchema.ts.Implementation notes
withPerfLog(operation, filename, run)helper increate()wraps the plugin's work inside each existingguard()body. In every proxied method the GraphQLSP contribution is separable from the underlyinginfo.languageServicecall (which runs outside the wrapper), so the logged duration covers only GraphQLSP's own work in all cases.withPerfLogis selected once at plugin creation — whenlogPerformanceis off it's a plainrun()passthrough with no timer calls or string building. IngetSchema.tstiming is gated behind a single boolean.performance.now()fromnode:perf_hooks, durations rounded to one decimal.minor) is included.Test plan
test/e2e/perf-logging.test.ts: enableslogPerformance: trueintest/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'stsserver.log(deleted up-front so stale content from earlier test files can't satisfy the assertions; polled for flush) and asserts[GraphQLSP] perf:lines forschema load,getSemanticDiagnostics, andgetCompletionsAtPosition.pnpm --filter @0no-co/graphqlsp run buildpasses.pnpm run test:e2e: 12 test files, 53 tests, all passing (including the new test).🤖 Generated with Claude Code