Class PerfRegressionTest
java.lang.Object
org.checkerframework.framework.test.junit.PerfRegressionTest
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAnnotatedTypeFactory.annotationClassNamesmust not be wrapped inCollections.synchronizedMap.voidvoidComplementary case: addAll of an all-duplicate collection must return false.voidAnnotationMirrorSet.addAll(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror>)must returntruewhen any element was newly added, per the standardSet.addAll(java.util.Collection<? extends E>)contract.voidAnnotationMirrorSetmust not implementNavigableSet.voidThe bareAnnotationMirrorSet.iterator()is mutable.voidAfter PR #1673,AnnotationUtils.annotationName(javax.lang.model.element.AnnotationMirror)returns an interned string.voidTheAnnotationUtils.annotationNameAsName(javax.lang.model.element.AnnotationMirror)accessor introduced in PR #1669 returns the underlyingNamewithout going throughtoString.voidThe package-privateputKey/removeKey/containsKeymethods onSubtypeVisitHistoryexist to letStructuralEqualityVisitHistoryshare onePairacross both inner histories per public call.
-
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 returntruewhen any element was newly added, per the standardSet.addAll(java.util.Collection<? extends E>)contract. PR #1649 initially shipped with this collapsed to an all-or-nothing return value, which brokeindextestwhere callers rely onaddAllto 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 bareAnnotationMirrorSet.iterator()is mutable. The unmodifiable wrapper comes fromAnnotationMirrorSet.unmodifiableSet(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror>)(formerlymakeUnmodifiable), not fromiterator()itself. Past patches have inverted this; the cost is a defensive copy on every iteration. -
annotationUtils_annotationName_returnsInternedString
public void annotationUtils_annotationName_returnsInternedString()After PR #1673,AnnotationUtils.annotationName(javax.lang.model.element.AnnotationMirror)returns an interned string. The separateannotationNameInternedmethod 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 oneStringper call. -
annotationUtils_annotationNameAsName_exists
TheAnnotationUtils.annotationNameAsName(javax.lang.model.element.AnnotationMirror)accessor introduced in PR #1669 returns the underlyingNamewithout going throughtoString. Removing it would force the hot LUB/GLB paths back to per-call UTF-8 decoding.- Throws:
NoSuchMethodException
-
annotatedTypeScanner_visitedNodes_isIdentityHashMap
AnnotatedTypeScanner.visitedNodesmust be anIdentityHashMap, not a plainHashMap. 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 (nohashCodedispatch). Seedocs/developer/performance-notes.md.- Throws:
NoSuchFieldException
-
annotatedTypeFactory_annotationClassNames_notSynchronized
AnnotatedTypeFactory.annotationClassNamesmust not be wrapped inCollections.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.synchronizedMapreturns an instance ofCollections$SynchronizedMap; a regression that reintroduces synchronization would typically widen the declared type back toMap, and this test will fail then.- Throws:
Exception
-
subtypeVisitHistory_keyedOverloads_exist
public void subtypeVisitHistory_keyedOverloads_exist()The package-privateputKey/removeKey/containsKeymethods onSubtypeVisitHistoryexist to letStructuralEqualityVisitHistoryshare onePairacross both inner histories per public call. Removing them would halve the allocation reduction shipped in PR #1719.
-