Claus Ibsen created CAMEL-26937:
-----------------------------------
Summary: camel-jbang - faster startup of the short commands: no
JLine terminal or log4j when not needed, and C1 for the CLI JVM
Key: CAMEL-26937
URL: https://issues.apache.org/jira/browse/CAMEL-26937
Project: Camel
Issue Type: Sub-task
Components: camel-jbang
Reporter: Claus Ibsen
Fix For: 4.24.0
Measured on 2026-11-13 with the unpacked 4.24.0-SNAPSHOT camel-launcher on
macOS (Apple M4 Pro, JDK 25), warm CDS archives, medians of 5-9 runs on a
machine with other load (treat as +/-30 %). Estimates are marked as such. Paths
are relative to {{dsl/camel-jbang/}}.
h3. 1. No color and no JLine terminal when stdout is not a terminal
{{CamelCommand.printColored}} (around lines 312 and 323) writes through
{{org.jline.jansi.AnsiConsole.out()}}, which builds a JLine system terminal
({{JniNativePty}}, {{TerminalBuilder}}), also when the output is piped.
Measured: {{camel log}} 0.48 -> 0.32 s, {{cmd send}} 0.75 -> 0.57 s, with
byte-identical output. This is a fixed cost per command, on top of the per-line
cost of CAMEL-26911 item 5. Default to plain output when there is no terminal.
h3. 2. No log4j initialization for commands that do not log
{{CamelCommand.configureLoggingOff}} (line 62) calls
{{RuntimeUtil.configureLog("off", ...)}} for every command whose
{{disarrangeLogging()}} is true (all but catalog, export and script). For ps,
get route and doc that loads about 520 log4j-core, 86 log4j-api, 28
layout-template-json and 150 Jackson 2 classes (through log4j's configuration
factories). Measured with the slf4j NOP provider: ps 0.245 -> 0.160 s, doc
0.259 -> 0.171 s, get route 0.265 -> 0.194 s, cmd send 0.465 -> 0.385 s (about
-30 %). Builds on CAMEL-26913 item 6 (static slf4j loggers bind log4j early).
h3. 3. C1 only for the CLI JVM
{{-XX:TieredStopAtLevel=1}}: get route 0.287 -> 0.241 s, validate 0.420 ->
0.349 s, and half the user CPU. It must not reach the integrations:
{{LauncherHelper.getCamelCommand()}} (lines 136-140) forwards every
{{-D}}/{{-X}} argument of the CLI JVM to a background integration, which today
also caps integrations at {{-Xmx512m}}.
h3. 4. Fewer jars to open
aesh {{MetadataProviderRegistry}} calls
{{getResources("META-INF/aesh/registry")}} and a ServiceLoader, which opens all
343 jars of the manifest class path: 49-51 ms against 18 ms for one merged jar.
A registry file or a skip of the discovery in aesh, or fewer jars, saves 30-50
ms.
Not worth it: SerialGC alone, {{log4j2.disable.jmx}} alone, changes to camel.sh
(about 15 ms).
Together with the AOT cache sub-task: ps, get, doc and log go from about 0.25 s
to about 0.15 s (measured combination: no log4j + one AOT cache + C1).
_Claude Code on behalf of Claus Ibsen_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)