davsclaus opened a new pull request, #30203: URL: https://github.com/apache/camel/pull/30203
[CAMEL-27050](https://issues.apache.org/jira/browse/CAMEL-27050) `camel catalog component` (with or without `--filter`) took about 420 ms, three times as long as the other short commands. For each of the 422 components it read the whole model JSON from the catalog and parsed it into a `ComponentModel`: 14 MB of JSON, as the options and headers are most of each file. The list shows only the name, title, support level, since, description, label, native and Maven coordinates, which are all in the first object of the file (`"component"`). ### Change `CatalogModelHeader.componentModel` reads each component JSON only up to the end of its `"component"` object (strings, escapes and nested objects are skipped correctly), and builds the model from that object with `JsonMapper.generateComponentModel`, so the getters behave the same. The JSON is read through the version manager and runtime provider of the catalog, so it also works for `--camel-version`, Spring Boot and Quarkus. When the JSON is not in the catalog (a component added to it at runtime) or does not start with that object, the whole model is read from the catalog as before. Only components: the models of data formats, languages and others are a few KB, and reading the first object before parsing it cost 6-10 ms more than parsing the whole small file (measured), so those lists stay as they are. ### Measured JDK 25, macOS (Apple M4 Pro), through `camel.sh` (with its CDS archive), median of 15 runs: | command | main | this PR | |---|---|---| | `camel catalog component` | 441 ms | 223 ms | | `camel catalog component --filter=kafka` | 417 ms | 215 ms | | `camel catalog dataformat` (unchanged) | 174 ms | 178 ms | ### Tests - `CatalogModelHeaderTest` (new): the first object only; braces and escaped quotes in strings; another first key, a longer key, a value that is not an object, a JSON that ends first; and for every component of the catalog, every field the list shows is the same as from the whole model. - camel-jbang-core `Catalog*Test`: 177 run, 0 failures. - Distribution: the output of `catalog component` (all 422, `--filter=kafka --json`, a filter that matches nothing), `--camel-version=4.18.0` with `--runtime=spring-boot` and `--runtime=quarkus`, and `catalog dataformat` is byte for byte the same as on main. Related: #30199 (CAMEL-27045) and #30201 (CAMEL-27048), the other startup work for the short commands. _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]
