Skip to content

Conversation

gsmet
Copy link
Member

@gsmet gsmet commented Aug 15, 2025

Better reviewed commit per commit as I made them semantic.

These optimizations are NOT CPU related: I was having a look at memory allocation profiles.

An example of what we're trying to solve here.

Before:

Screenshot From 2025-08-15 10-25-42

After:

Screenshot From 2025-08-15 10-24-21

gsmet added 5 commits August 15, 2025 10:07
Instead of transforming all the submitted DotNames to toString(), we only
submit the ones we test against.
And also avoiding creating an additional list with the Jandex call.
It's going to be a bit larger than required in some cases, but it will
avoid resizing the list, which should be a win in most cases.
It triggers unnecessary allocations and it's visible when there are a
lot of beans.
Marko told me that it was actually faster to iterate and from what I can
see it's true.
I won't change it everywhere but it seems like a good idea to make the
change in the Core parts.

Note that some of the changes I made might not be critical but it wasn't
worth the hassle to check everywhere if it actually made a noticeable
difference given the size of the change.
@quarkus-bot quarkus-bot bot added area/arc Issue related to ARC (dependency injection) area/config area/core labels Aug 15, 2025
Comment on lines -412 to 422
if (arcConfig.shouldEnableBeanRemoval()) {
Set<String> unremovableClassNames = unremovableBeans.stream()
Set<DotName> unremovableClassNames = unremovableBeans.stream()
.map(UnremovableBeanBuildItem::getClassNames)
.flatMap(Collection::stream)
.collect(toSet());

for (ConfigClassBuildItem configClass : configMappingTypes.values()) {
if (configClass.getConfigClass().isAnnotationPresent(Unremovable.class)
|| unremovableClassNames.contains(configClass.getName().toString())) {
|| unremovableClassNames.contains(configClass.getName())) {
toRegister.add(new ConfigMappingBuildItem(configClass.getConfigClass(), configClass.getPrefix()));
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkouba I would appreciate if you could have a look at this as it looks extremely odd. I don't think it should be done this way: it's not actually applying the predicates but relying on the class names being set, which won't work if you have a custom predicate.
I can understand it given you don't have the BeanInfo but I wonder if there could be a better way to achieve the same goal by using ArC metadata?

It's a separate work though, I just kept the logic as is for now.

It was added by @radcortez here: 564d112 .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct indeed.

Given the fact that this logic is executed after the validation phase (unused beans are already removed if needed) I think that the correct solution would be to attempt to find a bean for a given config mapping class and if it's present then register the ConfigMappingBuildItem.

@radcortez Something like this should IMO work:

for (ConfigClassBuildItem configClass : configMappingTypes.values()) {
   if (!validationPhase.getContext().beans().withBeanClass(configClass.getConfigClass()).isEmpty()) {
      toRegister.add(new ConfigMappingBuildItem(configClass.getConfigClass(), configClass.getPrefix()));
   }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, when we clean this up, let's get rid of the classNames field in UnremovableBuildItem. And I think we could also drop the unnecessary public constructors that were added in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I think we could also drop the unnecessary public constructors

We should deprecate them first...

@gsmet gsmet requested review from Ladicek and mkouba August 15, 2025 08:16
Copy link
Contributor

@Ladicek Ladicek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gsmet
Copy link
Member Author

gsmet commented Aug 15, 2025

@Ladicek FWIW, I added one example of the improvements made here in the description.

Copy link

quarkus-bot bot commented Aug 15, 2025

Status for workflow Quarkus Documentation CI

This is the status report for running Quarkus Documentation CI on commit 8b37ff8.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

Warning

There are other workflow runs running, you probably need to wait for their status before merging.

Copy link

🎊 PR Preview 9beaf39 has been successfully built and deployed to https://quarkus-pr-main-49555-preview.surge.sh/version/main/guides/

  • Images of blog posts older than 3 months are not available.
  • Newsletters older than 3 months are not available.

Copy link

quarkus-bot bot commented Aug 15, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 8b37ff8.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.


Flaky tests - Develocity

⚙️ JVM Tests - JDK 17 Windows

📦 extensions/micrometer-opentelemetry/deployment

io.quarkus.micrometer.opentelemetry.deployment.compatibility.MicrometerTimedInterceptorTest.testTimeMethod - History

  • Stream has no elements - java.lang.IllegalArgumentException
java.lang.IllegalArgumentException: Stream has no elements
	at io.quarkus.micrometer.opentelemetry.deployment.common.MetricDataFilter.lambda$lastReading$2(MetricDataFilter.java:213)
	at java.base/java.util.Optional.orElseThrow(Optional.java:403)
	at io.quarkus.micrometer.opentelemetry.deployment.common.MetricDataFilter.lastReading(MetricDataFilter.java:213)
	at io.quarkus.micrometer.opentelemetry.deployment.common.MetricDataFilter.lastReadingDataPoint(MetricDataFilter.java:231)
	at io.quarkus.micrometer.opentelemetry.deployment.compatibility.MicrometerTimedInterceptorTest.testTimeMethod(MicrometerTimedInterceptorTest.java:77)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at io.quarkus.test.QuarkusUnitTest.runExtensionMethod(QuarkusUnitTest.java:534)

@gsmet gsmet merged commit 8b1dd48 into quarkusio:main Aug 15, 2025
59 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.28 - main milestone Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/config area/core triage/flaky-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants