-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
compiled interceptors module #22826
base: 2.5-develop
Are you sure you want to change the base?
compiled interceptors module #22826
Conversation
update from upstream
Hi @fsw. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
Hi @fsw,
Do you have some benchmarks to share with us? |
@fsw This is a very nice module, do but did you consider compiling interceptors per area and specifying those on di for Magento to use, instead of using static calls to "getCurrentScope"? |
@orlangur, on a standard instance, simple ApacheBench tests are showing about ~10% gain on a request, I will create some more detailed benchmark for you. @IvanChepurnyi, actually this was the original idea, but:
However I and not 100% sure used approach is better, do you think there are other upsides other than removing the static switch? |
@fsw switch opcache argument sounds reasonable, but maybe you somehow could receive this current scope without doing this static call, like maybe pass it in the constructor, so DI container will automatically supply it for you? |
@IvanChepurnyi this should be easily doable as code generator uses reflection anyway so should be easy to override parent constructor. I will check how this would affect performance. |
@orlangur, trivial benchmark in developer mode:
You can see that first request with generated code purged renders a lot slower as interceptors now read config to generate, but in exchange following requests are faster. This obviously depends on number of plugins and should be better in production mode where DI takes far less time. |
@IvanChepurnyi I have followed your suggestion and it seems to be a bit faster and code is much nicer indeed. |
@fsw Looks nice! But I just noticed, seems like you also use object manager directly for plugin instantiation, so maybe it makes sense to supply it as well as a dependency? |
@IvanChepurnyi already tried that :) but:
|
@fsw I mean passing object manager for instantiation of plugins later. Sure for performance reasons pre-instantiation of plugins does not make sense. |
@IvanChepurnyi oh yes, that makes sense. done. Also I have 2 questions for general public:
|
@kandy good point. |
I think it makes sense to include your code directly to Interceptor library. Also if this code will work in production mode we can make additional optimization like replace
with
|
@kandy I think plugin instances are shared between interceptors, plus I think there is a bit more logic in DI when it creates constructor arguments (constants/virtual types etc) so I am not sure if removing this single step of DI would be worth it. |
@fsw, It's hard to predict the performance impact now, and in any case, I don't recommend doing it in the scope of this PR |
I believe that PR still has failed builds |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
As discussed with @sidolov in Slack, he should ping the team working on finalizing this PR and write some updates here. |
As we discussed with @sidolov in Slack - he'll try to allocate time next week to go through this PR and figure out what's left. |
@ihor-sviziev @sidolov this version and module version have diverged a bit but maybe it will be useful for you to take a look at fixes to module version to see if they are useful here: |
Hello @fsw, Thanks for the contribution! Currently, we are not processing the PRs targeted for 2.5-develop. Hence we are moving this PR We will pick this PR in the future whenever we start working on 2.5-develop. Thanks |
As far as I can see, there is not even a timeline for 2.5, the next release in 2024 is 2.4.7. So my honest (yes or no) question: will this PR ever happen? (it's been 4+ years now) |
This will probably happen when shopware 8 is released and everyone will forget about magento) |
We are currently processing PRs targeted to 2.4-develop only. So, removing this from the community picked backlog for now. |
@sinhaparul I believe that we can update PR with changes for Magento 2.4 from https://github.com/creatuity/magento2-interceptors and move forward. What do you think? |
Any updates? |
Description (*)
At Creatuity we have developed a module that generates Interceptors code using app config instead of a boilerplate that reads config at runtime.
https://github.com/creatuity/magento2-interceptors
We believe it changes performance and debugging magento significantly and it is worth to consider making it a part of the core witch this pull request does.
Any comments welcome.
Manual testing scenarios (*)
to use in developer mode in
app/etc/di.xml
replace:with:
clear generated files and cache:
rm -rf generated/* && rm -rf var/cache/* && bin/magento cache:clean
generated interceptors instead of boilerplate that reads plugins config at runtime like this:
should have a code built using config like:
Contribution checklist (*)
Resolved issues: