Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0053918Openbravo ERPA. Platformpublic2023-11-13 13:222023-11-27 08:13
alostale 
alostale 
normalmajorsometimes
closedfixed 
5
 
PR24Q1 
Core
No
0053918: BO utilization causes excessive JVM metaspace usage
When backoffice application is intensively used, the JVM metaspace consumption considerably increases.

Javascript code is compiled in the JVM for OBBindings (ie. for filter selectors), causing this pressure in the metaspace.

Ie.: this command shows the number of currently loaded scripts, which can be huege: jcmd Bootstrap VM.metaspace show-classes show-loaders | grep org.mozilla.javascript.gen | wc -l
#1. In a real customer

In real customers with BO intensive use, monitory metaspace:

jcmd Bootstrap VM.metaspace

Detected in some live customer having 30GB allocated for heap space, meta to be >5GB.

#2. Emulate it by executing this code

try {
  System.out.println("start.,,");
  long t = System.currentTimeMillis();
  for (int i = 0; i < 10000; i++) {
    ParameterUtils.getJSExpressionResult(Map.of("inpTableId", "333") //
        , null,
        "OB.getFilterExpression(\"org.openbravo.erpCommon.info.BusinessPartnerSelectorFilterExpression\")");
  }
  System.out.println("done " + (System.currentTimeMillis() - t));
} catch (ScriptException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}
No tags attached.
Issue History
2023-11-13 13:22alostaleNew Issue
2023-11-13 13:22alostaleAssigned To => Triage Platform Base
2023-11-13 13:22alostaleModules => Core
2023-11-13 13:22alostaleTriggers an Emergency Pack => No
2023-11-13 13:27alostaleDescription Updatedbug_revision_view_page.php?rev_id=27111#r27111
2023-11-13 13:27alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=27113#r27113
2023-11-13 13:50alostaleDescription Updatedbug_revision_view_page.php?rev_id=27114#r27114
2023-11-13 13:50alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=27115#r27115
2023-11-13 14:06hgbotNote Added: 0157102
2023-11-13 14:26shuehnerIssue Monitored: shuehner
2023-11-14 07:39alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=27120#r27120
2023-11-14 07:39alostaleAssigned ToTriage Platform Base => alostale
2023-11-27 08:13hgbotResolutionopen => fixed
2023-11-27 08:13hgbotStatusnew => closed
2023-11-27 08:13hgbotNote Added: 0157651
2023-11-27 08:13hgbotFixed in Version => PR24Q1
2023-11-27 08:13hgbotNote Added: 0157652

Notes
(0157102)
hgbot   
2023-11-13 14:06   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/1048 [^]
(0157651)
hgbot   
2023-11-27 08:13   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/1048 [^]
(0157652)
hgbot   
2023-11-27 08:13   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 80547cae41df0e44264e592fde6a106e6b4edde5
Author: Asier Lostalé <asier.lostale@openbravo.com>
Date: 27-11-2023 06:44:42
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/80547cae41df0e44264e592fde6a106e6b4edde5 [^]

fixes BUG-53918: BO utilization causes excessive JVM metaspace usage

Backoffice uses OBBindings to compute defaults and filter expressions. They are
executed as JavaScript scripts. Each time one was used, it was compiled and
discarded causing a high usage of the mataspace.

Now they are cached (their key is the script string itself) so that each of them
is compiled just once.

---
M src-test/src/org/openbravo/test/expression/OBBindingsTest.java
M src/org/openbravo/base/expression/OBScriptEngine.java
---