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

Close its source exchanges once a stage finishes execution #16446

Merged
merged 1 commit into from
Mar 15, 2023

Conversation

linzebing
Copy link
Member

Description

For fault-tolerant execution, today we only clean up the spooling files at the end of a query. Actually we can clean up earlier --- once we are sure that the data won't be read again, then we can delete.

Additional context and related issues

N/A

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:

# Section
* Fix some things. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label Mar 8, 2023
@linzebing linzebing requested review from arhimondr and losipiuk March 8, 2023 19:19
@linzebing
Copy link
Member Author

Through testing, this PR decreased CPU time and wall time by around 3.2%-3.4% for tpch-sf10000 standard suite (22 queries), concurrency = 5 on a cluster of 7 workers and 7 buffer data nodes.

createStageExecution(subPlan, fragmentId.equals(rootFragmentId), nextSchedulingPriority++);
}
if (stageExecution != null && stageExecution.getState().equals(StageState.FINISHED) && !stageExecution.isClosed()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Do we need to check !stageExecution.isClosed() here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's a pruning, so we don't call abort on the same stage for multiple times.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is what confuses me a little. You are checking the parent stage, but closing child stages. So you still may end up closing child stages several times until the parent stage itself is closed. Given the close is cheap (as you are checking if it's already closed) i wonder if it is worth extra complexity? (as it doesn't protect from close being called more than once but may create such an impression)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd say closeSourceExchanges is not super cheap as it involves a loop which involves getStageId as well as a hashset lookup. Ideally we want to prune if possible.

@linzebing linzebing force-pushed the close-exchange-asap branch from 58ab4d9 to 7c7a079 Compare March 14, 2023 19:33
@linzebing linzebing changed the title Close and clean up its children stage executions once a stage finishes execution Close its source exchanges once a stage finishes execution Mar 14, 2023
@linzebing
Copy link
Member Author

Failure is unrelated

@arhimondr arhimondr merged commit 20f2d44 into trinodb:master Mar 15, 2023
@github-actions github-actions bot added this to the 411 milestone Mar 15, 2023
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