Skip to content

refactor(routing): split route construction#666

Merged
brendt merged 2 commits intotempestphp:mainfrom
blackshadev:feat/split-route-construction
Nov 6, 2024
Merged

refactor(routing): split route construction#666
brendt merged 2 commits intotempestphp:mainfrom
blackshadev:feat/split-route-construction

Conversation

@blackshadev
Copy link
Contributor

@blackshadev blackshadev commented Nov 2, 2024

What

Split route construction from matching. As discussed in #626 , it would be nice if the routing construction is concentrated in the route discovery and clearly separated from the route matching. This means that all logic is moved away from the RouteConfig and it is used just as a storage container.

Benchmarks

  • Dynamic route matching remained roughtly the same.
  • Route adding has remained the same.
  • Serialization of the route config has become significantly faster (432.739μs to 364.133μs, small in absolute value, but relative to each other is an improvement of 15% ).
  • Added a benchmark for the RouteConfig construction which includes the whole regex creation

Main

+--------------------------+--------------------+--------------------+------+-----+----------+-----------+--------+
| benchmark                | subject            | set                | revs | its | mem_peak | mode      | rstdev |
+--------------------------+--------------------+--------------------+------+-----+----------+-----------+--------+
| RouteConfigBench         | benchRoutingSetup  |                    | 1000 | 5   | 2.113mb  | 1.100ms   | ±0.70% |
| RouteConfigBench         | benchSerialization |                    | 1000 | 5   | 2.947mb  | 432.739μs | ±0.57% |
| GenericRouteMatcherBench | benchMatch         | Dynamic            | 1000 | 5   | 2.552mb  | 4.921μs   | ±1.36% |
| GenericRouteMatcherBench | benchMatch         | Non existing long  | 1000 | 5   | 2.552mb  | 5.308μs   | ±1.01% |
| GenericRouteMatcherBench | benchMatch         | Non existing short | 1000 | 5   | 2.552mb  | 3.070μs   | ±1.50% |
| GenericRouteMatcherBench | benchMatch         | Static route       | 1000 | 5   | 2.552mb  | 2.881μs   | ±1.44% |
+--------------------------+--------------------+--------------------+------+-----+----------+-----------+--------+

This branch

+-----------------------------+-----------------------------------------+--------------------+------+-----+----------+-----------+--------+
| RouteConfigBench            | benchSerialization                      |                    | 1000 | 5   | 2.721mb  | 364.133μs | ±0.80% |
| GenericRouteMatcherBench    | benchMatch                              | Dynamic            | 1000 | 5   | 2.434mb  | 4.982μs   | ±2.19% |
| GenericRouteMatcherBench    | benchMatch                              | Non existing long  | 1000 | 5   | 2.434mb  | 5.324μs   | ±2.52% |
| GenericRouteMatcherBench    | benchMatch                              | Non existing short | 1000 | 5   | 2.434mb  | 3.085μs   | ±1.07% |
| GenericRouteMatcherBench    | benchMatch                              | Static route       | 1000 | 5   | 2.434mb  | 3.049μs   | ±1.46% |
| RouteConfigConstructorBench | benchRouteConfigConstructionToConfig    |                    | 1000 | 5   | 2.131mb  | 65.156μs  | ±0.30% |
| RouteConfigConstructorBench | benchRouteConfigConstructionRouteAdding |                    | 1000 | 5   | 2.101mb  | 1.097ms   | ±1.12% |
+-----------------------------+-----------------------------------------+--------------------+------+-----+----------+-----------+--------+

@blackshadev blackshadev force-pushed the feat/split-route-construction branch 2 times, most recently from 9aea953 to f16038c Compare November 2, 2024 08:43
@blackshadev blackshadev changed the title Feat(routing): split route construction feat(routing): split route construction Nov 2, 2024
@blackshadev blackshadev force-pushed the feat/split-route-construction branch from f16038c to c9025b1 Compare November 2, 2024 10:32
@blackshadev blackshadev force-pushed the feat/split-route-construction branch 3 times, most recently from 9f6d2c9 to 473cb8c Compare November 2, 2024 13:29
@blackshadev blackshadev marked this pull request as ready for review November 2, 2024 13:34
Copy link
Member

@brendt brendt left a comment

Choose a reason for hiding this comment

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

Only one question, this is a great PR :)

@blackshadev blackshadev force-pushed the feat/split-route-construction branch from 46bc152 to 7ec4db8 Compare November 3, 2024 16:11
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11652825238

Details

  • 42 of 42 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 82.618%

Totals Coverage Status
Change from base Build 11647196989: 0.02%
Covered Lines: 7139
Relevant Lines: 8641

💛 - Coveralls

@innocenzi innocenzi changed the title feat(routing): split route construction refactor(routing): split route construction Nov 5, 2024
@brendt brendt merged commit 32bf4d0 into tempestphp:main Nov 6, 2024
@brendt
Copy link
Member

brendt commented Nov 6, 2024

Let's go 🌊

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.

3 participants