The __compute method of account_account needs optmization to improve Accounting Performance!
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) | Status tracked in Trunk | |||||
5.0 |
Fix Released
|
Undecided
|
Unassigned | |||
Trunk |
Fix Released
|
Medium
|
OpenERP R&D Addons Team 3 |
Bug Description
The current __compute method of account_account is wasting a lot of time reordering the list of accounts to compute.
We can make the next block of code about five times faster with a small one-line optimization (just adding a "ids2.reverse()" line):
--------
brs = list(self.
sums = {}
while brs:
current = brs[0]
for child in current.child_id:
if child.id not in sums:
if can_compute:
for fn in field_names:
--------
That code is computing the value of each account as the sums of the account values plus its children values.
The problem is that the list of the accounts is sorted on the worst posible way! So most of time is wasted reordering that list.
The list of accounts comes from _get_children_
So the block of code shown above, that always tries to compute the first element of the list, but he won't be able to do it without computing the children accounts first: so it ends up poping accounts from the list and puting them back at the begining of the list in the reverse order... that is, it wastes a lot of time just to reverse the list on the most expensive way!
Adding a ids2.reverse() line before the block of code, will mean that the list of accounts will be in the form [child3, child2_of_child2, child1_of_child2, child2, child1, parent] so no poping&inserting will be necesary!
We have timed that block of code before adding the "ids2.reverse()" and after it:
Original: 2.1701090335825 2.370021998875
Optimized: 0.37584179639849996 0.50867897272100004 (4.65 times faster!)
Note: Average times after several runs, getting the debit and credit of the root account on a database with 1663 accounts and 6930 account move lines.
I think this should be fixed ASAP: It will soothe the currents problems with accounting reports (like the general ledger performance problems reported on bug 514808 and bug 551630).
Related branches
- Mustufa Rangwala (Open ERP): Needs Fixing
-
Diff: 140 lines (+47/-32)3 files modifiedaccount/account.py (+14/-14)
account/invoice.py (+5/-13)
account_voucher/account_voucher.py (+28/-5)
- Purnendu Singh (OpenERP): Needs Resubmitting
- Mustufa Rangwala (Open ERP): Needs Fixing
-
Diff: 66 lines (+22/-2)4 files modifiedhr/security/hr_security.xml (+8/-0)
hr_evaluation/hr_evaluation_demo.xml (+7/-1)
hr_expense/security/ir_rule.xml (+1/-1)
hr_payroll/security/hr_security.xml (+6/-0)
Changed in openobject-addons: | |
importance: | Undecided → High |
milestone: | none → 5.0.10 |
status: | New → Confirmed |
summary: |
- The __compute method of account_account is wasting 78% of time + The __compute method of account_account needs optmization to improve + Accounting Performance! |
Changed in openobject-addons: | |
status: | Confirmed → In Progress |
account_account; 378
account_move_line; 3944
account_move; 1303
account_period; 84
all periods open - with patch mentioned on expert list regarding real time computation of all open fy
response of chart of account < 1 sec