Skip to content

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

Open
cataphract wants to merge 1 commit intomasterfrom
glopes/symfony-routes-redux
Open

Optimize Symfony http.route caching with path map approach#3676
cataphract wants to merge 1 commit 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)
Risky Test
phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:52
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: 699f0cf9000000001209c190fb17d8b9
tid: 699f0cf900000000
hexProcessTraceId: 1209c190fb17d8b9
hexProcessSpanId: 9338991605e3bfc1
processTraceId: 1299782795905194169
processSpanId: 10608397242138345409

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: 699eff5300000000b963b2def3d3a2e2
tid: 699eff5300000000
hexProcessTraceId: b963b2def3d3a2e2
hexProcessSpanId: 3c2d9a28c15782a1
processTraceId: 13358717590354240226
processSpanId: 4336291516060762785
View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: cab8ccb | Docs | Datadog PR Page | Was this helpful? Give us feedback!

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 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-02-25 14:59:24

Comparing candidate commit cab8ccb in PR branch glopes/symfony-routes-redux with baseline commit 07b618a in branch master.

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

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟩 execution_time [-7.025µs; -3.215µs] or [-6.416%; -2.936%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache

  • 🟩 execution_time [-8.577µs; -6.943µs] or [-7.741%; -6.266%]

scenario:PDOBench/benchPDOOverhead

  • 🟥 execution_time [+6.454µs; +10.633µs] or [+2.926%; +4.820%]

scenario:PDOBench/benchPDOOverheadWithDBM

  • 🟥 execution_time [+7.532µs; +12.507µs] or [+3.437%; +5.707%]

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