From 84e250dffb5d950daf5115b06c77e5b3e72edfcd Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 27 Apr 2023 20:03:33 +0200 Subject: [PATCH] Updated Improve Performance of PGPainless CLI with Nailgun (markdown) --- ...Performance-of-PGPainless-CLI-with-Nailgun.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Improve-Performance-of-PGPainless-CLI-with-Nailgun.md b/Improve-Performance-of-PGPainless-CLI-with-Nailgun.md index dc4fd16..351adc2 100644 --- a/Improve-Performance-of-PGPainless-CLI-with-Nailgun.md +++ b/Improve-Performance-of-PGPainless-CLI-with-Nailgun.md @@ -1,6 +1,6 @@ When executing a short-lived CLI application written in Java, a huge portion of the runtime is wasted on booting the JVM. -To fix this issue, [nailgun]() can be used: +To fix this issue, [nailgun](https://github.com/facebookarchive/nailgun) can be used: Nailgun is a client, protocol, and server for running Java programs from the command line without incurring the JVM startup overhead. Programs run in the server (which is implemented in Java), and are triggered by the client (written in C), which handles all I/O. @@ -12,13 +12,13 @@ This is because nailgun uses features from Java 8, which were removed in later r Simply execute the nailgun-server.jar on the Java 8 JVM: ```shell -$JAVA8_HOME/bin/java -jar nailgun-server.jar +$ $JAVA8_HOME/bin/java -jar nailgun-server.jar ``` Next, load the pgpainless-cli-XYZ-all.jar: ```shell -ng ng-cp /path/to/pgpainless-cli-XYZ-all.jar +$ ng ng-cp /path/to/pgpainless-cli-XYZ-all.jar ``` ## Execute PGPainlessCLI calls @@ -27,11 +27,11 @@ The syntax for calling pgpainless-cli only changes a little bit. Here is an example without and with using nailgun: ```shell -# WITHOUT nailgun -java -jar pgpainless-cli-XYZ-all.jar generate-key "Alice " +$ # WITHOUT nailgun +$ java -jar pgpainless-cli-XYZ-all.jar generate-key "Alice " -# WITH nailgun -ng org.pgpainless.cli.PGPainlessCLI generate-key "Alice " +$ # WITH nailgun +$ ng org.pgpainless.cli.PGPainlessCLI generate-key "Alice " ``` As you can see, you now need to provide the name of the main class. @@ -43,7 +43,7 @@ On my machine, comparing the performance shows a drastic improvement! ```shell $ time (repeat 100 {java -jar pgpainless-cli-1.5.1-all.jar generate-key > /dev/null;}) ( repeat 100; do; java -jar pgpainless-cli-1.5.1-all.jar generate-key > ; done 167,06s user 9,14s system 216% cpu 1:21,42 total -# vs. +$ # vs. $ time (repeat 100 {ng org.pgpainless.cli.PGPainlessCLI generate-key > /dev/null;}) ( repeat 100; do; ng org.pgpainless.cli.PGPainlessCLI generate-key > /dev/nul) 0,21s user 0,99s system 20% cpu 5,914 total ``` \ No newline at end of file