You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When parsing large source code and using
is a hotspot.
This is due to frequent container size expansion in Array2DHashSet.java and FlexibleHashMap.java.
During expansion, all hashes of items registered in the container are recomputed.
antlr4/runtime/Java/src/org/antlr/v4/runtime/misc/Array2DHashSet.java
Line 159 in f25a4f6
antlr4/runtime/Java/src/org/antlr/v4/runtime/misc/FlexibleHashMap.java
Line 194 in f25a4f6
In order to check how often the expansion is occurring, we have rewritten the log to output the following.
Array2DHashSet.java
FlexibleHashMap.java
It appears that the initial size of 16 is small, even for small input sources.
I think that this can be resolved in one of the following ways
Java's HashMap and HashSet implement strategy B.
https://github.com/openjdk/jdk/blob/d4474b5816c2ec8daaf1c905b77d8ba4e23c9439/src/java.base/share/classes/java/util/HashMap.java#L282
Beta Was this translation helpful? Give feedback.
All reactions