[ 
https://issues.apache.org/jira/browse/CAMEL-26942?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen reassigned CAMEL-26942:
-----------------------------------

    Assignee: Claus Ibsen

> camel-jbang - design: a resident CLI daemon or a native front for the short 
> commands
> ------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26942
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26942
>             Project: Camel
>          Issue Type: Sub-task
>          Components: camel-jbang
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Major
>             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/}}.
> Two ways to remove the JVM start of the short commands. Both need a design 
> decision before any code.
> h3. Resident daemon (prototype measured)
> A 70-line prototype ran {{CamelLauncherMain}} once and served 
> {{CliRunner.run(args)}} (which already returns exit code, stdout, stderr and 
> timing as JSON) over a Unix socket, with {{nc -U}} as client:
> ||Command||New JVM||Socket round trip||
> |version|0.15 s|26-30 ms|
> |ps --json|0.25 s|28 ms|
> |get route --json|0.28 s|27 ms|
> |doc timer|0.26 s|37 ms|
> |validate yaml|0.42 s|73 ms|
> |cmd send|0.46-0.75 s|137 ms (the action poll)|
> That is 10-20x, and the loop would take about 1.6 s (estimate). What it 
> needs: commands that start a process ({{run --background}}, {{restart}}, 
> {{debug}}, {{infra run}}) must be handled by the daemon itself (today they 
> fall back to the {{camel}} on PATH outside the launcher); cwd and environment 
> per request; direct console writers ({{AnsiConsole.out()}}, {{System.out}}) 
> bypass the {{CliRunner}} printer; one command at a time ({{CliRunner.LOCK}}); 
> the command line is a static field and {{quit()}} calls {{System.exit}}; 
> daemon lifecycle, upgrades and the security of the socket. The connector's 
> WebSocket transport already pushes a hello frame, snapshots and action 
> results, so a daemon could get push readiness instead of polling. Today the 
> MCP server is the resident path for agents, but it still uses the file 
> protocol (100 ms actions, about 0.9 s status lag).
> h3. Native front (feasibility study, no prototype: no GraalVM on the test 
> machine)
> Compiling the whole CLI is not realistic: run, export, plugins, Maven 
> resolution and the TUI load classes at run time. A split is: a native binary 
> for version, ps, stop, get, log, doc, catalog and cmd on a running 
> integration, which execs the JVM launcher for everything else. Estimated 
> 10-40 ms per short command, 30-45 MB without the catalog (50-70 MB with the 
> catalog JSON, no docs). The libraries are fine: aesh has a native-image test 
> in its CI, JLine, the terminal jars and log4j ship GraalVM metadata, and the 
> catalog is plain JSON with no reflection. The blockers are in our code:
> * No GraalVM metadata in any CLI module.
> * The base classes of the short commands reach heavy code: {{CamelCommand}} 
> (log4j), {{ActionBaseCommand.java:276}} ({{Run}}, {{KameletMain}} for the 
> route dump of files), {{CamelJBangMain}} ({{PluginHelper}}, Maven).
> * aesh builds the model by reflection (156 commands, 943 option sites); its 
> annotation processor would avoid that but needs a no-arg constructor 
> ({{AeshAnnotationProcessor}} lines 202-216), and every Camel command takes 
> {{CamelJBangMain}}: a small ask for aesh.
> * Distribution: 4-5 binaries per release built on one runner per platform, 
> Mandrel or GraalVM in the release, macOS signing, the 
> installers/Homebrew/SDKMAN switch from a Java binary, and an ASF legal check 
> of the GPLv2 + Classpath Exception runtime in the binary (Apache Maven mvnd 
> ships a native client).
> * The cmd file protocol keeps a 100-200 ms floor in any client.
> Effort: 1-2 weeks to a prototype, 6-8 weeks to ship (estimate).
> h3. Suggested order
> The quick-win sub-tasks first, then the AOT cache, then decide between a 
> daemon (same speed, no per-platform binaries, more runtime risk) and a native 
> front (no background process, more build and release work).
> _Claude Code on behalf of Claus Ibsen_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to