davsclaus opened a new pull request, #29879:
URL: https://github.com/apache/camel/pull/29879

   ## What
   
   CAMEL-26936, a sub-task of CAMEL-26935 (make the Camel CLI faster for AI 
agents).
   
   `camel run --background`, `camel restart`, and `camel_run` of the MCP server 
and the TUI wait for the integration to start by reading its status file. The 
connector wrote that file every second, its first one before Camel had started, 
and the commands looked at it every 500, 200 and 250 millis. So `camel run 
--background` returned about 1.3 seconds after the routes had started.
   
   - The file transport of the connector writes the status as soon as Camel 
changes phase, such as when it has started: it looks at the phase with every 
action poll. It also writes the status after it answers actions, so a `camel 
get` right after a `camel cmd` shows what the action did (it showed the totals 
of before the action in 3 of 4 tries). As collecting the status costs, that is 
at most every 200 millis, besides the status every second.
   - `camel run --background`, `camel restart` and `IntegrationLauncher` 
(`camel_run`, and its restarts) look at the status every 50 millis 
(`ProcessFinder.STATUS_POLL_INTERVAL`).
   - `IntegrationLauncher` reads the status of its own integration first, and 
only then finds it among all the integrations, which reads all of their status 
files. It did that every 250 millis.
   
   With an integration of an earlier Camel version, the commands see the status 
once a second, as before.
   
   This PR and #29878 (CAMEL-26938, the action poll every 20 millis) change the 
same lines of `FileCliConnectorTransport.actionPollTask` and of 
`cli-connector.adoc`; the one merged second gets a rebase. With both, Camel 
having started is seen within about 20 millis.
   
   ## Measured
   
   macOS (M4 Pro), JDK 25. The camel-launcher of main, and the same launcher 
with the `camel-cli-connector` and `camel-jbang-core` jars of this PR, run 
`camel run hello.camel.yaml --background` (a timer route) 6 times each, taking 
turns:
   
   | | returns after | routes started (log) | lag |
   |---|---|---|---|
   | main | 2.94 s | 1.60 s | 1.34 s |
   | this PR | 2.02 s | 1.60 s | 0.42 s |
   
   Most of the lag left is the exit of the CLI: on macOS a JVM that exits while 
its child runs takes about 0.3 seconds longer. `camel run --background` prints 
that the integration is running at 1.65 s and exits at 1.96 s; on main it also 
exits 0.33 s after it printed. A double fork could save that (the other part of 
CAMEL-26936), which is not in this PR.
   
   ## Tests
   
   - `FileCliConnectorTransportTest`: with the status every 60 seconds, the 
status shows that Camel has started as soon as it has, and the status is 
written after an action. Each test fails without its change. 
`actionsAreAnsweredBetweenTwoStatusUpdates` now allows a status after the 
actions, at most every 200 millis.
   - The tests of `camel-cli-connector` and `camel-jbang-core` pass.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to