davsclaus opened a new issue, #3133:
URL: https://github.com/apache/camel-kamelets/issues/3133
`camel catalog kamelet` in the Apache Camel CLI takes about 720 ms, where
its other short commands take 100-200 ms. Most of that is the constructor of
`KameletsCatalog` (`library/camel-kamelets-catalog`), which loads every Kamelet
up front.
### What happens
`KameletsCatalog()` calls `initCatalog()`, which:
1. scans the whole class path with ClassGraph (`acceptPaths("/kamelets/")`),
which lists the entries of every JAR on it (the Camel CLI has 341), and
2. parses each of the 259 `*.kamelet.yaml` files into the Kamelet CRD model
with a Jackson YAML `ObjectMapper` (fabric8 CRD classes, about 400
jackson-databind classes loaded).
It also creates a `DefaultCamelCatalog` per instance (the `cc` field),
whether or not it is used.
A caller that only needs the names, or the name, type, support level and
description of each Kamelet (a list), pays for all of it.
### Measured
`camel catalog kamelet` on JDK 25, macOS (Apple M4 Pro), from the class
loading timeline:
| phase | time |
|---|---|
| CLI: Maven resolution of `camel-kamelets-catalog` | 170 ms |
| `KameletsCatalog` class and Jackson `ObjectMapper` setup | 110 ms |
| ClassGraph scan for `/kamelets/` | 230 ms |
| parsing the 259 YAML files into `Kamelet` | 210 ms |
The first phase is on the Camel side; the other three are in
`KameletsCatalog`.
### What would help
- **An index instead of the scan**: generate a list of the Kamelets at build
time (for example `kamelets/kamelets.properties` or a generated class), so the
catalog reads the names without scanning the class path.
- **Parse on demand**: parse a Kamelet into the CRD model when it is asked
for (`getKameletByName`, `getKameletsByType`, ...), not all of them in the
constructor.
- **A summary for lists**: put name, type, support level, group, namespace
and description of each Kamelet in that index, so a list needs no YAML parsing
at all.
- **The `DefaultCamelCatalog`** created only when a method uses it.
The proposal to move the Kamelet catalog into apache/camel
([CAMEL-21049](https://issues.apache.org/jira/browse/CAMEL-21049)) could pick
this up as well. On the Camel side, the CLI work is tracked in
[CAMEL-26935](https://issues.apache.org/jira/browse/CAMEL-26935).
_Drafted by Claude Code on behalf of Claus Ibsen_
--
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]