Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0023550Openbravo ERPA. Platformpublic2013-04-15 13:272013-04-25 14:51
alostale 
alostale 
normalmajorhave not tried
closedfixed 
5
 
3.0MP23 
mtaal
Core
No
0023550: MenuManager resources consumption
MenuManager is the object in charge of caching (session scoped) menu to be reused by different components.

It is generated when the session is created (on login or role change).

The problem is the amount of resources it consumes to be created and maintained.
See https://issues.openbravo.com/view.php?id=23428#c57890 [^]

Following the test case proposed in that issue. MenuManager consumes ~53s to be generated for the 20 sessions (~2.65s per session).

It also retains ~7MB of heap for each session of Admin role with access to all entries.
This can be improved by creating a "generic menu" object cached at application scope by language (one copy of the menu for each different available language).

This generic menu would be lazily created on first time it is required (this is first login after tomcat is started).

Subsequent menu requests would reuse this global menu, caching it at session scope, in the same way now it is cached to be adapted to role permissions.

In this way:
* Global menu would be generated just once, currently is done once per session. Reducing CPU consumption.
* Global menu in memory object would be shared among different session, each of them would just keep a list of pointers of the session granted menu items, this pointers would link to common object. Reducing heap usage.
Performance
blocks design defect 0023428 new AugustoMauch When login the application the cpu consumes a lot of resources for few seconds and the memory also increases a lot 
diff about-menu.diff (3,737) 2013-04-15 13:30
https://issues.openbravo.com/file_download.php?file_id=6097&type=bug
Issue History
2013-04-15 13:27alostaleNew Issue
2013-04-15 13:27alostaleAssigned To => alostale
2013-04-15 13:27alostaleModules => Core
2013-04-15 13:27alostaleTriggers an Emergency Pack => No
2013-04-15 13:28alostaleRelationship addedblocks 0023428
2013-04-15 13:30alostaleFile Added: about-menu.diff
2013-04-15 13:31alostaleReview Assigned To => mtaal
2013-04-15 13:39alostaleNote Added: 0057895
2013-04-15 13:39alostaleTag Attached: Performance
2013-04-15 13:50hgbotCheckin
2013-04-15 13:50hgbotNote Added: 0057901
2013-04-15 13:50hgbotStatusnew => resolved
2013-04-15 13:50hgbotResolutionopen => fixed
2013-04-15 13:50hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/b69625663ccced5c10ad3b448f15f6b0be1db159 [^]
2013-04-16 19:18hudsonbotCheckin
2013-04-16 19:18hudsonbotNote Added: 0057978
2013-04-19 18:05hgbotCheckin
2013-04-19 18:05hgbotNote Added: 0058061
2013-04-22 16:36hudsonbotCheckin
2013-04-22 16:36hudsonbotNote Added: 0058105
2013-04-25 14:51mtaalNote Added: 0058257
2013-04-25 14:51mtaalStatusresolved => closed
2013-04-25 14:51mtaalFixed in Version => 3.0MP23

Notes
(0057895)
alostale   
2013-04-15 13:39   
Executed test case:

* Apply attached about-menu.diff.
* When opening About window, it logs generated menu javascript code for all the roles available in the system. Verified that before and after applying the fix, the generated code is identical.

Improvement:
*Before applying the fix, MenuManager consumed 1-2 seconds per session
*Before applying the fix, MenuManager retained ~7MB of heap per session

*After applying the fix, MenuManager consumes 10-300 ms per session
*After applying the fix, MenuManager still retains ~4MB per session, but these 4MB are application scoped so even retained by each session, new sessions do not increase (significantly) the global amount of memory used by MenuManager.
(0057901)
hgbot   
2013-04-15 13:50   
Repository: erp/devel/pi
Changeset: b69625663ccced5c10ad3b448f15f6b0be1db159
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Mon Apr 15 13:49:03 2013 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/b69625663ccced5c10ad3b448f15f6b0be1db159 [^]

fixed issue 23550: improved MenuManager resources consumption

Now GlobalMenu is application scoped sharing a "global generic" menu among
different sessions, preventing menu computation for each of them.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/MenuManager.java
M src/org/openbravo/erpCommon/utility/WindowTree.java
A modules/org.openbravo.client.application/src/org/openbravo/client/application/GlobalMenu.java
A modules/org.openbravo.client.application/src/org/openbravo/client/application/event/MenuCacheHandler.java
---
(0057978)
hudsonbot   
2013-04-16 19:18   
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/8df08bea850d [^]

Maturity status: Test
(0058061)
hgbot   
2013-04-19 18:05   
Repository: erp/devel/pi
Changeset: dceedab022193ae7df469b0bcd0b5d6788528d2b
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Fri Apr 19 18:04:36 2013 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/dceedab022193ae7df469b0bcd0b5d6788528d2b [^]

related to issue 23550: enable MenuManager to be used out of a CDI container

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/MenuManager.java
---
(0058105)
hudsonbot   
2013-04-22 16:36   
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/f78aa78542fa [^]

Maturity status: Test
(0058257)
mtaal   
2013-04-25 14:51   
Reviewed