Skip to content
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

8289572: InputStream wrapping with BufferedInputStream is redundant in HttpTimestamper #9343

Closed
wants to merge 1 commit into from

Conversation

stsypanov
Copy link
Contributor

@stsypanov stsypanov commented Jul 1, 2022

In case we read all bytes from an InputStream we don't need wrapping with BufferedInputStream as the bytes are not written into internal buffer. With removal of redundant buffer we save 8 kB of allocated memory.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8289572: InputStream wrapping with BufferedInputStream is redundant in HttpTimestamper

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9343/head:pull/9343
$ git checkout pull/9343

Update a local copy of the PR:
$ git checkout pull/9343
$ git pull https://git.openjdk.org/jdk pull/9343/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9343

View PR using the GUI difftool:
$ git pr show -t 9343

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9343.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 1, 2022

👋 Welcome back stsypanov! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jul 1, 2022

@stsypanov The following label will be automatically applied to this pull request:

  • security

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.

@openjdk openjdk bot added the security security-dev@openjdk.org label Jul 1, 2022
@stsypanov stsypanov changed the title InputStream wrapping with BufferedInputStream is redundant in HttpTimestamper 8289572: InputStream wrapping with BufferedInputStream is redundant in HttpTimestamper Jul 1, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 1, 2022
@mlbridge
Copy link

mlbridge bot commented Jul 1, 2022

Webrevs

@dfuch
Copy link
Member

dfuch commented Jul 1, 2022

In case we read all bytes from an InputStream we don't need wrapping with BufferedInputStream as the bytes are not written into internal buffer. With removal of redundant buffer we save 8 kB of allocated memory.

I believe that in that case the bytes might get double buffered, depending on whether the buffer used by readAllBytes is bigger than the buffer used by BufferedInputStream, since IIAMNM readAllBytes() will call read(byte[], off, len) - but I otherwise agree that regardless of that wrapping in a BufferedInputStream is always wasteful in this case. Good find!

@stsypanov
Copy link
Contributor Author

@dfuch as of current implementation of InputStream.readNBytes() it relies on InputStream.DEFAULT_BUFFER_SIZE which is 8192 and equals to DEFAULT_BUFFER_SIZE in BufferedInputStream.

Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, but please wait for someone from the security team to review this, before merging.

@openjdk
Copy link

openjdk bot commented Jul 5, 2022

⚠️ @stsypanov the full name on your profile does not match the author name in this pull requests' HEAD commit. If this pull request gets integrated then the author name from this pull requests' HEAD commit will be used for the resulting commit. If you wish to push a new commit with a different author name, then please run the following commands in a local repository of your personal fork:

$ git checkout 8289572
$ git commit --author='Preferred Full Name <you@example.com>' --allow-empty -m 'Update full name'
$ git push

@openjdk
Copy link

openjdk bot commented Jul 5, 2022

@stsypanov This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8289572: InputStream wrapping with BufferedInputStream is redundant in HttpTimestamper

Reviewed-by: jpai, mullan

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 188 new commits pushed to the master branch:

  • 3ad3950: Merge
  • fd89ab8: 8288112: C2: Error: ShouldNotReachHere() in Type::typerr()
  • 2bf6285: 8290209: jcup.md missing additional text
  • 73b83e0: 8290207: Missing notice in dom.md
  • 3bb2dc8: 8290290: Remove addition of TimeInstants
  • c7c2066: 8290221: G1: Merge multiple calls of get_next_marked_addr in HeapRegion::oops_on_memregion_iterate_in_unparsable
  • be58cbc: 8290269: gc/shenandoah/TestVerifyJCStress.java fails due to invalid tag: required after JDK-8290023
  • 109e21a: 8290080: G1: Remove unnecessary is-obj-dead check in HeapRegion::do_oops_on_memregion_in_humongous
  • adf40d2: 8290149: java/nio/file/Files/probeContentType/Basic.java fails on Windows Server 2019/2022
  • 292d909: 8290178: failure_handler: run netstat without name lookups
  • ... and 178 more: https://git.openjdk.org/jdk/compare/d260a4e794681c6f4be4767350702754cfc2035c...master

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 (@jaikiran, @seanjmullan) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 5, 2022
@stsypanov
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jul 14, 2022
@openjdk
Copy link

openjdk bot commented Jul 14, 2022

@stsypanov
Your change (at version 80b141b) is now ready to be sponsored by a Committer.

@seanjmullan
Copy link
Member

seanjmullan commented Jul 14, 2022

This is in security-libs code, so the JBS issue component should be "security-libs". The subcomponent should probably be "java.security". It should also have an appropriate noreg label, as there is no regression test.

@stsypanov
Copy link
Contributor Author

@seanjmullan done

@jaikiran
Copy link
Member

I see that Sean has approved this PR. I'll run some tests internally with this change and if it goes fine, then I'll go ahead and sponsor this today.

@jaikiran
Copy link
Member

The tests completed without any related issues.

@jaikiran
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Jul 22, 2022

Going to push as commit 75c1e99.
Since your change was applied there have been 298 commits pushed to the master branch:

  • 7841e5c: 8290464: Optimize ResourceArea zapping on ResourceMark release
  • e9f97b2: 8290489: Initial nroff manpage generation for JDK 20
  • 59d85ba: 8290687: serviceability/sa/TestClassDump.java could leave files owned by root on macOS
  • 66f59c2: 8290731: Clean up CDS handling of LambdaForm Species classes
  • 0dda3c1: 8289275: Remove incorrect __declspec(dllimport) attributes from pointers in jdk.crypto.cryptoki
  • 620c8a0: 8289643: File descriptor leak with ProcessBuilder.startPipeline
  • 7ec0132: 8286844: com/sun/jdi/RedefineCrossEvent.java failed with 1 threads completed while VM suspended
  • 80bd8c3: 8290504: Close streams returned by ModuleReader::list
  • 15f4b30: 8290115: ArrayCopyObject JMH has wrong package
  • 4c1cd66: 8288368: simplify code in ValueTaglet, remove redundant code
  • ... and 288 more: https://git.openjdk.org/jdk/compare/d260a4e794681c6f4be4767350702754cfc2035c...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 22, 2022
@openjdk openjdk bot closed this Jul 22, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Jul 22, 2022
@openjdk
Copy link

openjdk bot commented Jul 22, 2022

@jaikiran @stsypanov Pushed as commit 75c1e99.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@stsypanov stsypanov deleted the 8289572 branch July 22, 2022 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated security security-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

4 participants