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

Optimize null checking in DictionaryBlock #10264

Merged
merged 1 commit into from
Feb 25, 2022

Conversation

skrzypo987
Copy link
Member

No description provided.

@@ -445,14 +445,17 @@ public Block copyRegion(int position, int length)
@Override
public boolean mayHaveNull()
{
return positionCount > 0 && dictionary.mayHaveNull();
return mayHaveNull;
Copy link
Member

Choose a reason for hiding this comment

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

Would this result in lazily loaded non-null Dictionary never getting advantage of mayHaveNull ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Check it out now? There is a fast path for mayHaveNull == false and slower one for true.
&& is a condition but branch prediction should take care of that

@skrzypo987 skrzypo987 force-pushed the skrzypo/044-dictionary-nulls branch from d4f1fe2 to 1549e6f Compare December 10, 2021 10:20
Copy link
Member

@sopel39 sopel39 left a comment

Choose a reason for hiding this comment

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

small comment

@skrzypo987 skrzypo987 force-pushed the skrzypo/044-dictionary-nulls branch from 1549e6f to eca838a Compare January 19, 2022 08:54
@skrzypo987 skrzypo987 added the WIP label Jan 19, 2022
@skrzypo987 skrzypo987 force-pushed the skrzypo/044-dictionary-nulls branch from 4d0b5f4 to 292b78d Compare January 20, 2022 07:16
@skrzypo987 skrzypo987 removed the WIP label Jan 24, 2022
@skrzypo987 skrzypo987 force-pushed the skrzypo/044-dictionary-nulls branch from 292b78d to 2430c80 Compare February 11, 2022 09:55
@skrzypo987
Copy link
Member Author

@sopel39 , @raunaqmorarka ready for another round. This time tests are passing.

@skrzypo987
Copy link
Member Author

Checked both failing tests locally and they pass

@skrzypo987
Copy link
Member Author

I run tpch/ds benchmarks. A steady ~0.9% gain in both wall time and cpu. No regressions

@@ -64,6 +65,7 @@ public RunLengthEncodedBlock(Block value, int positionCount)
}

this.positionCount = positionCount;
this.isNull = positionCount > 0 && value.isNull(0);
Copy link
Member

Choose a reason for hiding this comment

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

undo: this will cause lazy block to be loaded.
Maybe do something similar as with io.trino.spi.block.DictionaryBlock#DictionaryBlock(int, int, io.trino.spi.block.Block, int[], boolean, boolean, io.trino.spi.block.DictionaryId)?

Copy link
Member

Choose a reason for hiding this comment

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

Do we have a case where we create RunLengthEncodedBlock out of a LazyBlock ? So far I didn't see one.
We already asserted the block to contain single position. I'm not sure why we would want to create a LazyBlock out of a single valued Block.

Copy link
Member

Choose a reason for hiding this comment

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

Do we have a case where we create RunLengthEncodedBlock out of a LazyBlock ? So far I didn't see one.

It breaks contract (e.g. forces loading in constructor). You could imagine joining single position with multiple build rows.

@skrzypo987 skrzypo987 force-pushed the skrzypo/044-dictionary-nulls branch from 2430c80 to 8925aa2 Compare February 24, 2022 07:12
@skrzypo987
Copy link
Member Author

@sopel39 I reverted the RLE changes

@skrzypo987 skrzypo987 force-pushed the skrzypo/044-dictionary-nulls branch from 8925aa2 to 690eaec Compare February 25, 2022 11:48
@sopel39 sopel39 merged commit 3345adb into trinodb:master Feb 25, 2022
@github-actions github-actions bot added this to the 372 milestone Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants