Optimize partitioned exchange for RowType channels#12762
Optimize partitioned exchange for RowType channels#12762raunaqmorarka merged 1 commit intotrinodb:masterfrom
Conversation
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
e879b19 to
4c17996
Compare
lukasz-stec
left a comment
There was a problem hiding this comment.
comments answered, addressed.
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/BatchRowWriter.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
4c17996 to
391e6f2
Compare
lukasz-stec
left a comment
There was a problem hiding this comment.
comments addressed
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Is it possible that the fieldBlocks coming out of RowBlock is a LazyBlock ? Not sure if PositionsAppender deals with those
There was a problem hiding this comment.
I don't think it's possible. fieldBlocks are loaded when the block is loaded via getLoadedBlock and the PartitionedOutputOperator is configured with the PageChannelSelector page pre processor
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/operator/output/TestPositionsAppender.java
Outdated
Show resolved
Hide resolved
391e6f2 to
ec1f450
Compare
lukasz-stec
left a comment
There was a problem hiding this comment.
comments addressed
There was a problem hiding this comment.
I don't think it's possible. fieldBlocks are loaded when the block is loaded via getLoadedBlock and the PartitionedOutputOperator is configured with the PageChannelSelector page pre processor
core/trino-main/src/test/java/io/trino/operator/output/TestPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
ec1f450 to
f0d4efd
Compare
lukasz-stec
left a comment
There was a problem hiding this comment.
added AbstractRowBlock#copyPositions branchless commit
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
4649750 to
75da2d9
Compare
|
AbstractRowBlock#copyPositions branchless impl fixed |
raunaqmorarka
left a comment
There was a problem hiding this comment.
Could you extract 2nd commit as a separate PR ? I think we can land that immediately.
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
75da2d9 to
f0d4efd
Compare
lukasz-stec
left a comment
There was a problem hiding this comment.
branchless copyPositions extracted to. #12926 + comment
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
f0d4efd to
161ac2a
Compare
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
161ac2a to
5f06583
Compare
|
comments addressed + commit message extended with the SPI change justification. |
core/trino-spi/src/main/java/io/trino/spi/block/AbstractRowBlock.java
Outdated
Show resolved
Hide resolved
5f06583 to
1885335
Compare
core/trino-main/src/main/java/io/trino/operator/output/RowPositionsAppender.java
Outdated
Show resolved
Hide resolved
1885335 to
42b0bab
Compare
|
@lukasz-stec please rebase to latest master |
Introduced batch oriented RowPositionsAppender. As RowBlock's field blocks are public via getChildren method and field offset can be calculated, albeit slowly, using Block#isNull, the AbstractRowBlock#getFieldBlockOffset is made public to give access to pre-calculated offsets. Before Benchmark (channelCount) (enableCompression) (nullRate) (partitionCount) (positionCount) (type) Mode Cnt Score Error Units BenchmarkPartitionedOutputOperator.addPage 1 false 0 16 8192 ROW_BIGINT_BIGINT avgt 20 687.344 ± 55.380 ms/op BenchmarkPartitionedOutputOperator.addPage 1 false 0 16 8192 ROW_RLE_BIGINT_BIGINT avgt 20 583.781 ± 69.803 ms/op BenchmarkPartitionedOutputOperator.addPage 1 false 0.2 16 8192 ROW_BIGINT_BIGINT avgt 20 426.873 ± 11.070 ms/op BenchmarkPartitionedOutputOperator.addPage 1 false 0.2 16 8192 ROW_RLE_BIGINT_BIGINT avgt 20 486.288 ± 69.490 ms/op After BenchmarkPartitionedOutputOperator.addPage 1 false 0 16 8192 ROW_BIGINT_BIGINT avgt 20 148.079 ± 14.656 ms/op BenchmarkPartitionedOutputOperator.addPage 1 false 0 16 8192 ROW_RLE_BIGINT_BIGINT avgt 20 102.773 ± 6.502 ms/op BenchmarkPartitionedOutputOperator.addPage 1 false 0.2 16 8192 ROW_BIGINT_BIGINT avgt 20 196.848 ± 6.971 ms/op BenchmarkPartitionedOutputOperator.addPage 1 false 0.2 16 8192 ROW_RLE_BIGINT_BIGINT avgt 20 159.385 ± 10.308 ms/op
42b0bab to
1a0325b
Compare
Optimize partitioned exchange for RowType channels
with batch oriented RowPositionsAppender
Description
performance improvement
core query engine and spi
Benchmarks
tpch/tpcds orc sf1000 partitioned
There is a slight (1.5%) CPU improvement. This is expected as

PartitindOutputOperatoris about 5% of the overall CPU.poo-row-type-sf1000-orc-part.pdf
jmh
There is 2x to 4x improvement.
before
after
This also brings big improvements for queries with a large number of aggregations that use
RowTypeas an intermediate state e.g.sum.This sample query sees about a 30% improvement.
before
after
Documentation
(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
( X) Release notes entries required with the following suggested text: