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(quantic): delay caused by recent queries fixed #5060

Merged
merged 10 commits into from
Mar 18, 2025
Merged

Conversation

mmitiche
Copy link
Contributor

@mmitiche mmitiche commented Mar 12, 2025

SFINT-6021

  • Reduced the maximum amount of recent queries to save in the local storage to 10.
  • Optimized the function that were doing some computation in the QuanticSearchBoxSuggestionsList by making them only run when necessary, in order to do this computation is only executed when the relevant dependant properties change values, this was made using setters methods tied to these properties.

@mmitiche mmitiche changed the title delay caused by recent queries fixed fix(quantic): delay caused by recent queries fixed Mar 12, 2025
Copy link

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 246.6 246.6 0
commerce 359.2 359.2 0
search 417.3 417.3 0
insight 408.5 408.5 0
recommendation 258 258 0
ssr 411.1 411.1 0
ssr-commerce 375.7 375.7 0

@mmitiche mmitiche marked this pull request as ready for review March 13, 2025 13:30
@mmitiche mmitiche requested a review from a team as a code owner March 13, 2025 13:30
Copy link
Contributor

@SimonMilord SimonMilord left a comment

Choose a reason for hiding this comment

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

I like the idea for the fix! Nice work. Do you have a before/after comparison of the performance impact? I wonder if the caching had more an impact or if the max amount of suggestions stored is the biggest factor here.

@erocheleau
Copy link
Collaborator

After discussion with @mmitiche ,

We should instead rely on the setters for the query suggestions and lastQueries to decide when we want to re-compute the arrays of suggestions/recent queries.

And keep the resulting in a "cache" so we don't have to re-compute the expensive operations every single time we re-render.

@SimonMilord SimonMilord self-requested a review March 17, 2025 14:01
Copy link
Collaborator

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

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

Couple of questions

Copy link
Contributor

@SimonMilord SimonMilord left a comment

Choose a reason for hiding this comment

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

Do you have a before/after comparison in terms of performance? Just out of curiosity?

@mmitiche
Copy link
Contributor Author

Do you have a before/after comparison in terms of performance? Just out of curiosity?

Yes, these screenshots shows how many times the methods getSuggestionListOption and getQuerySuggestionsNotInRecentQueries and the render method have been called when writing one character in the search box:

Before:

Screenshot 2025-03-12 at 9 15 45 PM

After:

Screenshot 2025-03-17 at 4 00 33 PM

Copy link
Collaborator

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

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

There's a weird corner case that we're not checking for I'm fairly certain

@mmitiche mmitiche requested a review from erocheleau March 18, 2025 16:15
Copy link
Collaborator

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

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

Nice

@mmitiche mmitiche added this pull request to the merge queue Mar 18, 2025
Merged via the queue into master with commit 31a14b9 Mar 18, 2025
103 checks passed
@mmitiche mmitiche deleted the SFINT-6021 branch March 18, 2025 18:28
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.

3 participants