Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033606Openbravo ERPA. Platformpublic2016-08-02 18:302016-12-16 18:39
shuehner 
NaroaIriarte 
highminorhave not tried
closedfixed 
5
 
3.0PR17Q13.0PR17Q1 
alostale
Core
No
0033606: speedup Preferences.getAllPreferences by improving getPreferenceFromList functions to do early return
That function does a manually coded complicate list search.

However most entries in that list will be for different properties and not just different in visibility.

So doing early check & return of the properties part in the comparison can save some cpu cycles.

On testing with bigger db that shaves of 50-60ms of all runtime on getAllPreferences.

From around 120ms (of the loop in getAllPreferences) downto 60ms

Note using a Map here instead of list with a key matching the open coded list search could give another speedup
-
Performance
diff 33606_prototype.diff (865) 2016-08-02 18:30
https://issues.openbravo.com/file_download.php?file_id=9669&type=bug
Issue History
2016-08-02 18:30shuehnerNew Issue
2016-08-02 18:30shuehnerAssigned To => platform
2016-08-02 18:30shuehnerModules => Core
2016-08-02 18:30shuehnerTriggers an Emergency Pack => No
2016-08-02 18:30shuehnerTag Attached: Performance
2016-08-02 18:30shuehnerFile Added: 33606_prototype.diff
2016-09-29 09:10alostaleStatusnew => acknowledged
2016-09-29 09:10alostaleTarget Version => 3.0PR17Q1
2016-12-01 14:05alostalePrioritynormal => urgent
2016-12-01 14:05alostalePriorityurgent => high
2016-12-05 12:48NaroaIriarteAssigned Toplatform => NaroaIriarte
2016-12-05 14:58NaroaIriarteStatusacknowledged => scheduled
2016-12-07 09:24hgbotCheckin
2016-12-07 09:24hgbotNote Added: 0092157
2016-12-07 09:24hgbotStatusscheduled => resolved
2016-12-07 09:24hgbotResolutionopen => fixed
2016-12-07 09:24hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/1f58fdc924744f4b1b3ae4d06365a88406f77890 [^]
2016-12-07 09:26NaroaIriarteReview Assigned To => alostale
2016-12-13 11:22alostaleNote Added: 0092308
2016-12-13 11:22alostaleStatusresolved => closed
2016-12-13 11:22alostaleFixed in Version => 3.0PR17Q1
2016-12-16 18:39hudsonbotCheckin
2016-12-16 18:39hudsonbotNote Added: 0092691

Notes
(0092157)
hgbot   
2016-12-07 09:24   
Repository: erp/devel/pi
Changeset: 1f58fdc924744f4b1b3ae4d06365a88406f77890
Author: Naroa Iriarte <naroa.iriarte <at> openbravo.com>
Date: Mon Dec 05 15:36:48 2016 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/1f58fdc924744f4b1b3ae4d06365a88406f77890 [^]

Fixed issue 33606: The Preferences.getPreferenceFromList improved.

A continue has been added to do an early return in a for loop of the Preferences.getPreferenceFromList method. Putting this code there prevents a lot of executions needed to get the "winVisibilityNotDefined" and the "sameWinVisibility" variables.
The "isCurrentPreference" variable needs to be true to make this piece of code true: "if (isCurrentPreference && (winVisbilityNotDefined || sameWinVisibility)) {" and to return the listPref value. So, if the "isCurrentPreference" is false, it doesn't matter the values of the "winVisibilityNotDefined" nor "sameWinVisibility" values. That is why is a good idea to put the early return. In this way a lot of executions to get the variables will be avoided.

---
M src/org/openbravo/erpCommon/businessUtility/Preferences.java
---
(0092308)
alostale   
2016-12-13 11:22   
code reviewed

tested:
* speed is improved accordingly to what was expected
* the preferences returned are the same as before the fix
(0092691)
hudsonbot   
2016-12-16 18:39   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/dc8bf00badd0 [^]
Maturity status: Test