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

Avoid extra allocation in OrderByOperator#getOutput() #16447

Merged
merged 1 commit into from
Mar 17, 2023

Conversation

pettyjamesm
Copy link
Member

Description

Changes OrderByOperator#getOutput() to use Page#getColumns(outputChannels) instead of building an array of output blocks itself, which avoids an extra allocation.

Release notes

(x) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text:

@cla-bot cla-bot bot added the cla-signed label Mar 8, 2023
blocks[i] = nextPage.getBlock(outputChannels[i]);
}
return new Page(nextPage.getPositionCount(), blocks);
return nextPage.getColumns(outputChannels);
Copy link
Member

Choose a reason for hiding this comment

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

getColumns() calls wrapBlocksWithoutCopy(positionCount, blocks), while new Page(count, blocks) uses blocksCopyRequired = true. Have you analyzed the impact of that change in semantics?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, that's the intention behind this change. The Block[] array in the previous implementation was created locally (not shared anywhere else) but was created once and then immediately cloned by the page constructor unnecessarily. Now we only create a single copy of the blocks array inside of Page#getColumns which requires no additional copy (and makes the code a little cleaner).

@pettyjamesm
Copy link
Member Author

@martint - ping for review / merge

@martint martint merged commit 52f3d4f into trinodb:master Mar 17, 2023
@github-actions github-actions bot added this to the 411 milestone Mar 17, 2023
@pettyjamesm pettyjamesm deleted the cleanup-orderby-operator-output branch March 17, 2023 21:05
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.

2 participants