Details
-
Bug
-
Resolution: Fixed
-
P3
-
None
Description
The static List, Set and Map factories added in 9 strike a balance between reducing footprint (by providing specialized implementations for small number of entries) and speed (using @Stable guarantees enables a JIT to constant fold). However, the number of implementation classes can have negative effects:
- Callsites may become bi- or megamorphic that would be monomorphic if it only observed a single implementation, e.g., ArrayList.
- Although trivially JITed, splitting work over 4 List implementation delays how quicky individual implementations reach optimal compilation levels, which can affect startup and warmup (observed afterJDK-8184777)
As such, this is part Enhancement, part Bug (observable regressions when using List.of() compared to arrays or ArrayList)
Experiments show we can profitably reduce the number of implementation classes to 2 while remaining footprint neutral.
We could also provide an option to only have one implementation, forfeiting the footprint gain to ensure monomorphic callsites.
- Callsites may become bi- or megamorphic that would be monomorphic if it only observed a single implementation, e.g., ArrayList.
- Although trivially JITed, splitting work over 4 List implementation delays how quicky individual implementations reach optimal compilation levels, which can affect startup and warmup (observed after
As such, this is part Enhancement, part Bug (observable regressions when using List.of() compared to arrays or ArrayList)
Experiments show we can profitably reduce the number of implementation classes to 2 while remaining footprint neutral.
We could also provide an option to only have one implementation, forfeiting the footprint gain to ensure monomorphic callsites.
Attachments
Issue Links
- relates to
-
JDK-8203184 List.copyOf() fails to copy sublists
-
- Closed
-
-
JDK-8184777 Factor out species generation logic from BoundMethodHandle
-
- Resolved
-