Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033605Openbravo ERPA. Platformpublic2016-08-02 17:262016-10-14 09:19
shuehner 
shuehner 
normalminorhave not tried
closedfixed 
5
 
3.0PR16Q4 
caristu
Core
No
0033605: OrgTree.getAccessibleTree is very slow with many organizations
This function is very slow >1s in a system with many orgs (524).

Most of that slowdown comes from bad coding of loops here.
- for (int i = 0; i < nodes.toArray().length; i++) {
+ for (int i = 0; i < nodes.size(); i++) {

In many functions of that class to get to the size of a java.util.list the above is used which create a new array from the list to get to the size of that tmp array and throws it away.

As that is being done very very often in the calculation it a major pain point.

Just changing that like shown in the above diff drops runtime from >1s down to 50ms
Trigger above code in a system with i.e. 524 orgs.

Found in flow POSLoginHandler (which runs fillSessionArguments which runs above function)
Performance
related to defect 0033602 new Triage Omni OMS LoginUtils.fillSessionArguments (query Attribute.selectOrgCurrency quite slow) around 100ms with many orgs 
blocks defect 0035729 closed alostale Performance issue in Financial Account when having high number of Organizations 
diff 33605_prototype.diff (3,113) 2016-08-02 17:27
https://issues.openbravo.com/file_download.php?file_id=9668&type=bug
Issue History
2016-08-02 17:26shuehnerNew Issue
2016-08-02 17:26shuehnerAssigned To => platform
2016-08-02 17:26shuehnerModules => Core
2016-08-02 17:26shuehnerTriggers an Emergency Pack => No
2016-08-02 17:27shuehnerFile Added: 33605_prototype.diff
2016-08-11 20:09shuehnerTag Attached: Performance
2016-08-23 14:56shuehnerRelationship addedrelated to 0033602
2016-08-23 15:04shuehnerReview Assigned To => caristu
2016-08-23 15:30hgbotCheckin
2016-08-23 15:30hgbotNote Added: 0089307
2016-08-23 15:30hgbotStatusnew => resolved
2016-08-23 15:30hgbotResolutionopen => fixed
2016-08-23 15:30hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/fbbbd0d5bd13f0a59455446e0de48dd9a5a4b576 [^]
2016-08-25 10:39caristuNote Added: 0089380
2016-08-25 10:39caristuStatusresolved => closed
2016-08-25 10:39caristuFixed in Version => 3.0PR16Q4
2016-10-14 09:19alostaleAssigned Toplatform => shuehner
2017-05-03 14:07alostaleRelationship addedblocks 0035729

Notes
(0089307)
hgbot   
2016-08-23 15:30   
Repository: erp/devel/pi
Changeset: fbbbd0d5bd13f0a59455446e0de48dd9a5a4b576
Author: Stefan Hühner <stefan.huehner <at> openbravo.com>
Date: Tue Aug 23 15:29:22 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/fbbbd0d5bd13f0a59455446e0de48dd9a5a4b576 [^]

Fixed 33605. Simplify & speedup OrgTree functions with many organizations.

Code in OrgTree.java used strange pattern to loop over its internal (Array)List
of notes.

- for (int i = 0; i < nodes.toArray().length; i++) {
+ for (int i = 0; i < nodes.size(); i++) {

That makes code harder to read and create/copy of those temporary arrays has
a noticable performanc cost in a system with many organizations.

---
M src/org/openbravo/base/secureApp/OrgTree.java
---
(0089380)
caristu   
2016-08-25 10:39   
Code reviewed