davsclaus commented on code in PR #27285:
URL: https://github.com/apache/camel/pull/27285#discussion_r4166365457
##########
dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/DependencyDownloaderKamelet.java:
##########
@@ -179,9 +179,9 @@ private void downloadDependencies(List<String>
dependencies) {
final List<String> gavs = new ArrayList<>();
for (String dep : dependencies) {
String gav = dep;
- if (dep.startsWith("camel:")) {
- // it's a known camel component
- gav = "org.apache.camel:camel-" +
dep.substring("camel:".length()) + ":" + camelContext.getVersion();
+ if (CatalogDependencyResolver.isCamelShorthand(dep)) {
Review Comment:
This resolves `camel:core`, which almost every kamelet declares, through the
catalog before `isValidGav` drops `org.apache.camel:camel-core` as already
included. `camel-core` isn't in the catalog, so this costs a full scan (~245
ms, and the retained heap with the cached catalog) for a dependency that is
thrown away a few lines later. Could `camel-core` (and `camel-kamelet`) be
skipped before resolving?
##########
dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CatalogDependencyResolver.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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 java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+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 static final CamelCatalog CATALOG = new DefaultCamelCatalog(true);
Review Comment:
Since `COORDINATES` already caches the result per artifact, the catalog's
own cache only retains the models parsed during each scan: about +33 MB after
resolving one artifact that isn't in the catalog (`camel-core`). Uncached, each
artifact is still looked up once, and the models can be garbage-collected:
```suggestion
private static final CamelCatalog CATALOG = new DefaultCamelCatalog();
```
--
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]