-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(routing): add regex chunking to route regex #714
feat(routing): add regex chunking to route regex #714
Conversation
c28affe
to
9ed28c0
Compare
src/Tempest/Http/src/Routing/Construction/RouteMatchingRegexesBuilder.php
Outdated
Show resolved
Hide resolved
src/Tempest/Http/src/Routing/Construction/RouteMatchingRegexesBuilder.php
Outdated
Show resolved
Hide resolved
src/Tempest/Http/src/Routing/Construction/RouteMatchingRegexesBuilder.php
Outdated
Show resolved
Hide resolved
src/Tempest/Http/src/Routing/Construction/RouteMatchingRegexesBuilder.php
Outdated
Show resolved
Hide resolved
src/Tempest/Http/src/Routing/Construction/RouteMatchingRegexesBuilder.php
Outdated
Show resolved
Hide resolved
9ed28c0
to
3e57646
Compare
src/Tempest/Http/src/Routing/Construction/RouteMatchingRegexesBuilder.php
Outdated
Show resolved
Hide resolved
src/Tempest/Http/src/Routing/Construction/RouteMatchingRegexesBuilder.php
Outdated
Show resolved
Hide resolved
src/Tempest/Http/src/Routing/Construction/RouteMatchingRegexesBuilder.php
Outdated
Show resolved
Hide resolved
Great PR 👍 |
Pull Request Test Coverage Report for Build 11799155234Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
6aaab7b
to
61cc31c
Compare
b13bf7d
to
f9ead7f
Compare
Do you wanna take a look at the merge conflict? Other than that I'm fine merging this 👍 It's not a blocker for me, but I do like for Look at it from a language perspective: "I have a route match" — that always means that there is a matching route. When you say "I don't have a route match", it means there is no matching route (ie. |
- Renamed Regexes to Regex as it is already plural - Make Regex limit a power of 2.. because it should be - Make RouteMatch isFound a computed method based on routeMark
f9ead7f
to
4cc26e3
Compare
Done
done It is a matter of opinion I changed it to |
Thanks! Great PR 💪 |
What
Add regex chunking to route regex. When loading in massive amounts of routes a singular regex can become to large for PCRE to process. A solution for this is to split it up in multiple separate regexes, this is called chunking. With this PR is should be possible to load in as many routes as you like, as long as your memory can hold it.
In order to facilitate this I needed to rework how we build up the regex, instead of using recursion and having the stack implicitly as a php call stack. I needed to implement it manually such that, when it is detected we require a new chunk, we could rebuild the regex prefix based on the stack and also finish it based on it.
Outstanding debates
RouteMatchingRegexesBuilder performance considerations
I isolated the regex buildin into
src/Tempest/Http/src/Routing/Construction/RouteMatchingRegexesBuilder.php
and one singular function. This is mostly because of performance reasons. The inner part of the loop is called so many times, every function call needed to count. So there is a trade-off between readability and performance. Currently I opted to go slightly more towards the performance side. If you think it should be implemented into multiple methods, do know it comes at a cost. (If needed, we can use the benchmarks to signify the cost of alterations).This is also the reason for using
null
as a end marker instead of wrapping all nodes into a VO which also would translate to an end-marker. I saw a performance drop of arround 60%, I went from 120μs to 190μsPHPunit memory limit
I bumped the phpunit memory limit. I couldn't find a "leak" in the newly added code. And it mainly breaks on the integration part. My expectation is the integration tests are already quite hefty on memory and my changes tipped it over the limit. I used memprof to find any culprits, but I couldn't find any glaring issues, most memory consumption is not in "my" code or even near it.