-
Notifications
You must be signed in to change notification settings - Fork 6k
8265891: (ch) InputStream returned by Channels.newInputStream should override transferTo #4263
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
Conversation
Preventing transfer through the JVM heap by using NIO and potentially performing intra-OS transport to improve performance where possible. Signed-off-by: Markus Karg <markus@headcrashing.eu>
These days I/O devides, particularly SSDs, are much faster than in the days this original code was written. Due to that, the transfer time is less I/O bound. Performance can be increased significantly by spending 16x 8 KiB instead of the original 1x 8 KiB heap memory (approx. doubles performance, clearly depending on the used hardware). Signed-off-by: Markus Karg <markus@headcrashing.eu>
Hi @mkarg, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user mkarg" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
/signed |
Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
Signed-off-by: Markus Karg <markus@headcrashing.eu>
Signed-off-by: Markus Karg <markus@headcrashing.eu>
Signed-off-by: Markus Karg <markus@headcrashing.eu>
@AlanBateman I'm done with the changes you requested and kindly like to ask where to go from here. |
Moving ChannelOutputStream to sun.nio.ch looks right. The implementation of transferTo will need a few rounds of cleanup, it's a look very messy right now. You are over using var and is impossible for the reader to know what the types are. Pattern matching for instanceof can be used to avoid the casts. |
Great ideas, will do as you say, stay tuned! Didn't know that using |
Signed-off-by: Markus Karg <markus@headcrashing.eu>
Replaced |
Signed-off-by: Markus Karg <markus@headcrashing.eu>
Replaced casting by pattern matching for |
@AlanBateman Pushed the requested changes. More change requests? :-) |
src/java.base/share/classes/sun/nio/ch/ChannelOutputStream.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Markus Karg <markus@headcrashing.eu>
Signed-off-by: Markus Karg <markus@headcrashing.eu>
Agreed, I will split this PR into several PRs, so we can start with the low-hanging fruits first and later dive into the more complex cases. |
I have split up this PR so that only the lowest hanging fruit is covered and kindly request review: #5179. |
@mkarg This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Work on this draft will be continued as soon as depenency PRs are resolved. Please keep this issue open. |
@mkarg This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Please keep this PR open. More commits will follow on the next weeks. |
@mkarg This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Please keep this PR open. More commits will follow on the next weeks. |
Looks promising, keep moving, @mkarg ! |
@mkarg This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Please keep this PR open as I am working on several sub-issues currently. |
@mkarg This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Please keep this PR open. I am still working on it. |
@mkarg This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Please keep this PR open; I will continune work on it soon. |
@mkarg This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Please keep this PR open; I will continune work on it soon. |
@mkarg This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Please keep this PR open; I will continune work on it soon. |
@mkarg This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@mkarg This pull request has been inactive for more than 16 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
Hi @laeubi, thanks for making a comment in an OpenJDK project! All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user laeubi for the summary. If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.
Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use. |
@laeubi The performance was optimized by several PRs (works well for file based streams now), but there are still cases that could (possibly should) get optimized. These cases are still on my agenda. But before I continue with those cases, I focus on enabling that optimization (BufferedInputStream prevents the benefit in most cases, but #10525 will fix that, so I can step on soon). |
Hi @laeubi, thanks for making a comment in an OpenJDK project! All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user laeubi for the summary. If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.
Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use. |
This PR-draft is work in progress and an invitation to discuss a possible solution for issue JDK-8265891. It is not yet intended for a final review.
As proposed in JDK-8265891, this PR provides an implementation for
Channels.newInputStream().transferTo()
which provide superior performance compared to the current implementation. The changes are:Using JMH I have benchmarked both, the original implementation and this implementation, and (depending on the used hardware and use case) performance change was approx. doubled performance. So this PoC proofs that it makes sense to finalize this work and turn it into an actual OpenJDK contribution.
I encourage everybody to discuss this draft:
Channels.newInputStream().transferTo()
?Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4263/head:pull/4263
$ git checkout pull/4263
Update a local copy of the PR:
$ git checkout pull/4263
$ git pull https://git.openjdk.java.net/jdk pull/4263/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4263
View PR using the GUI difftool:
$ git pr show -t 4263
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4263.diff