Skip to content

[Issue] Improve setup:di:compile performance by using gc_disable #38035

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

Closed
5 tasks
m2-assistant bot opened this issue Oct 3, 2023 · 8 comments
Closed
5 tasks

[Issue] Improve setup:di:compile performance by using gc_disable #38035

m2-assistant bot opened this issue Oct 3, 2023 · 8 comments
Assignees
Labels
Area: Performance Issue: needs update Additional information is require, waiting for response Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: dev in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@m2-assistant
Copy link

m2-assistant bot commented Oct 3, 2023

This issue is automatically created based on existing pull request: #38032: Improve setup:di:compile performance by using gc_disable


Description (*)

By disabling garbage collector the code generation finishes a bit faster:

  1. Result for this contribution repo
    Selection_755

With larger apps the difference is not that significant but noticeable
2.

  • 2 minutes without changes
    Selection_758

  • under 2 minutes with changes
    Selection_757

I also checked calling gc_collect_cycles after each operation to save some memory, but the difference is not that significant and visible on the second screenshot.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes magento/magento2#<issue_number>

Manual testing scenarios (*)

  1. Run setup:di:compile on different CPUs with and without changes
  2. Compare execution time

Questions or comments

  1. More tests needed on different CPUs.
  2. The actual result may vary per project, depending from number of plugins/factories/proxies needed to detect and generate.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)
@m2-assistant
Copy link
Author

m2-assistant bot commented Oct 4, 2023

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Hotel
Copy link
Contributor

Hello @ilnytskyi,

Thanks for the report and collaboration!

We have tried to reproduce the issue in the 2.4-develop branch as well as from the PR. But there is no difference visible to us in both. Please have a look at the below screenshot for reference:

2.4-develop
image

With PR
image

Please let us know if we have missed anything.

Thanks

@engcom-Hotel engcom-Hotel added Issue: needs update Additional information is require, waiting for response and removed Issue: ready for confirmation labels Oct 4, 2023
@ilnytskyi
Copy link
Contributor

@engcom-Hotel it's actually visible, it takes 1 second less and uses a bit more memory.
But as I described more tests needed on different CPUs.

You can also try to check this on composer installation with MSI as there are more modules

@engcom-Hotel
Copy link
Contributor

Hello @ilnytskyi,

Thanks for the reply!

We have tried to reproduce it with the latest version 2.4.7-beta1 and the results are the same. Please have a look into the below screenshot for reference:

Without PR Changes
image

With PR Changes
image

The difference is 1 second and in memory usage. Shall we consider this?

Thanks

@ilnytskyi
Copy link
Contributor

@engcom-Hotel
Could you also repeat tests with this command

time bin/magento setup:di:compile

And compare the output of real time from time command as I did the description?

btw. I forgot to mention
The hardware is Intel Core i7-8550U and PHP 8.1 my screens suggest bigger difference.
In your case it's 1 second that is ~3.3%

@hostep
Copy link
Contributor

hostep commented Oct 5, 2023

Make sure to properly test, it could be that the first run is slower if magento caches are empty.
I would suggest these 3 steps each time you want to measure:

# to warm up caches
$ bin/magento  

# to remove all generated files (some of which bin/magento will generate)
$ rm -R generated/*

# to actually measure
$ time bin/magento setup:di:compile

Doing this myself on a pretty complex project, I'm only seeing 1sec difference, so I'm not convinced at the moment there is much to win here.

@engcom-Hotel
Copy link
Contributor

Hello @hostep,

Thanks for the detailed steps!

I tried to same and the outcome is the same as yours. Please find below the screenshots for reference:

In 2.4.7-beta1
image

With PR Changes in 2.4.7-beta1
image

The difference b/w is showing 1 sec, I agree with @hostep, at the moment there is much to win here.

@ilnytskyi can you please provide some more updates on the same?

Thanks

@engcom-Bravo
Copy link
Contributor

Hi @ilnytskyi,

This issue is being closed since it has not been updated in a long time.Please feel free to reopen or raise a new ticket if the issue still exists.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Performance Issue: needs update Additional information is require, waiting for response Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: dev in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants