RFR: 8253179: Replace LinkedList Impl in net.http.Http2Connection [v2]

Conor Cleary ccleary at openjdk.java.net
Fri Oct 2 08:45:45 UTC 2020


On Fri, 2 Oct 2020 08:41:56 GMT, Conor Cleary <ccleary at openjdk.org> wrote:

>> This patch replaces a LinkedList data structure used in the net.http.Http2Connection class with an ArrayList. This
>> issue relates to [JDK-8246048: Replace LinkedList with ArrayLists in
>> java.net](https://bugs.openjdk.java.net/browse/JDK-8246048).  Some justifications for this change are as follows:
>> 
>> - Sequential Access Times for ArrayLists are improved due to locality of reference (i.e ArrayList elements stored in same
>>   memory neighborhood)
>> - Get(index) operations are O(1) time complexity for ArrayLists as opposed to worst-case O(N-1) for LinkedLists
>> - While insertion operations can be expensive (O(N) in the worst case), these operations appear to be
>>   infrequent/non-existent in this case.
>> 
>> Additional justifications or challenges to those listed are welcome! The general idea is that ArrayLists out-perform
>> LinkedLists in this scenario.
>
> Conor Cleary has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8253179: Removed ArrayList copy of streams

src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java line 704:

> 702:         client2.deleteConnection(this);
> 703:         for (Stream<?> s : streams.values()) {
> 704:             try {

To address some of the feedback given, the streams  are now directly addressed instead of making a copy.  ConcurrentMap
has also been used to initialise streams instead of Map. Seeking feedback/opinions on this if possible

-------------

PR: https://git.openjdk.java.net/jdk/pull/431


More information about the net-dev mailing list