Skip to content

fix: make profiler configurable and disable it by default in non-debug mode#1243

Open
martiis wants to merge 1 commit intooverblog:masterfrom
martiis:fix/load-profiler
Open

fix: make profiler configurable and disable it by default in non-debug mode#1243
martiis wants to merge 1 commit intooverblog:masterfrom
martiis:fix/load-profiler

Conversation

@martiis
Copy link
Copy Markdown
Contributor

@martiis martiis commented Apr 10, 2026

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? maybe
Documented? no
Fixed tickets no
License MIT

Summary
The profiler.yaml configuration was loaded unconditionally in OverblogGraphQLExtension::loadConfigFiles(), registering GraphQLCollector and ProfilerController in all environments — including production.

While the data_collector tag is harmless when the profiler is disabled (Symfony's ProfilerPass simply skips it), the kernel.event_listener tag on graphql.post_executor is processed by RegisterListenersPass independently.

This means GraphQLCollector::onPostExecutor() fired on every GraphQL request in production, performing:

  • Parser::parse() — re-parsing the full GraphQL query into an AST
  • $this->cloneVar($variables) — deep-cloning all query variables via Symfony's VarCloner
  • $this->cloneVar($result) — deep-cloning the entire GraphQL response
  • AST traversal of all operation definitions and fields

All this data was accumulated into $this->batches and never consumed, since collect() is only called by Symfony when the profiler is enabled.

Impact

  • Eliminates unnecessary CPU overhead (query parsing + deep cloning) on every production GraphQL request
  • Reduces memory usage from cloned result objects that were never read
  • Removes an unused public controller endpoint (ProfilerController) from production

…g mode

The profiler.yaml was loaded unconditionally, causing GraphQLCollector's
event listener to run on every GraphQL request in production — parsing
queries and deep-cloning results for data that was never consumed.

Add an `enabled` option to the `profiler` configuration section,
defaulting to `kernel.debug`. This allows explicit control while
ensuring profiler services are only registered in dev/test by default.
@martiis martiis force-pushed the fix/load-profiler branch from 07076ed to dbca7b1 Compare April 10, 2026 07:33
@martiis martiis changed the title fix: only load profiler services when Symfony profiler is available fix: make profiler configurable and disable it by default in non-debug mode Apr 10, 2026
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.

2 participants