GH-3226: Improve performance of InternalParquetRecordReader (1%) #3227
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.
Avoid LongStream reading files and use an ad-hoc Long Iterator
Rationale for this change
Profiling the load of a Parquet file with Java Mission Control, I've noticed that InternalParquetRecordReader LongStream consumes relevant amount of time:
This LongStream can be replaced with a simpler Long Iterator that iterates from 0 to pages.getRowCount().
To measure the overhead I've created a test project that overwrites
InternalParquetRecordReader
class using a Long Iterator (the same change than proposed in the PR)The execution time is sensitive to the context of the JVM, but running the benchmark multiple times shows that LongStream is slower than LongIterator, between 1% and 4% depending on the run.
What changes are included in this PR?
A new
LongIterator
that implementsPrimitiveIterator.OfLong
and replaces aLongStream.range(0, pages.getRowCount()).iterator()
Are these changes tested?
Not directly, but it's covered by existing tests
Are there any user-facing changes?
No
Closes #3226