Skip to content

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
Copy link
Contributor

✔️ QA Passed

@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

@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.

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.

5 participants