Skip to content

Optimize Symfony http.route caching with path map approach#3676

Open
cataphract wants to merge 2 commits intomasterfrom
glopes/symfony-routes-redux
Open

Optimize Symfony http.route caching with path map approach#3676
cataphract wants to merge 2 commits intomasterfrom
glopes/symfony-routes-redux

Conversation

@cataphract
Copy link
Contributor

Replace per-route caching with a single cached map of all route paths. This significantly improves performance and reduces memory usage.

Key improvements:

  • Cache entire route map under single key '_datadog.symfony.route_paths'
  • Store simple array: ['route_name' => '/path', ...]
  • Smart invalidation based on compiled routes file mtime
  • Cache indefinitely until Symfony recompiles routes or cache is invalidated
  • Gracefully disable if cache.app unavailable

Cache invalidation logic:

  • Checks {cache_dir}/url_generating_routes.php modification time
  • Compares against cached timestamp (created at cache build time)
  • Rebuilds cache only when compiled routes file is newer

Description

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@datadog-official
Copy link

datadog-official bot commented Feb 25, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 1028 Tests failed

testSearchPhpBinaries from integration.DDTrace\Tests\Integration\PHPInstallerTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integration\PHPInstallerTest::testSearchPhpBinaries
Test code or tested code printed unexpected output: Searching for available php binaries, this operation might take a while.
testSimplePushAndProcess from laravel-58-test.DDTrace\Tests\Integrations\Laravel\V5_8\QueueTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V5_8\QueueTest::testSimplePushAndProcess
Test code or tested code printed unexpected output: spanLinksTraceId: 69a9a45000000000656b819cf0f982e0
tid: 69a9a45000000000
hexProcessTraceId: 656b819cf0f982e0
hexProcessSpanId: 6717fe35e0ff1f32
processTraceId: 7308077331396526816
processSpanId: 7428685617732460338

phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:106
testSimplePushAndProcess from laravel-8x-test.DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest::testSimplePushAndProcess
Test code or tested code printed unexpected output: spanLinksTraceId: 69a9b28100000000218b01179d79f622
tid: 69a9b28100000000
hexProcessTraceId: 218b01179d79f622
hexProcessSpanId: a89bd2861b11d8bc
processTraceId: 2417026825952294434
processSpanId: 12149535893183649980
View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9700e85 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@cataphract cataphract force-pushed the glopes/symfony-routes-redux branch from 3252e79 to cab8ccb Compare February 25, 2026 13:42
@cataphract cataphract marked this pull request as ready for review February 25, 2026 14:17
@cataphract cataphract requested a review from a team as a code owner February 25, 2026 14:17
@pr-commenter
Copy link

pr-commenter bot commented Feb 25, 2026

Benchmarks [ tracer ]

Benchmark execution time: 2026-03-05 16:48:03

Comparing candidate commit 9700e85 in PR branch glopes/symfony-routes-redux with baseline commit eebb4fe in branch master.

Found 2 performance improvements and 0 performance regressions! Performance is the same for 191 metrics, 1 unstable metrics.

scenario:ComposerTelemetryBench/benchTelemetryParsing

  • 🟩 execution_time [-1357.325ns; -442.675ns] or [-11.803%; -3.849%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟩 execution_time [-6.629µs; -5.011µs] or [-6.237%; -4.715%]

@cataphract cataphract force-pushed the glopes/symfony-routes-redux branch from cab8ccb to 8ba7ce8 Compare March 5, 2026 15:26
@cataphract cataphract requested a review from a team as a code owner March 5, 2026 15:26
Replace per-route caching with a single cached map of all route paths.
This significantly improves performance and reduces memory usage.

Key improvements:
- Cache entire route map under single key '_datadog.symfony.route_paths'
- Store simple array: ['route_name' => '/path', ...]
- Smart invalidation based on compiled routes file mtime
- Cache indefinitely until Symfony recompiles routes or cache is
  invalidated
- Gracefully disable if cache.app unavailable

Cache invalidation logic:
- Checks {cache_dir}/url_generating_routes.php modification time
- Compares against cached timestamp (created at cache build time)
- Rebuilds cache only when compiled routes file is newer
@cataphract cataphract force-pushed the glopes/symfony-routes-redux branch from 8ba7ce8 to f8873ec Compare March 5, 2026 15:26
DD_TRACE_SYMFONY_HTTP_ROUTE=false incorrectly fully disabled Symfony
request handling instrumentation.

Properly scoped it to its original intent: the extraction of the Symfony
route path for meta tag http.route.
@cataphract cataphract force-pushed the glopes/symfony-routes-redux branch from f8873ec to 9700e85 Compare March 5, 2026 15:27
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