Skip to content

Avoid extra allocation in OrderByOperator#getOutput()#16447

Merged
martint merged 1 commit intotrinodb:masterfrom
pettyjamesm:cleanup-orderby-operator-output
Mar 17, 2023
Merged

Avoid extra allocation in OrderByOperator#getOutput()#16447
martint merged 1 commit intotrinodb:masterfrom
pettyjamesm:cleanup-orderby-operator-output

Conversation

@pettyjamesm
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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