Skip to content
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

Save Asynchronous Operations with one Batch improvement #27257

Merged
merged 7 commits into from
Apr 1, 2020

Conversation

nuzil
Copy link
Contributor

@nuzil nuzil commented Mar 12, 2020

Description (*)

This Pull request is providing performance improvement on a step when Bulk scheduling operation.

Operation are saved into database for reporting, and in existed implementation it happening inside of foreach loop.
So if we have a lot of operations its takes quite a lot of time. Much faster to make it with one Mysql request.

So I chanegd implementation for save results into database after foreach.

Also I made some performance calculation,

with only 200 operations in one request, it gives 20% improvement on performance side.
The bigger amount of operations the bigger performance influence.

Manual testing scenarios (*)

Shedule any bulk operation.

Questions or comments

Auto Tests - implementing of saving to operation table is already covered with tests, so this particular PR do not need any additional tests. If current one will work, then implementation works successfully.

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)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Mar 12, 2020

Hi @nuzil. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@nuzil nuzil changed the title Async mass save Save Asynchronous Operations with one Batch improvement Mar 12, 2020
Copy link
Contributor

@swnsma swnsma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nuzil!
Thank you for your contribution! It looks really great!
Could you please check my comments?
Also, could you add some tests for introduced behaviour?

/**
* @inheritDoc
*/
public function execute(array $operations): void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have declared OperationInterface[] expected type for '$operations', but in current implementation it will works correctly only with data in arrays.

Please keep contract on OperationInterface or do not make current service as API.

@@ -139,6 +149,7 @@ public function publishMass($topicName, array $entitiesArray, $groupId = null, $
try {
$operation = $this->operationRepository->createByTopic($topicName, $entityParams, $groupId);
$operations[] = $operation;
$singleOperationsData[] = $operation->getData();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my mind, better is to use DTO from point of view of Service Contracts, than arrays with raw data.

@magento-engcom-team
Copy link
Contributor

Hi @swnsma, thank you for the review.
ENGCOM-7158 has been created to process this Pull Request
✳️ @swnsma, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@engcom-Alfa engcom-Alfa moved this from Ready for Testing to Testing in Progress in Pull Requests Dashboard Mar 26, 2020
@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

@engcom-Alfa engcom-Alfa moved this from Testing in Progress to Extended Testing (optional) in Pull Requests Dashboard Mar 26, 2020
@engcom-Echo engcom-Echo self-assigned this Mar 27, 2020
@engcom-Echo
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests EE, Functional Tests CE

@engcom-Echo
Copy link
Contributor

Failed unit tests not related to the changes in this PR

@engcom-Echo engcom-Echo moved this from Extended Testing (optional) to Merge in Progress in Pull Requests Dashboard Mar 31, 2020
@magento-engcom-team magento-engcom-team merged commit f76d2c2 into magento:2.4-develop Apr 1, 2020
@m2-assistant
Copy link

m2-assistant bot commented Apr 1, 2020

Hi @nuzil, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@ghost ghost moved this from Merge in Progress to Recently Merged in Pull Requests Dashboard Apr 1, 2020
@magento-engcom-team magento-engcom-team removed this from Recently Merged in Pull Requests Dashboard Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants