This cache line size is closely related to the CPU. jdk does not provide such an API. I don’t know what the windows system is like. In the linux system, there are these files in the /sys/devices/system/cpu/cpu0/cache/directory
coherency_line_size
level
number_of_sets
physical_line_partition
shared_cpu_list
shared_cpu_map
size
type
ways_of_associativity
The coherency_line_size records the cache line size.
It can also be obtained through `getconf LEVEL1_DCACHE_LINESIZE 64` on the command line.
If you want to get this number when the Java program is running, what you can think of now is to dynamically execute the shell or view the file when the program starts to get this number. Then set this number into the system property, which can be taken out and used later.
This cache line size is closely related to the CPU. jdk does not provide such an API.
I don’t know what the windows system is like. In the linux system, there are these files in the
/sys/devices/system/cpu/cpu0/cache/
directoryThe coherency_line_size records the cache line size.
It can also be obtained through `getconf LEVEL1_DCACHE_LINESIZE
64` on the command line.
If you want to get this number when the Java program is running, what you can think of now is to dynamically execute the shell or view the file when the program starts to get this number. Then set this number into the system property, which can be taken out and used later.
Try opening it on the command line
jvisualvm
and see.