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] base: fast mapped func + 1800 % #30975

Open
wants to merge 1 commit into
base: 11.0
from

Conversation

Projects
None yet
4 participants
@fmdl
Copy link
Contributor

commented Feb 9, 2019

Dear @odony @nim-odoo @mart-e I have find a huge performance trick for the mapped function.

Description of the issue/feature this PR addresses:
During the mapped function all field are prefetch, but we just need one.

Test 1:
self.env['stock.move'].search([], limit=5000).mapped('product_id')
Before : 5.7196s -> After : 0.3094s : + 1800 %

self.env['stock.move'].search([], limit=5000).mapped('product_id.categ_id')
Before : 7.5418s -> After : 0.8502s : + 900 %
In this case it is not necessary to put all fields of product_id in cache.

Test 2 with #30817:
self.env['stock.move'].search([], limit=5000).mapped('product_id')
Before : 2.3296s -> After : 0.1344s : + 1800 %
Compare to Test 1 : + 4200 %

self.env['stock.move'].search([], limit=5000).mapped('product_id.categ_id')
Before : 2.7994s -> After : 0.377s : + 800 %
Compare to Test 1 : + 2000 %

Note 1: can be targeted in master.
Note 2: it is maybe not the best way to do
Note 3: test_60_prefetch fail because before mapped put all fields in cache

cc @alexis-via @sla-subteno-it

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

[FIX] fast mapped func
During the mapped function all field are prefetch, but we just need one.

Test :
self.env['stock.move'].search([], limit=5000).mapped('product_id')
Before : 5.7196s
After : 0.3094s

@robodoo robodoo added the seen 🙂 label Feb 9, 2019

@fmdl fmdl changed the title [FIX] base: fast mapped func [FIX] base: fast mapped func + 1800 % Feb 9, 2019

@Yenthe666 Yenthe666 added the Framework label Feb 9, 2019

@odony

This comment has been minimized.

Copy link
Contributor

commented Feb 9, 2019

Nice, could you compare your patch with d1cefc4ec5dda009bc9dc735c68674fdbe28ce7c that is a part of #30817, a pending PR with a lot of performance fine-tuning? I believe it could yield the same boost, but perhaps in a more generic way.
It would also be very interesting to apply the whole #30817 and add that to your benchmarks

Thanks a lot!

/cc @rco-odoo @beledouxdenis

@fmdl

This comment has been minimized.

Copy link
Contributor Author

commented Feb 9, 2019

@odony please find the result (my PR have the same efficience)

Test 2 with #30817:
self.env['stock.move'].search([], limit=5000).mapped('product_id')
Before : 2.3296s -> After : 0.1344s : + 1800 %
Compare to Test 1 : + 4200 %

self.env['stock.move'].search([], limit=5000).mapped('product_id.categ_id')
Before : 2.7994s -> After : 0.377s : + 800 %
Compare to Test 1 : + 2000 %

@beledouxdenis beledouxdenis requested a review from rco-odoo Feb 11, 2019

@fmdl

This comment has been minimized.

Copy link
Contributor Author

commented Apr 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.