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

   `ZoneId.systemDefault()`, and parsing a time with a region such as 
`[Europe/Paris]`, load the time zone rules of java.time. The JDK then looks for 
their providers (`ZoneRulesProvider`) with a `ServiceLoader` in every JAR of 
the class path: about 50 ms with the 340 JARs of the CLI distribution, on a 
short command that otherwise needs a dozen JARs. Found while working on the 
startup of the short commands (CAMEL-26935).
   
   ### Change
   
   `CliTimes` (camel-jbang-run) gives local times without those rules: the 
offset of the default `TimeZone` at that time (both read the tzdb data of the 
JDK, so the local time is the same, also around daylight saving changes), and 
the epoch millis of an ISO date-time from its offset (the region in brackets is 
left out; a text without an offset still goes to `ZonedDateTime.parse`).
   
   It is used where a short command printed a local time or parsed one:
   
   - `camel get health`: the SINCE column parsed the times of the health checks 
with `ZonedDateTime.parse` (with region) and `ZonedDateTime.now()`.
   - `camel log`: the tip about the previous run (`PreviousRun`), whose 
formatter called `ZoneId.systemDefault()` when the class was loaded.
   - `camel get sql-trace`: the TIME column.
   
   The other uses of java.time zones in the CLI are in commands that do much 
more anyway (run, export, the AI tools, chaos explore).
   
   Measured on a small program with the class path of the distribution: 
formatting a local time with `ZoneId.systemDefault()` 60 ms, with `CliTimes` 7 
ms (`SimpleDateFormat` 21 ms, it loads locale data).
   
   ### Measured
   
   JDK 25, macOS (Apple M4 Pro), through `camel.sh` (with its CDS archive), 
median of 15 runs; CPU time (user + system), with the wall time in brackets, as 
the machine was busy:
   
   | command | main | this PR |
   |---|---|---|
   | `camel get health` (one integration) | 445 ms (244 ms) | 373 ms (223 ms) |
   | `camel log` (tip about a previous run) | 316 ms (165 ms) | 306 ms (163 ms) 
|
   
   `camel log` gains little on main today, as aesh's class path scan 
(aeshell/aesh#779) and its JUL loggers (aeshell/aesh#782) open every JAR first; 
with those fixed, and #30199, the zone rules were 30 ms of it.
   
   ### Tests
   
   - `CliTimesTest` (new): the same local time as `ZoneId.of(zone)` for 
Copenhagen, New York, Kolkata, Lord Howe (half hour daylight saving) and UTC, 
at the second before and after each daylight saving change of 2026; parsing the 
text of a `ZonedDateTime` with and without region, with an offset and `Z`; a 
text that is not a date-time.
   - camel-jbang-run: `CliTimesTest`, `PreviousRunTest`, `PreviousRunLogTest`; 
camel-jbang-core: `ListHealthTest`, `ListSqlTraceTest`, `CamelLogActionTest` 
and the process tests: all pass.
   - Distribution: `-Xlog:class+load` shows no `ZoneRulesProvider` for `get 
health` and the `log` tip (main: loaded); their output is the same as on main.
   
   _Claude Code on behalf of 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