number of cpus detection still buggy

Aleksandar Ivanisevic aleksandar.ivanisevic at 2e-systems.com
Wed May 4 15:51:16 UTC 2022


Hi,

looks like number of CPUs detection is still buggy in u332, if there is a core online with a logical number bigger than the total number of cores allocated to the (LXD, maybe also some docker implemantations) container in /sys/devices/system/cpu/online, it does not get counted, JRE counts only the ones with a “possible” number, i.e. if there are 8 cores allocated, only cores 0-7 are counted

# cat Cpus.java
class Cpus {
    public static void main(String[] args) {
        System.out.println("Number of processors available to this JVM: " + Runtime.getRuntime().availableProcessors());
    }
}

# java -version
openjdk version "1.8.0_332"
OpenJDK Runtime Environment (Zulu 8.62.0.19-CA-linux64) (build 1.8.0_332-b09)
OpenJDK 64-Bit Server VM (Zulu 8.62.0.19-CA-linux64) (build 25.332-b09, mixed mode)

# cat /sys/devices/system/cpu/online
3,8-10,13,22,25,28

# java Cpus
Number of processors available to this JVM: 1

so only core number 3 is counted. This is especially funny when no cores are within range, them jre thinks it has 0 CPUs and all sorts of hilarity ensues ;)

if I get rid of /sys/devices/system/cpu/online, or override number of cores with -XX:ActiveProcessorCount=  all is well

# umount /sys/devices/system/cpu
# java Cpus
Number of processors available to this JVM: 8

but this is really hard to diagnose, as the errors are for some reason mostly 

random java.lang.NoClassDefFoundError exceptions
JRE crashing on startup with a segmentation fault in "# V  [libjvm.so+0x95eb25]  ParNewGeneration::collect(bool, bool, unsigned long, bool)+0x95”. 
maven dying with "Error assembling JAR: / by zero”

(just putting this down in hope people might find it googling ;)

java11 does not have that problem. How does one go about getting this fixed so that people do not waste more time with this than its necessary?  I’m just a lowly sysadmin that lost two days of his life on this, not really enlightened how things are going with JVM development.

Thank you.

-- 
Aleksandar Ivanisevic
Head of Operations and Support
2e Systems

Tel: +49 - 6196 - 950 58 14
Fax: +49 - 6196 - 950 58 94
E-mail: Aleksandar.Ivanisevic at 2e-systems.com

Address: 2e Systems GmbH,  Koenigsteiner Str. 107, 65812 Bad Soden am Taunus
Company registration: Amtsgericht Koenigstein (Germany), HRB 7303
Director: Philip Douglas

http://www.2e-systems.com - making your business fly!




More information about the jdk8u-dev mailing list