⚡️Improve caching of callable inspection result #14441
Open
+8
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Currently if
app.depedendency_overridesis not empty then each request generates new Dependant, instead of reusing one build while declaring a route. This effects performance of all requests, even if specific dependency is not actually overridden. I'm personally use dependency overrides on production apps (see #13913), so all my applications are affected.Change description
If dependency is not overridden, reuse existing Dependant with cached
inspectresults. This avoids performance hit, in my case 460RPS -> 630RPS.Also simplified check of
dependency_overridesmakes resolution of complex dependency trees faster, even when no dependency overrides used in the first place.Microbenckmark:
Details
Before
Performed GET /data requests without dependency override: 100,000 times in 81.2075s
Average per call: 812.08 µs
Flamegraph
Performed GET /data requests wit dependency override of unrelated dependency: 100,000 times in 220.0742s
Average per call: 2200.74 µs
Flamegraph
Performed GET /data requests wit dependency override: 100,000 times in 236.5470s
Average per call: 2365.47 µs
Flamegraph
After:
Performed GET /data requests without dependency override: 100,000 times in 66.0966s
Average per call: 660.97 µs
Flamegraph
Performed GET /data requests with non-empty dependency overrides: 100,000 times in 67.9596s
Average per call: 679.60 µs
Flamegraph
Performed GET /data requests with actual dependency override: 100,000 times in 106.0456s
Average per call: 1060.46 µs
Flamegraph