Skip to content

Commit f5ccf9c

Browse files
committed
Reduce ML_ONLY heap size, so that direct memory is accounted for.
1 parent f262f81 commit f5ccf9c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/MachineDependentHeap.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,17 @@ protected int getHeapSizeMb(Settings nodeSettings, MachineNodeRole role, long av
9898
* could result in ML processes crashing with OOM errors or repeated autoscaling up and down.
9999
*/
100100
case ML_ONLY -> {
101+
/*
102+
* An ML node used to have 40% of the total memory for the Java heap, and the remainder
103+
* for ML and overhead (the operating system). This did not account for the Java direct
104+
* memory, which equals half of the heap size (see JvmErgonomics).
105+
* Right now, a factor of 2/3 is applied to the heap size, leaving the ML memory formula
106+
* the same. That means it now also accounts for direct memory.
107+
*/
101108
if (availableMemory <= (GB * 16)) {
102-
yield mb((long) (availableMemory * .4), 4);
109+
yield mb((long) (availableMemory * .4 * 2/3), 4);
103110
} else {
104-
yield mb((long) min((GB * 16) * .4 + (availableMemory - GB * 16) * .1, MAX_HEAP_SIZE), 4);
111+
yield mb((long) min(((GB * 16) * .4 + (availableMemory - GB * 16) * .1) * 2/3, MAX_HEAP_SIZE), 4);
105112
}
106113
}
107114
/*

0 commit comments

Comments
 (0)