Skip to content

Conversation

amcrn
Copy link

@amcrn amcrn commented Nov 6, 2017

Problem: If an empty ArrayList has addAll() invoked with a Collection
argument that has a size less than 10, the underlying elementData
Object[] is still grown to 10 via an Array copy. In the case of
AbstractListenableFuture, the number of listeners is often 0 or 1,
and AbstractListenableFuture is in the critical path, meaning this
behavior causes unnecessary GC pressure for high throughput
applications.

Therefore, this commit enhances the logic to avoid the construction
of the listener copy ArrayList and its iterator if possible, and if
not, to use the more efficient constructor vs. addAll().

Problem: If an empty ArrayList has addAll() invoked with a Collection
argument that has a size less than 10, the underlying elementData
Object[] is still grown to 10 via an Array copy. In the case of
AbstractListenableFuture, the number of listeners is often 0 or 1,
and AbstractListenableFuture is in the critical path, meaning this
behavior causes unnecessary GC pressure for high throughput
applications.

Therefore, this commit enhances the logic to avoid the construction
of the listener copy ArrayList and its iterator if possible, and if
not, to use the more efficient constructor vs. addAll().
@ingenthr ingenthr self-assigned this Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants