Skip to content

[GLUTEN-10770][VL] Improve std::vector usage in toVeloxPlan#10771

Merged
philo-he merged 1 commit intoapache:mainfrom
beliefer:10770
Sep 24, 2025
Merged

[GLUTEN-10770][VL] Improve std::vector usage in toVeloxPlan#10771
philo-he merged 1 commit intoapache:mainfrom
beliefer:10770

Conversation

@beliefer
Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

This PR propose to improve perf for toVeloxPlan with ProjectRel.
Fixes #10770

How was this patch tested?

GA tests.

@github-actions github-actions Bot added the VELOX label Sep 22, 2025
@github-actions
Copy link
Copy Markdown

#10770

@beliefer
Copy link
Copy Markdown
Contributor Author

Comment on lines +491 to +499
std::vector<std::string> emitProjectNames;
std::vector<core::TypedExprPtr> emitExpressions;
emitProjectNames.reserve(emitSize);
emitExpressions.reserve(emitSize);

for (int i = 0; i < emitSize; i++) {
int32_t mapId = emit.output_mapping(i);
emitProjectNames[i] = projectNames[mapId];
emitExpressions[i] = expressions[mapId];
emitProjectNames.emplace_back(std::move(projectNames[mapId]));
emitExpressions.emplace_back(std::move(expressions[mapId]));
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.

Curious, does the new code improve performance in real workloads?

These changes themselves feel reasonable to me though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

First, below two lines create default obj.

std::vector<std::string> emitProjectNames(emitSize);
std::vector<core::TypedExprPtr> emitExpressions(emitSize);

We should avoid the behavior.
Second, std::move could avoid copy obj.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TBH, I'm new to C++. But I got these information after I learned.

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.

Yes, in that case let's rephrase the PR title / description as code cleanup rather than improve perf. It feels this code is not on hot path so let's be conservative until the performance improvement is actually proved.

Copy link
Copy Markdown
Contributor Author

@beliefer beliefer Sep 23, 2025

Choose a reason for hiding this comment

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

Got it. The title updated.

@beliefer beliefer changed the title [GLUTEN-10770] Improve perf for toVeloxPlan with ProjectRel [GLUTEN-10770] Code cleanup for toVeloxPlan with ProjectRel Sep 23, 2025
Copy link
Copy Markdown
Member

@philo-he philo-he left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks.

@philo-he philo-he changed the title [GLUTEN-10770] Code cleanup for toVeloxPlan with ProjectRel [GLUTEN-10770] Improve std::vector usage in toVeloxPlan Sep 24, 2025
@philo-he philo-he changed the title [GLUTEN-10770] Improve std::vector usage in toVeloxPlan [GLUTEN-10770][VL] Improve std::vector usage in toVeloxPlan Sep 24, 2025
@philo-he philo-he merged commit 647c606 into apache:main Sep 24, 2025
100 of 102 checks passed
@beliefer
Copy link
Copy Markdown
Contributor Author

@philo-he @zhztheplayer Thank you all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code cleanup for toVeloxPlan with ProjectRel

3 participants