-
Notifications
You must be signed in to change notification settings - Fork 6k
TaskSources register tasks with MessageLoopTaskQueues dispatcher #25307
TaskSources register tasks with MessageLoopTaskQueues dispatcher #25307
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
ed21997 to
c74d60b
Compare
|
@chinmaygarde this PR is mostly ready, I still need to write tests for this, wanted to get your take on this before I go ahead with it. |
c74d60b to
934a678
Compare
237f4a9 to
6e07478
Compare
chinmaygarde
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is extremely compelling stuff. I did an initial pass over the interface with some suggestions for your consideration. Looking at the implementation in detail now. Thanks!
fml/task_source.h
Outdated
|
|
||
| void Clear(); | ||
|
|
||
| void RegisterTask(TaskSourceGrade grade, DelayedTask&& task); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can DelayedTask have its copy ctor disabled? We can then remove the && and ensure that it is impossible to have unnecessary copies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried doing this, looks like using a priority queue without a copy constructor is non-trivial. Will attempt doing this in a future PR.
chinmaygarde
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so awesome.
| switch (task.GetTaskSourceGrade()) { | ||
| case TaskSourceGrade::kUserInteraction: | ||
| primary_task_queue_.push(task); | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Here and later, you can use [[fallthrough]] if the compiler troubles you about the missing break. You call though.
DartHandle messages will be held
1. Add tests for TaskSource 2. Add docs for TaskSource 3. Get existing failing tests to pass
2dd11ca to
f49ec77
Compare
f49ec77 to
7795d8d
Compare
|
@chinmaygarde I've noticed a couple of assumptions in the profiler initialization code that prevents us from pausing the micro task queue on vsync start. We have to do it after the first frame renders. I'm landing the changes to the task management as done in this PR. I will address these issues (in a much smaller patch) in a follow-up PR. |
SGTM. |
This is because tests don't really wait for vsync to complete Fixes: flutter/flutter#69694 See: flutter#25307 (comment)
This is because tests don't really wait for vsync to complete Fixes: flutter/flutter#69694 See: flutter#25307 (comment)
|
Does this also close flutter/flutter#69694? |
This is because tests don't really wait for vsync to complete Fixes: flutter/flutter#69694 See: flutter#25307 (comment)
This is because tests don't really wait for vsync to complete Fixes: flutter/flutter#69694 See: flutter#25307 (comment)
This is because tests don't really wait for vsync to complete Fixes: flutter/flutter#69694 See: flutter#25307 (comment)
This is because tests don't really wait for vsync to complete Fixes: flutter/flutter#69694 See: flutter#25307 (comment)
…her (flutter#25307)" This reverts commit f2f09b6.
…her (flutter#25307)" This reverts commit f2f09b6.
Task Source
Introduces a notion of a
TaskSource.TaskSourceprovides the task dispatcher (MessageLoopTaskQueues) an abstraction to obtain the next task to run.TaskSources as implemented in the PR have two managed task heaps.kPrimaryandkSecondarytask heaps. When registering a task with the task dispatcher, we provide a way to specify whether the task is for thekPrimiaryorkSecondarytask heap. Secondary heaps can be paused and resumed.Usage
HandleMessagecalls on a dart isolate are also serviced by the secondary heap of the UI thread's task source.This makes it so that all non-frame build related events on the UI threads are paused on vsync and we re enable them only when the frame gets built. See: go/flutter-engine-task-prioritization.
Benchmarks
lands the framework to address: flutter/flutter#69694