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

Fix performance issue with bruteforce search in review observer #840

Merged
merged 1 commit into from Oct 29, 2019

Conversation

@IvanChepurnyi
Copy link
Contributor

IvanChepurnyi commented Oct 18, 2019

The current observer does a brute-force search to find a current summary related to a product in the collection. It becomes visible when you show 1000 products on a page and increases exponentially with the increased size of product collection.
Fix replaces brute force search (O(n^m)) with a hash map lookup (O(n))

The current observer does a brute-force search to find a current summary related to a product in the collection. It becomes visible when you show 1000 products on a page and increases exponentially with the increased size of product collection. 
Fix replaces brute force search (O(n^m)) with a hash map lookup (O(n))
Copy link
Contributor

colinmollenhour left a comment

Wow, a PR from @IvanChepurnyi! Thanks!

@tmotyl

This comment has been minimized.

Copy link
Contributor

tmotyl commented Oct 19, 2019

@IvanChepurnyi can you share some code snippet you used to test the issue? It would ease up the review.
Thanks

Copy link
Member

Flyingmana left a comment

looked through the used code, great find and improvement.

@IvanChepurnyi

This comment has been minimized.

Copy link
Contributor Author

IvanChepurnyi commented Oct 19, 2019

Here is a Blackfire profile of a customer where this issue is visible:
https://blackfire.io/profiles/d1d95169-67cd-4cd7-8bd0-1ddf7bd81223/graph

As customer outputs almost all products as a list of product names on a category, rendering takes more than 20 seconds in this case:
image

@Flyingmana Flyingmana merged commit 9648b1e into OpenMage:1.9.4.x Oct 29, 2019
1 check passed
1 check passed
LGTM analysis: JavaScript No code changes detected
Details
@IvanChepurnyi IvanChepurnyi deleted the IvanChepurnyi:patch-1 branch Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.