Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Dec 5, 2025

This one takes a type argument instead of as a tree argument. This makes mapping such annotations a lot faster and also safer. In fact, in retrospect, most annotations could be represented as CompactAnnotations.

CompactAnnotation is extended by RetainingAnnotation, which is reserved for @retains, @retainsByName and @retainsCap. We make sure that all annotations with these classes are represented as RetainingAnnotations.

For now there are no CompactAnnotations other than @RetainingAnnotations but this could be changed in the future.

@odersky odersky force-pushed the opt-annots branch 3 times, most recently from 9af8000 to 66aa6bb Compare December 8, 2025 19:10
We don't need the constructor anymore since `RetainingAnnotation` has equivalent
functionality. And we don't need the deconstructor since there is already
`CapturingOrRetainsType`.
@odersky
Copy link
Contributor Author

odersky commented Dec 9, 2025

I did some benchmarking: I compiled repeatedly the contents of typer/*.scala. Results are here:

Screenshot 2025-12-09 at 17 11 58

Benchmark setup: 2 compiler instances with 20 runs each. Classpath is kept in memory between runs. Tests were run on an M4 Macbook Pro.

lines: Total number of lines
best: average of 13 best runs (out of 40 total)
avg: average of 13 last runs

The gist is:

  • Raw compile speed is between 20K and 24K lines / second.
  • We lose about 5% between 3.3.6 and 3.6.2.
  • We lose a further 10% between 3.6.2 and 3.7.3/3.8.0
  • We regain about 1.5% with this PR.

We should drill deeper and find out where the other losses came from.

@odersky
Copy link
Contributor Author

odersky commented Dec 9, 2025

I noticed that some of the versions in the benchmarks produced warnings and other did not, so I reran them with warnings off. Here are the new numbers.

Screenshot 2025-12-09 at 19 19 49

So, we lose about 4% from 3.3 to 3.6, another 2.5% from 3.6 to 3.7, and another 4% between 3.7 and 3.8. And this PR makes no difference to the 3.8 baseline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants