Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Mar 12, 2020

Part of the effort enabling thread merging.

This is the implementation based on offline discussion with @iskakaushik and @flar, and an update from #9652.

The summary of the discussion can be concluded as following:
When changing thread configuration, we cancel the current frame and hope to resubmit the same layer tree in the next frame. (We will call the frame to be resubmitted "resubmitting frame below") If at the moment when we resubmit, there has already been a new frame inserted into the queue, we drop resubmitting frame, because the new frame in the queue is newer than the resubmitting frame.
For a detailed discussion including all the options we have explored: go/flutter-pipeline-for-thread-merging

Above is a short term solution to handle thread merging under current pipeline structure.

In long term, we want to update the pipeline structure completely, which would make pipeline handling on thread merging much simpler.

related issue: flutter/flutter#23975

@auto-assign auto-assign bot requested a review from GaryQian March 12, 2020 22:53
@cyanglaz cyanglaz requested review from iskakaushik and removed request for GaryQian March 12, 2020 22:53
@cyanglaz cyanglaz requested a review from flar March 12, 2020 22:53
@cyanglaz cyanglaz assigned amirh and unassigned amirh Mar 12, 2020
@cyanglaz cyanglaz requested a review from amirh March 12, 2020 22:53
Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

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

Also, would like to see input from @chinmaygarde

front_continuation.Complete(std::move(resubmitted_layer_tree_));
if (result) {
consume_result = PipelineConsumeResult::MoreAvailable;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me that if Complete returns false here, then there must be something in the queue, so the call to Complete just above this (line 126?) would probably have already returned MoreAvailable anyway? Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, you are right! Reverting.

@flar flar requested a review from chinmaygarde March 13, 2020 21:59
@chinmaygarde
Copy link
Member

This is the implementation based on offline discussion with @iskakaushik and @flar

Can you provide a short summary for folks not in that discussion? I feel like I am missing some context here. Just updating the commit description is fine.

In long term, we want to update the pipeline structure completely, which would make pipeline handling on thread merging much simpler.

Highly in favor of this. The initial implementation was geared towards a set of requirements that have evolved quite a bit and this structure is not longer well suited to solving the same.

@cyanglaz
Copy link
Contributor Author

Can you provide a short summary for folks not in that discussion? I feel like I am missing some context here. Just updating the commit description is fine.

Sure! I have updated the description of the PR. Please let me know if there are still things missing :)

Copy link
Contributor

@iskakaushik iskakaushik left a comment

Choose a reason for hiding this comment

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

LGTM modulo requests for doc improvements and a nit about test name.

// used to en-queue high-priority resources.
ProducerContinuation ProduceToFront() {
// Create a `ProducerContinuation` that will only push the task if the queue
// is empty.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be useful to add a brief description for the recommended usage of this method. Something along the lines of:

Prefer using Produce. ProducerContinuation returned by this method doesn't  guarantee that the frame will be rendered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

TEST(PipelineTest, PushingToFrontOverridesOrder) {
TEST(PipelineTest, ProduceIfEmptyWhenQueueIsNotEmptyDoesNotConsume) {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename test to ProduceIfEmptyDoesNotConsumeWhenQueueIsNotEmpty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

while (queue_.size() > depth_) {
queue_.pop_back();
if (!queue_.empty()) {
empty_.Signal();
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a note here describing why this semaphore needs to be signaled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

@iskakaushik Updated based on your comments!

// used to en-queue high-priority resources.
ProducerContinuation ProduceToFront() {
// Create a `ProducerContinuation` that will only push the task if the queue
// is empty.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

while (queue_.size() > depth_) {
queue_.pop_back();
if (!queue_.empty()) {
empty_.Signal();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

TEST(PipelineTest, PushingToFrontOverridesOrder) {
TEST(PipelineTest, ProduceIfEmptyWhenQueueIsNotEmptyDoesNotConsume) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@iskakaushik iskakaushik left a comment

Choose a reason for hiding this comment

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

LGTM

@cyanglaz cyanglaz merged commit 2d42c74 into flutter:master Mar 20, 2020
@cyanglaz cyanglaz deleted the pipeline_produce_to_front_if_empty branch March 20, 2020 18:05
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 20, 2020
fluttergithubbot pushed a commit to flutter/flutter that referenced this pull request Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants