NIOFileHandle: don't read from the file to fill a trash buffer #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The writeSetup method in NIOFileHandle ensures that the buffer used for speeding up reads is aligned sanely with any write that we're going to do, so that we can also use it as a write-through cache. In the process, it may resize the buffer and read into it from the file on disk. However, the write method taking a ByteBuffer immediately throws away that read buffer, so resizing it and filling it is simply a waste of time.
This work was motivated by the desire to speed up image format conversions for image files in excess of 50GB. In conjunction with additional changes in bioformats and ome-codecs, I have achieved a geometric to linear time asymptotic improvement, plus another ~30% speed improvement of just the linear time cost. The patch for ome-codecs has already been submitted, and the patches for bioformats will be forthcoming in the next few days.