Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

improve performance of the annotation overlay #495

Merged
merged 3 commits into from
Feb 11, 2025

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented Feb 11, 2025

Supersedes #494

There's several improvements in this commit:

1. Transformed annotations are always cached, even if no transformation
   applied. This makes it much faster in the most common case, while
   adding no significant memory overhead, because vast majority of objects
   already existed.

2. The transformation context implementation creates a copy of annotations
   lazily, on the first need. Again, this makes it much faster in the most
   common case (which is no annotation transformations applied).

3. Several copies were eliminated because they were just unnecessary overhead.
   For example, `AnnotationTarget.annotations()` or `declaredAnnotations()`
   already return unmodifiable collections, so there's no need to rewrap
   them again.

4. The [potentially transformed] annotations are no longer stored as a `Set`
   but as a `Collection`. This saves several copies and doesn't affect public
   API, which has always been defined in terms of `Collection`s.

5. Lambdas in `AnnotationOverlayImpl` were replaced by annonymous classes.
   The [modest] usage of streams was eliminated completely.
The benchmark is rather simplistic and cannot be used in isolation.
A real-world benchmark needs to be used as well.
@Ladicek Ladicek merged commit 6656c5b into smallrye:main Feb 11, 2025
35 checks passed
@Ladicek Ladicek deleted the improve-annotation-overlay branch February 11, 2025 17:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants