Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0038197Openbravo ERPA. Platformpublic2018-03-22 13:122018-04-26 16:55
0038197: TreeTablesEventHandler performance issue on processes with lots of inserts
The Cost Adjustment Process can perform many inserts in the Cost Adjusment Line table. This table has a tree defined so on each insert the TreeTablesEventHandler.

Reviewing in YourKit the times consumed on each method during the process execution the TreeTablesEventHandler handler takes around 14% of the time.

out of 376 seconds of execution 48 are consumed by the handler: org.openbravo.costing.CostAdjustmentProcess.doProcessCostAdjustment(CostAdjustment) 376712
<16 calls> org.openbravo.client.application.event.TreeTablesEventHandler.onNew(EntityNewEvent) 48082

Attached a csv with the call tree exported from YourKit. Note that some other performance improvements have been applied to the process so the numbers might be different on a standard environment.
Create a Cost Adjustment that generates many lines and process it with YourKit profiling data.

Check the times consumed by each method and note that the TreeTablesEventHandler consumes too much time.

Example with F&B data.
1 Go to Product Window and select Cerveza Ale 0,5L
2 On Transactions Tab find the line of receipt:
      10000085 - 23-08-2012 - Bebidas Alegres, S.L. - 10 - Cerveza Ale 0,5L - 90000.00
3 Do a Manual Cost Adjustment with parameters (start YourKit profiling before clicking Done button):
   Amount: 50000
   Incremental: Yes
   Unit Cost: Yes
   Date: default
4 Check that process takes some seconds. Check that part of the time is spent on mentioned handler.
Most of the time is consumed retrieving the TableTree related to the CostAdjustmentLine table. The query always return the same return. This can be improved by caching it in ApplicationDictionaryCachedStructures or a similar class.

The next big time consumption is spent converting back to JSONObject the jsonBob. But in this case the the table uses LinkToParentTreeDatasourceService with does nothing in the addNewNode method so the initialization is useless.
related to defect 0038205 closed collazoandy4 Cost Adjustment Process very slow 
csv cost-adjustment-process-calltree.csv (24,214) 2018-03-22 13:12
Issue History
2018-03-22 13:12gorkaionNew Issue
2018-03-22 13:12gorkaionAssigned To => platform
2018-03-22 13:12gorkaionFile Added: cost-adjustment-process-calltree.csv
2018-03-22 13:12gorkaionModules => Core
2018-03-22 13:12gorkaionTriggers an Emergency Pack => No
2018-03-22 13:56gorkaionSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=16913#r16913
2018-03-22 18:14gorkaionRelationship addedrelated to 0038205
2018-03-23 12:52alostaleTag Attached: Performance
2018-03-23 13:06gorkaionPriorityurgent => high
2018-03-23 13:06gorkaionSeveritymajor => minor
2018-03-23 13:08alostaleStatusnew => acknowledged
2018-04-26 16:55ngarciaIssue Monitored: ngarcia

There are no notes attached to this issue.