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

Optimizes the ModelsResolver class #345

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jimrubenstein
Copy link

Q A
Bug fix? No
New feature? No
BC breaks? No
Related Issue N/a
Need Doc update No

Describe your change

Improves the performance of populating results in the ModelResolver class

What problem is this fixing?

ModelResolver was executing a ~O(n^2) loop for populating scout metadata and building the results collection.

This was causing some scout searches to take 5+ seconds for us.

This fix changes the result collection construction to ~O(n), yielding a 100%-500% speed improvement in our local tests.

Model resolver class was performing an O(n^2) array search for populating the scoutMetadata on the result model.

In some of our queries, this was taking upwards of 4 seconds to return.

This update changes the strategy for populating that data to using a map, and cuts the iterations on the instances collection to a single iteration (to generate the map), instead of the length of the hits collection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant