Skip to content

Decrease a lock contention in PipelinedStageExecution#14395

Merged
sopel39 merged 2 commits intotrinodb:masterfrom
radek-kondziolka:rk/decrease_lock_contention_PipelinedStageExecution
Oct 10, 2022
Merged

Decrease a lock contention in PipelinedStageExecution#14395
sopel39 merged 2 commits intotrinodb:masterfrom
radek-kondziolka:rk/decrease_lock_contention_PipelinedStageExecution

Conversation

@radek-kondziolka
Copy link
Copy Markdown
Contributor

@radek-kondziolka radek-kondziolka commented Sep 30, 2022

Description

We observed that there is a high lock contention on io.trino.execution.scheduler.PipelinedStageExecution's monitor.
Lock contention before:

new_master

Lock contention after:

Screenshot 2022-09-30 at 11 53 50

We measured the throughput (80 trino workers, 40 r5.4xlarge nodes, 64 concurrent queries) before/after

Throughput (queries/h) before:
6000 queries / h

Throughput (queries/h) after:
6600 queries / h (10% difference)

Non-technical explanation

The Trino is able to process more queries within one hour.

Release notes

( ) This is not user-visible 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:
Increase throughput when running highly concurrent workloads on big Trino clusters

@cla-bot cla-bot bot added the cla-signed label Sep 30, 2022
@radek-kondziolka radek-kondziolka force-pushed the rk/decrease_lock_contention_PipelinedStageExecution branch 2 times, most recently from bf65968 to c42071b Compare September 30, 2022 08:43
@radek-kondziolka radek-kondziolka marked this pull request as ready for review September 30, 2022 10:00
@radek-kondziolka radek-kondziolka force-pushed the rk/decrease_lock_contention_PipelinedStageExecution branch from c42071b to 261f3ac Compare October 3, 2022 14:20
@sopel39 sopel39 requested a review from Dith3r October 3, 2022 15:10
@radek-kondziolka radek-kondziolka force-pushed the rk/decrease_lock_contention_PipelinedStageExecution branch from 261f3ac to 9510d8d Compare October 4, 2022 10:13
@radek-kondziolka radek-kondziolka force-pushed the rk/decrease_lock_contention_PipelinedStageExecution branch from 9510d8d to 46798c3 Compare October 5, 2022 07:09
Copy link
Copy Markdown
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.

lgtm % comments

@radek-kondziolka radek-kondziolka force-pushed the rk/decrease_lock_contention_PipelinedStageExecution branch 2 times, most recently from 2f4fde7 to a117151 Compare October 6, 2022 08:36
Copy link
Copy Markdown
Member

@Dith3r Dith3r left a comment

Choose a reason for hiding this comment

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

LGTM.

@radek-kondziolka radek-kondziolka force-pushed the rk/decrease_lock_contention_PipelinedStageExecution branch from a117151 to 1cba3c6 Compare October 6, 2022 10:24
@sopel39
Copy link
Copy Markdown
Member

sopel39 commented Oct 6, 2022

There are some test failures. Could you rerun?

@radek-kondziolka
Copy link
Copy Markdown
Contributor Author

There are some test failures. Could you rerun?

Yes, these failures are not relevant. I am going to rerun but before I want to see result of product tests. After that, I rerun.

@radek-kondziolka radek-kondziolka force-pushed the rk/decrease_lock_contention_PipelinedStageExecution branch 2 times, most recently from ed1a002 to 200a20c Compare October 7, 2022 12:31
@radek-kondziolka radek-kondziolka force-pushed the rk/decrease_lock_contention_PipelinedStageExecution branch 2 times, most recently from 36dbf6c to 64a8e46 Compare October 10, 2022 07:42
Taking a monitor of io.trino.execution.scheduler.PipelinedStageExection
in the updateTaskStatus method causes a high lock contention. Make this
method lock-less.
@radek-kondziolka radek-kondziolka force-pushed the rk/decrease_lock_contention_PipelinedStageExecution branch from 64a8e46 to 348ea11 Compare October 10, 2022 07:44
@sopel39 sopel39 merged commit 426e759 into trinodb:master Oct 10, 2022
@github-actions github-actions bot added this to the 400 milestone Oct 10, 2022
@sopel39 sopel39 mentioned this pull request Oct 10, 2022
if (isFlushing()) {
stateMachine.transitionToFlushing();
// avoid extra synchronization if no new flushing or finished task was observed
if (newFlushingOrFinishedTaskObserved) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The stageState is read before a task is added to the finishedTasks set. I think this breaks happens-before assumptions. It is possible that State stageState = stateMachine.getState(); is run when the state is not yet SCHEDULED so the stateMachine.transitionToFinished(); is not run while at the same time the schedulingComplete() transitions the stage to SCHEDULED but doesn't see all tasks being finished.

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.

Yup. You are correct.

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.

5 participants