Skip to content

Again improve symfony http.route resolution#3779

Open
cataphract wants to merge 2 commits intomasterfrom
glopes/symfony-http-route-again
Open

Again improve symfony http.route resolution#3779
cataphract wants to merge 2 commits intomasterfrom
glopes/symfony-http-route-again

Conversation

@cataphract
Copy link
Copy Markdown
Contributor

Turns out it's quite feasible to resolve at runtime the route path from the route name using files in the Symfony cache dir. Not only that, but that strategy was already being used in EndpointCatalog.php.

This fixes a performance issue -- avoid the deserializaiton and possible transfer from Redis of the full route collection cache on every request.

The routing data is in PHP files and with opcache it's basically just one big compile-time variable.

Description

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@cataphract cataphract requested review from a team as code owners April 7, 2026 17:20
@datadog-prod-us1-6
Copy link
Copy Markdown

datadog-prod-us1-6 bot commented Apr 7, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Other Violations

🧪 2 Tests failed

tests.appsec.test_automated_login_events.Test_V3_Login_Events_Blocking.test_login_event_blocking_auto_login[apache-mod-8.0] from system_tests_suite   View in Datadog   (Fix with Cursor)
AssertionError: assert <RemoteConfigApplyState.UNKNOWN: 0> == <RemoteConfigApplyState.ACKNOWLEDGED: 2>
 +  where <RemoteConfigApplyState.UNKNOWN: 0> = <utils._remote_config.RemoteConfigStateResults object at 0x7f54c65ee330>.state
 +    where <utils._remote_config.RemoteConfigStateResults object at 0x7f54c65ee330> = <tests.appsec.test_automated_login_events.Test_V3_Login_Events_Blocking object at 0x7f550823fec0>.config_state_2
 +  and   <RemoteConfigApplyState.ACKNOWLEDGED: 2> = <enum 'RemoteConfigApplyState'>.ACKNOWLEDGED
 +    where <enum 'RemoteConfigApplyState'> = rc.ApplyState

self = <tests.appsec.test_automated_login_events.Test_V3_Login_Events_Blocking object at 0x7f550823fec0>

    def test_login_event_blocking_auto_login(self):
        assert self.r_login.status_code == 200
...
tests.appsec.test_automated_login_events.Test_V3_Login_Events_Blocking.test_login_event_blocking_sdk[apache-mod-8.0] from system_tests_suite   View in Datadog   (Fix with Cursor)
ValueError: No appsec event validate this condition

self = <tests.appsec.test_automated_login_events.Test_V3_Login_Events_Blocking object at 0x7f550823f770>

    def test_login_event_blocking_sdk(self):
        for request in self.r_login:
            assert request.status_code == 200
    
        assert self.config_state_1.state == rc.ApplyState.ACKNOWLEDGED
        assert self.config_state_2.state == rc.ApplyState.ACKNOWLEDGED
...

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.65% (-0.03%)

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

@cataphract cataphract requested a review from a team as a code owner April 7, 2026 18:15
@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Apr 7, 2026

Benchmarks [ tracer ]

Benchmark execution time: 2026-04-09 15:38:15

Comparing candidate commit 9b21f02 in PR branch glopes/symfony-http-route-again with baseline commit 14dabf8 in branch master.

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

scenario:EmptyFileBench/benchEmptyFileBaseline-opcache

  • 🟥 execution_time [+103.844µs; +306.456µs] or [+3.270%; +9.652%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟥 execution_time [+3.004µs; +5.156µs] or [+2.960%; +5.080%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache

  • 🟥 execution_time [+5.343µs; +7.197µs] or [+5.327%; +7.176%]

scenario:SamplingRuleMatchingBench/benchGlobMatching4

  • 🟩 execution_time [-214.310ns; -57.290ns] or [-7.727%; -2.066%]

)->withExactTags([
'symfony.route.action' => 'AppBundle\Controller\CommonScenariosController@simpleAction',
'symfony.route.name' => 'simple',
'http.route' => '/simple',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why http.route is not on tests any more?

Copy link
Copy Markdown
Contributor Author

@cataphract cataphract Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disabled it for old versions of Symfony. There, we don't have the files in the cache dir and falling back on getRouteCollection() is too slow.

Copy link
Copy Markdown
Contributor

@estringana estringana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please remove the code coming from glopes/claude-ci branche since it's not on this pr where that should be reviewed plz?

@cataphract cataphract force-pushed the glopes/symfony-http-route-again branch from 8388154 to 34ef11e Compare April 9, 2026 14:20
Turns out it's quite feasible to resolve at runtime the route path from
the route name using files in the Symfony cache dir. Not only that, but
that strategy was already being used in EndpointCatalog.php.

This fixes a performance issue -- avoid the deserializaiton and possible
transfer from Redis of the full route collection cache on every request.

The routing data is in PHP files and with opcache it's basically just
one big compile-time variable.
@cataphract cataphract force-pushed the glopes/symfony-http-route-again branch from 34ef11e to 9b21f02 Compare April 9, 2026 14:20
@cataphract cataphract requested a review from estringana April 9, 2026 14:20
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