New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8253179: Replace LinkedList Impl in net.http.Http2Connection #431
Conversation
|
@ccleary-oracle The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
@@ -700,7 +700,7 @@ void shutdown(Throwable t) { | |||
Throwable initialCause = this.cause; | |||
if (initialCause == null) this.cause = t; | |||
client2.deleteConnection(this); | |||
List<Stream<?>> c = new LinkedList<>(streams.values()); | |||
List<Stream<?>> c = new ArrayList<>(streams.values()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we dispense with this copy completely, and instead just iterate streams.values()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point Aleksey. I guess that the original intent was to avoid ConcurrentModificationException
. However I see that streams
is a ConcurrentHashMap
now. So maybe we could dispense of the copy:
private final Map<Integer,Stream<?>> streams = new ConcurrentHashMap<>();
Could be worth changing the type from Map<Integer,Stream<?>>
to ConcurrentMap<Integer,Stream<?>>
in the declaration above if we decide to get rid of the copy though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking a look at this presently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although Aleksey's proposal does not change the behavior, it raises a question (to be explored separately): can a stream be added to that map while Http2Connection.shutdown
is in progress? If this is the case, then the method is racy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if that happened , it should not matter as the connection will be (or is) closed anyway. I don't believe that's the kind of scenario that the copy was trying to prevent. Closing a stream will definitely remove it from the map though, so my guess that is where the CME would happen if no precaution was taken.
@@ -700,8 +700,7 @@ void shutdown(Throwable t) { | |||
Throwable initialCause = this.cause; | |||
if (initialCause == null) this.cause = t; | |||
client2.deleteConnection(this); | |||
List<Stream<?>> c = new ArrayList<>(streams.values()); | |||
for (Stream<?> s : c) { | |||
for (Stream<?> s : streams.values()) { | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@ccleary-oracle This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 80 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dfuch, @pavelrappo, @ChrisHegarty, @shipilev) but any other Committer may sponsor as well.
|
/integrate |
@ccleary-oracle |
I can sponsor this, but it is not clear what testing was done on this. At least |
|
/sponsor |
@shipilev @ccleary-oracle Since your change was applied there have been 86 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 703b345. |
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.
Some justifications for this change are as follows:
Additional justifications or challenges to those listed are welcome! The general idea is that ArrayLists out-perform LinkedLists in this scenario.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/431/head:pull/431
$ git checkout pull/431