Skip to content

Instantly share code, notes, and snippets.

@SergejIsbrecht
Last active March 16, 2022 11:13
Show Gist options
  • Save SergejIsbrecht/f0d89d4af7fe341ad2096c9da88c8b3b to your computer and use it in GitHub Desktop.
Save SergejIsbrecht/f0d89d4af7fe341ad2096c9da88c8b3b to your computer and use it in GitHub Desktop.
substrate_vm
WITHOUT DEBUG SYMBOLS DWARF
arguments(
'-H:+PreserveFramePointer',
'--no-server',
'--no-fallback',
'--enable-all-security-services',
'--report-unsupported-elements-at-runtime'
)
-rwxrwxr-x 1 sergej sergej 9483000 Jan 17 17:20 topten*
   ~/Development/Development/SVMPlayground ldd build/native-image/file  ✔   25s  16:47:31
linux-vdso.so.1 (0x00007ffd67b9b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5609111000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f560910b000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f56090ef000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5608efd000)
/lib64/ld-linux-x86-64.so.2 (0x00007f56099e8000)
WITH DWARF
arguments(
'-H:GenerateDebugInfo=1',
'-H:DebugInfoSourceSearchPath=/home/sergej/Development/Development/SVMPlayground/src/main/java/de/sergejisbrecht',
'-H:+PreserveFramePointer',
'--no-server',
'--no-fallback',
'--enable-all-security-services',
'--report-unsupported-elements-at-runtime'
)
-rwxrwxr-x 1 sergej sergej 14582464 Jan 17 17:16 topten*
COMPILATION-TIME
   ~/Development/Development/SVMPlayground time ./gradlew nativeImage  ✔  16:54:20
> Task :nativeImage
[topten:389763] classlist: 1,102.46 ms, 0.96 GB
[topten:389763] (cap): 530.00 ms, 0.96 GB
[topten:389763] setup: 1,644.79 ms, 0.96 GB
[topten:389763] (clinit): 203.09 ms, 1.22 GB
[topten:389763] (typeflow): 4,615.33 ms, 1.22 GB
[topten:389763] (objects): 3,542.47 ms, 1.22 GB
[topten:389763] (features): 278.51 ms, 1.22 GB
[topten:389763] analysis: 8,972.10 ms, 1.22 GB
[topten:389763] universe: 370.92 ms, 1.22 GB
[topten:389763] (parse): 1,054.40 ms, 1.71 GB
[topten:389763] (inline): 1,578.69 ms, 1.71 GB
[topten:389763] (compile): 7,256.46 ms, 2.34 GB
[topten:389763] compile: 10,377.30 ms, 2.34 GB
[topten:389763] image: 1,065.57 ms, 2.34 GB
[topten:389763] write: 181.18 ms, 2.34 GB
[topten:389763] [total]: 23,852.59 ms, 2.34 GB
________________________________________________________
Executed in 25,51 secs fish external
usr time 1444,47 millis 954,00 micros 1443,52 millis
sys time 159,43 millis 382,00 micros 159,05 millis
native-image --version
Toolchain
--libc selects the libc implementation to use. Available implementations:
glibc, musl
--native-compiler-options
provide custom C compiler option used for query code compilation.
--native-compiler-path
provide custom path to C compiler used for query code compilation
and linking.
--native-image-info show native-toolchain information and image-build settings
EXECUTION TIME
   ~/Development/Development/SVMPlayground/build/native-image time ./topten /home/sergej/Downloads/big2.txt  ✔   13s  16:56:04
und = 742224
der = 300752
die = 265888
da = 215936
zu = 161360
sie = 157024
den = 140000
er = 139776
das = 139760
ich = 129824
________________________________________________________
Executed in 13,70 secs fish external
usr time 13,52 secs 0,00 micros 13,52 secs
sys time 0,16 secs 1545,00 micros 0,16 secs
FLAMEGRAPH with DWARF
   ~/Development/Development/SVMPlayground/build/native-image flamegraph -c "record -F 99 -g" -- ./topten /home/sergej/Downloads/big2.txt  ✔  17:16:44
Setup:
Linux sergej-ThinkPad-P50 5.8.0-36-generic #40~20.04.1-Ubuntu SMP Wed Jan 6 10:15:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
You may need to install the following packages for this specific kernel:
linux-tools-5.8.0-36-generic
linux-cloud-tools-5.8.0-36-generic
GraalVM Version 20.3.0 (Java Version 11.0.9+10-jvmci-20.3-b06)
# echo 1 > sudo tee /proc/sys/kernel/perf_event_paranoid
# echo 0 > sudo tee /proc/sys/kernel/kptr_restrict
jdk install java 20.3.0.r11-grl
package de.sergejisbrecht;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class TopTen {
private static final Pattern PATTERN_REPLACE = Pattern.compile("[^a-zA-Z]");
private static final Pattern PATTERN_SPLIT = Pattern.compile("\\b");
// /usr/bin/time ...
public static void main(String[] args) {
Arrays.stream(args)
.parallel()
.flatMap(TopTen::fileLines)
.flatMap(TopTen::split)
.map(TopTen::replace)
.filter(word -> word.length() > 0)
.map(String::toLowerCase)
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
.entrySet()
.stream()
.sorted((a, b) -> -a.getValue().compareTo(b.getValue()))
.limit(10)
.forEach(e -> System.out.format("%s = %d%n", e.getKey(), e.getValue()));
}
private static String replace(String word) {
// word.replaceAll("[^a-zA-Z]", "");
Matcher matcher = PATTERN_REPLACE.matcher(word);
return matcher.replaceAll("");
}
private static Stream<String> split(String word) {
// line.split("\\b")
return Arrays.stream(PATTERN_SPLIT.split(word));
}
private static Stream<String> fileLines(String path) {
try {
return Files.lines(Paths.get(path));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment