Skip to content

Commit 70ff21f

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

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
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. Default 1024 is a reasonable size for
58+
* typical applications, avoiding resizing during startup while not over-allocating.
59+
*/
60+
private static final int INDY_CALLSITE_INITIAL_CAPACITY = SystemUtil.getIntegerSafe("groovy.indy.callsite.initial.capacity", 1024);
5661

5762
/**
5863
* flags for method and property calls
@@ -176,7 +181,7 @@ public static CallType fromCallSiteName(String callSiteName) {
176181
* Weak set of all CacheableCallSites. Used to invalidate caches when metaclass changes.
177182
* Uses WeakReferences so call sites can be garbage collected when no longer referenced.
178183
*/
179-
private static final Set<WeakReference<CacheableCallSite>> ALL_CALL_SITES = ConcurrentHashMap.newKeySet();
184+
private static final Set<WeakReference<CacheableCallSite>> ALL_CALL_SITES = ConcurrentHashMap.newKeySet(INDY_CALLSITE_INITIAL_CAPACITY);
180185

181186
static {
182187
GroovySystem.getMetaClassRegistry().addMetaClassRegistryChangeEventListener(cmcu -> invalidateSwitchPoints());

0 commit comments

Comments
 (0)