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(perf): improve speed of setQueryParameters #6006

Merged
merged 2 commits into from
Jan 18, 2024

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Jan 17, 2024

Summary

inside setQueryParameters (used in many cases), we have _parseNumbers, which is always used with the arguments of setQueryParameters or new SearchParameters. This therefore means we don't need to make a safe copy of the parameters, everything should be fine using the arguments instead.

Result

Note, this PR requires #6007 to be merged before it. The failing test is related to that change.

better perf:

before after
Screenshot 2024-01-17 at 11 35 45 Screenshot 2024-01-17 at 11 36 12

inside setQueryParameters (used in many cases), we have _parseNumbers, which is always used with the arguments of setQueryParameters or new SearchParameters

TODO: find out why CurrentRefinements > RefinementList changes its order with this change. Not sure yet
Copy link

codesandbox-ci bot commented Jan 17, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4c1634e:

Sandbox Source
InstantSearch.js Configuration
react-instantsearch-app Configuration
example-react-instantsearch-default-theme Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-vue-instantsearch-default-theme Configuration

@Haroenv Haroenv marked this pull request as ready for review January 17, 2024 16:28
@Haroenv Haroenv requested review from a team, dhayab and sarahdayan and removed request for a team January 17, 2024 16:28
…6007)

introduced in #5764, but wasn't an issue until merge/setQueryParameters doesn't make a new copy constantly of the parameters.

Essentially what's going on:
- when you build the requests, it's sorting the facet values
- this then gets updated in the parameters as well as it's the same object
- with this fix, the sorting is done non-mutating (similar to .toSorted) to avoid the sorting of the parameters for cache to have a potential impact on the UI
@dhayab dhayab merged commit 1f48c9c into fix/perf-avoid-clear-refinements Jan 18, 2024
8 checks passed
@dhayab dhayab deleted the fix/perf-avoid-merge branch January 18, 2024 11:26
@dhayab dhayab restored the fix/perf-avoid-merge branch January 18, 2024 17:55
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.

None yet

2 participants