RFR: 8309191: Reduce JDK dependencies of cgroup support
Aleksandar Pejovic
apejovic at openjdk.org
Mon Jun 5 09:10:08 UTC 2023
On Thu, 1 Jun 2023 09:47:29 GMT, Severin Gehwolf <sgehwolf at openjdk.org> wrote:
>> The current code for cgroup support in the JDK has large and expensive dependencies: it uses NIO, streams, and regular expressions. This leads to unnecessary class loading and slows down startup, especially when the code is executed early during an application startup. This is especially a problem for GraalVM, which executes this code during VM startup.
>>
>> This PR reduces the dependencies:
>> - NIO is replaced with regular `java.io` for file access.
>> - Streams are replaced with loops (a side effect of this is that files are read in full whereas previously they could be read up to a certain point, e.g., until a match is found).
>> - Regular expressions are replaced with manual tokenization (and for usages of `String.split`, the "regex" is changed to single characters for which `String.split` has a fast-path implementation that avoids the regular expression engine).
>
> src/java.base/linux/classes/jdk/internal/platform/cgroupv1/CgroupV1SubsystemController.java line 110:
>
>> 108:
>> 109: public static long convertHierachicalLimitLine(String line) {
>> 110: String[] tokens = line.split(" ");
>
> Again, assumes single space (` `) delimited entries in `memory.stat`. I'm not sure we should hard-code this.
This delimiter also hasn't changed since the `memory.stat` file was introduced, and since cgroup v1 is in maintenance mode I'd expect it to stay that way.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14216#discussion_r1217765452
More information about the core-libs-dev
mailing list