-
Notifications
You must be signed in to change notification settings - Fork 97
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
⚡️ Improve page load by optimizing the caching code #492
⚡️ Improve page load by optimizing the caching code #492
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congrats on making your first Pull Request and thanks for taking the time to improve Websurfx! ❤️!
Say hello by joining the conversation in our Discord
27db60b
to
29b76be
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
104c841
to
51214dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review
Thanks ❤️ for working on this PR. We really appreciate it 👍 Since everything looks good. We will merge this PR as soon as possible 🚀 🙂 .
The search also does appear to be 4-6 seconds quicker now with the changes when I tested it. |
I also seem to have similar results on my side when I tested it. So it seems to be a great improvement overall. Also, thanks ❤️ again to spencerjibz for the cool work. 🙂 |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved! Let's merge this in. 👍
What does this PR do?
It reduces the time it takes for the search results to appear on the search page by caching the next, current and previous page search results simultaneously using Redis pipelining and mini-mocha sync methods. And deferring the caching of the caching of the search results once all the search results have been aggregated from the upstream search engines in the search function in the src/server/routes/search.rs file under the codebase by using a non-blocking concurrent/parallel tokio::spawn thread.
Why is this change important?
Caching results simultaneously and using a separate non-blocking thread will significantly reduce the time it takes to load the search results to the user. Thus improving user experience and improving the search engine speed.
The idea is to cache results for the next, current and previous pages simultaneously, which can help reduce the time it takes to cache the results from the three pages. Also, caching the search results only when the search results from all three pages have been completely fetched and aggregated. Once the results are fetched and aggregated, this will spawn a new parallel and concurrent thread using something like tokio::spawn. The search results from all three pages would be passed to it and cached parallelly and concurrently using tokio::spawn.
How to test this PR locally?
It can be tested by installing and running Websurfx as mentioned in the docs and on the readme and by launching the browser and thoroughly testing.
Run the app with any of the cache_stores enabled via feature flags (redis-cache & hybrid ), and use a Redis-client (either cli or a GUI like redisInsight and others). If you inspect Redis, you find that on each search, two more search_results are stored. Also in the browser, the previous and next search results are loaded faster.
Author's checklist
v1.9.4
Related issues
Closes #444