-
-
Notifications
You must be signed in to change notification settings - Fork 946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding many routes to CompiledRouter is slow (takes O(n^2) time) #1550
Comments
Hi @fengyong ! In my test, adding 400 routes takes about 4 seconds, which could probably be still acceptable for some cases? OTOH I realize that may render unit tests unusable slow, as well as one would eventually hit the limit of what is reasonable with even more routes. Potential solutions:
|
i fixed this by add a patch, it works great, but ugly, i wish there will be a better official version it only takes 2 lines if directly modify falcon's source code, but it need to deliberate the side-affects.
|
4 seconds for 400 routes is acceptable in fact.
|
I think it would be reasonable to set a flag that delays code generation until the first call to |
As an alternative the every time a new route is added to the router def _compile_and_find(self, *args):
self._find = self._compile(...)
return self._find(*args) so that it will compile only on the first call. This would also avoid the condition to check if a compilation is need in the |
I've tried creating a poc at #1665. By delaying compilation 400 routes are added in 50 ms |
i have about 400 api route to add
falcon compiles method “find” each time and slower as the count grows
it slows down hug booting
does anyone else have same problem?
i made a patch to fix it,but not very elegent,
i wish there will be a better solution
Sent with GitHawk
The text was updated successfully, but these errors were encountered: