davsclaus commented on code in PR #27285:
URL: https://github.com/apache/camel/pull/27285#discussion_r4166205061


##########
dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CatalogDependencyResolver.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.main.download;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.tooling.maven.MavenGav;
+import org.apache.camel.tooling.model.ArtifactModel;
+
+final class CatalogDependencyResolver {
+
+    private final CamelContext camelContext;
+    private final CamelCatalog catalog = new DefaultCamelCatalog();

Review Comment:
   `new DefaultCamelCatalog()` has caching turned off, and each of the four 
call sites creates its own resolver and catalog. `modelFromMavenGAV` parses the 
JSON of every component, then every data format, language, "other" and 
transformer, until one matches. I measured it on a fresh catalog: 
`camel-aws2-s3` 60 ms, `camel-zipfile` (a data format) 179 ms, `camel-main` (an 
"other") 127 ms, and still about 20 ms on a repeat. An uncataloged artifact 
costs the full scan every time.
   
   `KnownDependenciesResolver.mavenGavForClass` runs this for every lookup that 
maps to a `camel:` value, including `DependencyDownloaderPropertiesComponent`, 
which looks up each property key, value and line. So many properties for one 
component repeat the scan at startup. Could the four call sites share one 
resolver, using `new DefaultCamelCatalog(true)`, and keep a small map from 
shorthand to resolved GAV?



-- 
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