Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxDirectMemorySize memory size reported by -XX:+PrintFlagsFinal is incorrect (i.e it's -1 by default) #16637

Closed
grcevski opened this issue Jan 31, 2023 · 5 comments · Fixed by #16639

Comments

@grcevski
Copy link

Elasticsearch uses few math formulas for basic JVM ergonomics when launching without explicit heap size settings. We look at the max available heap and the max direct memory on the system, and then we use them to determine what's a good heap size for the JVM.

Running the following command below produces this output with j9:

java -XX:+PrintFlagsFinal
[Global flags]
   size_t MaxHeapSize                              = 16828923904                               {product} {ergonomic}
 uint64_t MaxDirectMemorySize                      = 18446744073709551615                      {product} {ergonomic}

Running Hotspot with the same produces:

   size_t MaxHeapSize                              = 16835936256                               {product} {ergonomic}
 uint64_t MaxDirectMemorySize                      = 0                                         {product} {default}

According to the Java SE docs, it should be 0 if it's not specified:

Sets the maximum total size (in bytes) of the New I/O (the java.nio package) direct-buffer allocations. Append the letter k or K to indicate kilobytes, m or M to indicate megabytes, g or G to indicate gigabytes. By default, the size is set to 0, meaning that the JVM chooses the size for NIO direct-buffer allocations automatically.
https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html (search for XX:MaxDirectMemorySize)

j9 version:

java version "17.0.6-ea" 2023-01-17
IBM Semeru Runtime Open Edition 17.0.6.0-december_22-preview_1 (build 17.0.6-ea+6)
Eclipse OpenJ9 VM 17.0.6.0-december_22-preview_1 (build criu-preview-december_22-release-6c898853679, JRE 17 Linux amd64-64-Bit Compressed References 20230117_95 (JIT enabled, AOT enabled)
OpenJ9   - 6c898853679
OMR      - 6124dbc41
JCL      - 220b5cb074a based on jdk-17.0.6+6)

OS/System information:

/proc/version
Linux version 5.15.0-56-generic (buildd@lcy02-amd64-004) (gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022

/proc/meminfo
MemTotal:       65738028 kB
MemFree:        53102960 kB
MemAvailable:   61846336 kB
Buffers:          271448 kB
Cached:          8842196 kB
SwapCached:            0 kB
Active:          4515964 kB
Inactive:        7250184 kB
Active(anon):       1944 kB
Inactive(anon):  2643288 kB
Active(file):    4514020 kB
Inactive(file):  4606896 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Dirty:               196 kB
Writeback:             0 kB
AnonPages:       2652516 kB
Mapped:           369096 kB
Shmem:              4224 kB
KReclaimable:     347240 kB
Slab:             529764 kB
SReclaimable:     347240 kB
SUnreclaim:       182524 kB
KernelStack:       11520 kB
PageTables:        19088 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    34966160 kB
Committed_AS:    8048312 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       91468 kB
VmallocChunk:          0 kB
Percpu:            39552 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      545300 kB
DirectMap2M:    16119808 kB
DirectMap1G:    50331648 kB
@pshipton
Copy link
Member

@tajila @mstoodle fyi

@grcevski
Copy link
Author

I took a look at the code that prints the Hotspot compatible flags output, so I it can easily be tweaked for the printout so Java programs can find this setting. Strangely enough, the Hotspot JCL treats -1 as unset (or empty setting), but prints 0.

@pshipton
Copy link
Member

#16639 should fix it.

@mstoodle
Copy link
Contributor

nice catch, @grcevski , thanks for pointing it out!

@grcevski
Copy link
Author

Awesome! Thanks!

pshipton added a commit to pshipton/openj9 that referenced this issue Feb 1, 2023
Issue eclipse-openj9#16637

Signed-off-by: Peter Shipton <Peter_Shipton@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants