On Tue, 30 May 2023 13:03:27 GMT, Aleksandar Pejovic <apejo...@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). Not as far as I'm aware (it can deal with tabs vs. spaces differences as well as multiple spaces). FWIW, I've done [this change](https://github.com/openjdk/jdk/compare/master...jerboaa:jdk:jdk-21+25-cgroups-change) as a PoC a while ago and it seems sufficient to use the JDK's metrics impl in native-image (barring some perf numbers; If somebody provides me with pointers, happy to provide those too). ------------- PR Comment: https://git.openjdk.org/jdk/pull/14216#issuecomment-1680514999