Skip to content

Commit ca36b8c

Browse files
committed
GROOVY-10307: Set initial capacity for call site registry
1 parent 43d99f9 commit ca36b8c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/main/java/org/codehaus/groovy/vmplugin/v8/IndyInterface.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
public class IndyInterface {
5454
private static final long INDY_OPTIMIZE_THRESHOLD = SystemUtil.getLongSafe("groovy.indy.optimize.threshold", 10_000L);
5555
private static final long INDY_FALLBACK_THRESHOLD = SystemUtil.getLongSafe("groovy.indy.fallback.threshold", 10_000L);
56+
/**
57+
* Initial capacity for the call site registry used to track all active call sites
58+
* for cache invalidation when metaclass changes occur. The default of 1024 balances
59+
* memory usage against resize overhead. Tune via {@code groovy.indy.callsite.initial.capacity}
60+
* system property for larger applications.
61+
*/
62+
private static final int INDY_CALLSITE_INITIAL_CAPACITY = SystemUtil.getIntegerSafe("groovy.indy.callsite.initial.capacity", 1024);
5663

5764
/**
5865
* flags for method and property calls
@@ -176,7 +183,7 @@ public static CallType fromCallSiteName(String callSiteName) {
176183
* Weak set of all CacheableCallSites. Used to invalidate caches when metaclass changes.
177184
* Uses WeakReferences so call sites can be garbage collected when no longer referenced.
178185
*/
179-
private static final Set<WeakReference<CacheableCallSite>> ALL_CALL_SITES = ConcurrentHashMap.newKeySet();
186+
private static final Set<WeakReference<CacheableCallSite>> ALL_CALL_SITES = ConcurrentHashMap.newKeySet(INDY_CALLSITE_INITIAL_CAPACITY);
180187

181188
static {
182189
GroovySystem.getMetaClassRegistry().addMetaClassRegistryChangeEventListener(cmcu -> invalidateSwitchPoints());

0 commit comments

Comments
 (0)