Class PerfRegressionTest

java.lang.Object
org.checkerframework.framework.test.junit.PerfRegressionTest

public class PerfRegressionTest extends Object
Regression tests for performance-relevant invariants that have broken in the past or whose accidental reintroduction would silently undo a shipped optimization.

Every test in this class documents the PR it guards (or the rejected-direction it prevents), so a future reader can decide whether their proposed change is actually safe. Do not delete a test here without understanding what it protects; the corresponding entry in docs/developer/performance-notes.md has the full rationale.

  • Constructor Details

    • PerfRegressionTest

      public PerfRegressionTest()
      Default constructor.
  • Method Details

    • annotationMirrorSet_addAll_returnsTrueIfAnyNew

      public void annotationMirrorSet_addAll_returnsTrueIfAnyNew()
      AnnotationMirrorSet.addAll(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror>) must return true when any element was newly added, per the standard Set.addAll(java.util.Collection<? extends E>) contract. PR #1649 initially shipped with this collapsed to an all-or-nothing return value, which broke indextest where callers rely on addAll to report whether the receiver grew at all.
    • annotationMirrorSet_addAll_returnsFalseIfAllDuplicates

      public void annotationMirrorSet_addAll_returnsFalseIfAllDuplicates()
      Complementary case: addAll of an all-duplicate collection must return false.
    • annotationMirrorSet_iterator_isMutableByDefault

      public void annotationMirrorSet_iterator_isMutableByDefault()
      The bare AnnotationMirrorSet.iterator() is mutable. The unmodifiable wrapper comes from AnnotationMirrorSet.unmodifiableSet(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror>) (formerly makeUnmodifiable), not from iterator() itself. Past patches have inverted this; the cost is a defensive copy on every iteration.
    • annotationMirrorSet_isNotNavigableSet

      public void annotationMirrorSet_isNotNavigableSet()
      AnnotationMirrorSet must not implement NavigableSet. PR #1649 dropped the TreeSet backing in favor of ArrayList; the changelog promises Set- only semantics. Re-implementing NavigableSet would reintroduce the compareTo-driven Name.toString decoding that prompted the rewrite.
    • annotationUtils_annotationName_returnsInternedString

      public void annotationUtils_annotationName_returnsInternedString()
      After PR #1673, AnnotationUtils.annotationName(javax.lang.model.element.AnnotationMirror) returns an interned string. The separate annotationNameInterned method was removed because it was redundant. Hot downstream callers (qualifier hierarchy lookups, supported-qualifier checks) rely on this: a regression here would silently re-allocate one String per call.
    • annotationUtils_annotationNameAsName_exists

      public void annotationUtils_annotationNameAsName_exists() throws NoSuchMethodException
      The AnnotationUtils.annotationNameAsName(javax.lang.model.element.AnnotationMirror) accessor introduced in PR #1669 returns the underlying Name without going through toString. Removing it would force the hot LUB/GLB paths back to per-call UTF-8 decoding.
      Throws:
      NoSuchMethodException
    • annotatedTypeScanner_visitedNodes_isIdentityHashMap

      public void annotatedTypeScanner_visitedNodes_isIdentityHashMap() throws NoSuchFieldException
      AnnotatedTypeScanner.visitedNodes must be an IdentityHashMap, not a plain HashMap. Identity is required for correctness: distinct ATM instances representing the same Java type must be visited separately so cycle-breaking works. It is also faster (no hashCode dispatch). See docs/developer/performance-notes.md.
      Throws:
      NoSuchFieldException
    • annotatedTypeFactory_annotationClassNames_notSynchronized

      public void annotatedTypeFactory_annotationClassNames_notSynchronized() throws Exception
      AnnotatedTypeFactory.annotationClassNames must not be wrapped in Collections.synchronizedMap. The wrapper was carried over from a 2020 refactor of a previously-static cache; the threading audit showed AT factories are confined to the javac main thread, matching every other per-factory LRU on the same object. Reintroducing the wrapper would re-add the per-call monitor enter/exit cost.

      The check inspects the declared field type. Collections.synchronizedMap returns an instance of Collections$SynchronizedMap; a regression that reintroduces synchronization would typically widen the declared type back to Map, and this test will fail then.

      Throws:
      Exception
    • subtypeVisitHistory_keyedOverloads_exist

      public void subtypeVisitHistory_keyedOverloads_exist()
      The package-private putKey/removeKey/containsKey methods on SubtypeVisitHistory exist to let StructuralEqualityVisitHistory share one Pair across both inner histories per public call. Removing them would halve the allocation reduction shipped in PR #1719.