-
Notifications
You must be signed in to change notification settings - Fork 25.7k
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
[PERF] point_of_sale: lazy reactive getter #174184
Open
caburj
wants to merge
2
commits into
odoo:saas-17.2
Choose a base branch
from
odoo-dev:saas-17.2-lazy-reactive-getter-jcb
base: saas-17.2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[PERF] point_of_sale: lazy reactive getter #174184
caburj
wants to merge
2
commits into
odoo:saas-17.2
from
odoo-dev:saas-17.2-lazy-reactive-getter-jcb
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
caburj
changed the title
[FIX] point_of_sale: lazy reactive getter
[PERF] point_of_sale: lazy reactive getter
Jul 23, 2024
caburj
force-pushed
the
saas-17.2-lazy-reactive-getter-jcb
branch
3 times, most recently
from
July 23, 2024 11:42
08a2d26
to
ced2369
Compare
caburj
force-pushed
the
saas-17.2-lazy-reactive-getter-jcb
branch
from
July 25, 2024 08:01
ced2369
to
4df4d91
Compare
C3POdoo
requested review from
a team and
davidmonnom
and removed request for
a team
July 25, 2024 09:55
caburj
commented
Jul 25, 2024
Comment on lines
+51
to
+60
function registerGetters() { | ||
for (const [name, func] of getAllGetters(WithLazyGetters.prototype)) { | ||
if (name.startsWith("__") && name.endsWith("__")) { | ||
continue; | ||
} | ||
const lazyName = `__lazy_${name}`; | ||
getters.set(name, [lazyName, (obj) => func.call(obj)]); | ||
} | ||
gettersRegistered = true; | ||
} |
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.
I had to change when this is called and the getAllGetters
should be given the prototype
of WithLazyGetters
, not the passed Class
.
This change is necessary so that patches of the getters from other modules are taken into account.
caburj
force-pushed
the
saas-17.2-lazy-reactive-getter-jcb
branch
3 times, most recently
from
July 26, 2024 06:53
689cba7
to
774372c
Compare
**Problem:** A customer experiences a noticeable delay (1 to 2 sec) when adding product in the cart because of lack of caching computations. It gets worse the more orderlines are added in the cart. **Solution:** This commit introduces an implementation of lazy reactive computed value that is pull-based -- it only recomputes when it's needed. Check the following PR in odoo/owl for its origin: odoo/owl#1499 This can be used for smart-caching selected getters. In this PR, we made a getter for the `get_all_prices` method and instead of normal getter access, we get the result of the getter using the `get` method introduced in the wrapper class. This means that in one call stack, calling `get('allPrices')` will only run once and it will keep returning the cached value until a dependency in its dependency (calculation) graph changed. With this patch, adding an orderline is now 300ms -- approximate 5 times faster than without caching.
caburj
force-pushed
the
saas-17.2-lazy-reactive-getter-jcb
branch
from
July 26, 2024 06:53
774372c
to
8985aa7
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
A customer experiences a noticeable delay (1 to 2 sec) when adding product in
the cart because of lack of caching computations. It gets worse the more
orderlines are added in the cart.
Solution:
This commit introduces an implementation of lazy reactive computed value that is
pull-based -- it only recomputes when it's needed. Check the following PR in
odoo/owl for its origin: odoo/owl#1499
This can be used for smart-caching selected getters. In this PR, we made a
getter for the
get_all_prices
method and instead of normal getter access, weget the result of the getter using the
get
method introduced in the wrapperclass.
This means that in one call stack, calling
get('allPrices')
will only run onceand it will keep returning the cached value until a dependency in its
dependency (calculation) graph changed.
With this patch, adding an orderline is now 300ms -- approximate 5 times faster
than without caching.
Related: https://github.com/odoo/enterprise/pull/67382