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

Reduce the number of individual InputStream#read calls by reading in batches. #21

Merged
merged 1 commit into from
Feb 26, 2018

Conversation

nirvdrum
Copy link
Contributor

Individual reads from ZipFileInputStream, as would be encountered when reading a resource from a JAR, can be very inefficient. They allocate a single-byte array and require unzipping the source file for each read (at least in OpenJDK 8).

@headius
Copy link
Member

headius commented Feb 26, 2018

As mentioned on IRC, I would like to see if a simple BufferedInputStream has the same impact, since it would be simpler code and would not need to read the zipped content entirely into memory.

…-byte reads.

Individual reads from ZipFileInputStream, as would be encountered when reading a resource from a JAR, can be very inefficient. They allocate a single-byte array and require unzipping the source file for each read (at least in OpenJDK 8).
@nirvdrum nirvdrum force-pushed the more-efficient-array-reader branch from 623a1f4 to 437dfb3 Compare February 26, 2018 19:48
@nirvdrum
Copy link
Contributor Author

BufferedInputStream might be a tad slower because it will end up opening the JAR file multiple times, but I think it borders on inconsequential. I've updated the PR to use it since it's much clearer.

@headius headius merged commit 9f28476 into jruby:master Feb 26, 2018
@nirvdrum nirvdrum deleted the more-efficient-array-reader branch February 26, 2018 19:56
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.

None yet

2 participants