Skip middleware code when there are no user middlewares installed#2629
Skip middleware code when there are no user middlewares installed#2629
Conversation
Fixes performance issue introduced by #2577, boosting from 8K req/sec to almost 9K req/sec. If there are no middlewares installed by the user the attribute `request._match_info.current_app` already looks at to the right app, this is by design.
|
Test numbers I've used this benchmark [1] |
Codecov Report
@@ Coverage Diff @@
## master #2629 +/- ##
==========================================
+ Coverage 97.92% 97.92% +<.01%
==========================================
Files 38 38
Lines 7261 7265 +4
Branches 1260 1261 +1
==========================================
+ Hits 7110 7114 +4
Misses 47 47
Partials 104 104
Continue to review full report at Codecov.
|
aiohttp/web_app.py
Outdated
|
|
||
| for subapp in self._subapps: | ||
| subapp.freeze() | ||
| self._run_middlewares |= len(subapp._middlewares) > 0 |
There was a problem hiding this comment.
The line is cryptic a little.
Please replace with self._run_middlewares = self._run_middlewares or subapp._run_middlewares
The change respects middlewares from deep nested subapps: app -> subapp1 -> subapp2.
There was a problem hiding this comment.
Fair enough, done. Added also a bit of internal documentation about this flag and the root cause of its usage.
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
What do these changes do?
Fixes performance issue introduced by #2577, boosting from 8K req/sec
to almost 9K req/sec.
If there are no middlewares installed by the user the attribute
request._match_info.current_appalready looks at to the right app,this is by design.
Are there changes in behavior for the user?
No