Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Issue 2814843002: gpu: GPU service scheduler. (Closed)

Created:
3 years, 8 months ago by sunnyps
Modified:
3 years, 7 months ago
Reviewers:
sadrul, vmiura, dcheng, piman
CC:
chromium-reviews, rjkroege, mlamouri+watch-content_chromium.org, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, jam, yzshen+watch_chromium.org, abarth-chromium, jbauman+watch_chromium.org, Aaron Boodman, darin-cc_chromium.org, piman+watch_chromium.org, kalyank, danakj+watch_chromium.org, darin (slow to review)
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

gpu: GPU service scheduler. The GPU service scheduler runs tasks (closures) containing command buffer work. Tasks are enqueued in sequences which represent indepdent streams of execution. A task in one sequence may wait on a sync token fence that's released on another sequence. Tasks can specify their sync token fences beforehand so that the scheduler won't run a sequence only to disable it due to a sync token wait. Tasks can check if they should yield so that a higher priority task may run. If a task decides to yield, it can continue execution by supplying a new closure which will run before any other scheduled tasks in that sequence. The scheduler maintains a priority queue of sequences ordered by sequence priority and then order number. Priority inversion because of sync token dependencies is handled by a simple priority ceiling scheme. Sequences which are expected to release sync tokens dependencies are assigned a priority (HIGH) that's higher than any client specified priorities. However, browser view context sequences can have an even higher priority (REAL_TIME). GPU channel IPC messages are run as tasks in the scheduler. Each client side stream is mapped to a sequence. The client is expected to use a small number of streams to partition its command buffers so there is no tracking of stream lifetimes in the service. The message filter posts messages as tasks. AsyncFlush is the only message for which sync token dependencies are given to the scheduler. The initial implementation uses the GPU main thread to run scheduled tasks. Future implementations, for example, could use a worker pool with task traits to specify which thread a task should run on. R=piman@chromium.org BUG=514813 CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Review-Url: https://codereview.chromium.org/2814843002 Cr-Commit-Position: refs/heads/master@{#471187} Committed: https://chromium.googlesource.com/chromium/src/+/e7e36ccdaa3fcf63b330bc956eeeb73abf7c39ea

Patch Set 1 #

Patch Set 2 : move gpu_stream_constants #

Patch Set 3 : more tests #

Patch Set 4 : Do not allow HIGH priority contexts by unprivileged clients. #

Patch Set 5 : Do not allow HIGH priority contexts by unprivileged clients. #

Total comments: 2

Patch Set 6 : gpu: Use adaptive vsync for GLX surface. #

Patch Set 7 : revert patch applied by mistake #

Patch Set 8 : rebase #

Patch Set 9 : enable async worker context only when gpu scheduler is enabled #

Patch Set 10 : temporarily enable gpu scheduler because perf bots can't deal with command line args #

Patch Set 11 : rebase and revert gpu scheduler flag forced on #

Patch Set 12 : flush worker context every frame #

Patch Set 13 : rebase #

Total comments: 31

Patch Set 14 : Revert "flush worker context every frame" #

Patch Set 15 : review #

Patch Set 16 : enum -> enum class #

Total comments: 4

Patch Set 17 : nits #

Patch Set 18 : fix test dcheck failures #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1390 lines, -196 lines) Patch
M content/browser/compositor/gpu_process_transport_factory.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +9 lines, -4 lines 0 comments Download
M content/browser/gpu/compositor_util.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +4 lines, -3 lines 0 comments Download
M content/browser/gpu/gpu_ipc_browsertests.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +3 lines, -2 lines 0 comments Download
M content/browser/renderer_host/compositor_impl_android.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +13 lines, -4 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_android.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +7 lines, -3 lines 0 comments Download
A content/common/gpu_stream_constants.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +26 lines, -0 lines 0 comments Download
M content/public/browser/gpu_utils.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +3 lines, -0 lines 0 comments Download
M content/public/common/content_switches.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +2 lines, -0 lines 0 comments Download
M content/public/common/content_switches.cc View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +6 lines, -0 lines 0 comments Download
M content/renderer/pepper/pepper_video_encoder_host.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +4 lines, -4 lines 0 comments Download
M content/renderer/pepper/ppb_graphics_3d_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +2 lines, -1 line 0 comments Download
M content/renderer/render_thread_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 6 chunks +11 lines, -11 lines 0 comments Download
M content/renderer/renderer_blink_platform_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +3 lines, -3 lines 0 comments Download
M content/test/layouttest_support.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +3 lines, -2 lines 0 comments Download
M gpu/BUILD.gn View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M gpu/command_buffer/common/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +2 lines, -0 lines 0 comments Download
A gpu/command_buffer/common/scheduling_priority.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +32 lines, -0 lines 0 comments Download
A gpu/command_buffer/common/scheduling_priority.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +28 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/BUILD.gn View 1 chunk +2 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gles2_cmd_decoder.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +3 lines, -0 lines 0 comments Download
M gpu/command_buffer/service/gpu_preferences.h View 1 chunk +3 lines, -0 lines 0 comments Download
A gpu/command_buffer/service/scheduler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +138 lines, -0 lines 0 comments Download
A gpu/command_buffer/service/scheduler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +499 lines, -0 lines 0 comments Download
A gpu/command_buffer/service/scheduler_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +335 lines, -0 lines 0 comments Download
M gpu/ipc/client/command_buffer_proxy_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +2 lines, -2 lines 0 comments Download
M gpu/ipc/client/command_buffer_proxy_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +1 line, -5 lines 0 comments Download
M gpu/ipc/client/gpu_channel_host.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 4 chunks +0 lines, -8 lines 0 comments Download
M gpu/ipc/client/gpu_channel_host.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +0 lines, -8 lines 0 comments Download
M gpu/ipc/common/BUILD.gn View 1 1 chunk +0 lines, -1 line 0 comments Download
M gpu/ipc/common/gpu_messages.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -1 line 0 comments Download
M gpu/ipc/common/gpu_param_traits_macros.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +3 lines, -2 lines 0 comments Download
M gpu/ipc/common/gpu_preferences.mojom View 1 chunk +1 line, -0 lines 0 comments Download
M gpu/ipc/common/gpu_preferences_struct_traits.h View 2 chunks +4 lines, -0 lines 0 comments Download
M gpu/ipc/common/gpu_stream_constants.h View 1 1 chunk +0 lines, -16 lines 0 comments Download
M gpu/ipc/common/struct_traits_unittest.cc View 2 chunks +2 lines, -0 lines 0 comments Download
M gpu/ipc/service/gpu_channel.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 chunks +38 lines, -23 lines 0 comments Download
M gpu/ipc/service/gpu_channel.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 chunks +109 lines, -38 lines 0 comments Download
M gpu/ipc/service/gpu_channel_manager.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 4 chunks +8 lines, -1 line 0 comments Download
M gpu/ipc/service/gpu_channel_manager.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 10 chunks +13 lines, -14 lines 0 comments Download
M gpu/ipc/service/gpu_channel_test_common.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +3 lines, -2 lines 0 comments Download
M gpu/ipc/service/gpu_channel_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 10 chunks +36 lines, -24 lines 0 comments Download
M gpu/ipc/service/gpu_command_buffer_stub.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +6 lines, -2 lines 0 comments Download
M services/ui/gpu/gpu_service.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +3 lines, -0 lines 0 comments Download
M services/ui/gpu/gpu_service.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +8 lines, -3 lines 0 comments Download
M services/ui/public/cpp/gpu/context_provider_command_buffer.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +3 lines, -3 lines 0 comments Download
M services/ui/public/cpp/gpu/context_provider_command_buffer.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -1 line 0 comments Download
M services/ui/public/cpp/gpu/gpu.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 3 chunks +9 lines, -5 lines 0 comments Download

Messages

Total messages: 44 (24 generated)
sunnyps
This is not fully done yet but is very close to the final state. PTAL ...
3 years, 8 months ago (2017-04-11 20:02:22 UTC) #9
sunnyps
vmiura@ PTAL
3 years, 8 months ago (2017-04-14 20:35:02 UTC) #15
vmiura
I'm still reviewing the Scheduler implementation. A few comments for now. https://codereview.chromium.org/2814843002/diff/80001/gpu/ipc/service/gpu_channel.h File gpu/ipc/service/gpu_channel.h (right): ...
3 years, 7 months ago (2017-05-04 21:27:37 UTC) #17
piman
Ditto, still reviewing the scheduler code, but here's feedback on the rest, mostly nits. https://codereview.chromium.org/2814843002/diff/240001/gpu/command_buffer/client/context_support.h ...
3 years, 7 months ago (2017-05-09 00:48:39 UTC) #18
piman
Some more nits. Overall this is nice though, close to landing I think. https://codereview.chromium.org/2814843002/diff/240001/gpu/command_buffer/service/scheduler.cc File ...
3 years, 7 months ago (2017-05-10 00:38:50 UTC) #19
sunnyps
Addressed all comments and removed the temporary EnsureWorkVisibleAsync patch. PTAL https://codereview.chromium.org/2814843002/diff/80001/gpu/ipc/service/gpu_channel.h File gpu/ipc/service/gpu_channel.h (right): https://codereview.chromium.org/2814843002/diff/80001/gpu/ipc/service/gpu_channel.h#newcode291 ...
3 years, 7 months ago (2017-05-10 23:15:16 UTC) #20
piman
lgtm
3 years, 7 months ago (2017-05-10 23:35:24 UTC) #21
sunnyps
+dcheng@ for OWNERS review of gpu/ipc changes +sadrul@ for OWNERS review of services/ui/.../gpu changes
3 years, 7 months ago (2017-05-10 23:53:35 UTC) #23
dcheng
ipc lgtm https://codereview.chromium.org/2814843002/diff/300001/gpu/command_buffer/service/scheduler.cc File gpu/command_buffer/service/scheduler.cc (right): https://codereview.chromium.org/2814843002/diff/300001/gpu/command_buffer/service/scheduler.cc#newcode151 gpu/command_buffer/service/scheduler.cc:151: : sequence_id_(sequence_id), priority_(priority), order_data_(order_data) {} Nit: std::move(order_data) ...
3 years, 7 months ago (2017-05-11 03:31:47 UTC) #24
sadrul
lgtm https://codereview.chromium.org/2814843002/diff/300001/services/ui/public/cpp/gpu/gpu.cc File services/ui/public/cpp/gpu/gpu.cc (right): https://codereview.chromium.org/2814843002/diff/300001/services/ui/public/cpp/gpu/gpu.cc#newcode67 services/ui/public/cpp/gpu/gpu.cc:67: bool support_locking = false; Can these remain constexpr ...
3 years, 7 months ago (2017-05-11 04:05:09 UTC) #25
vmiura
lgtm4
3 years, 7 months ago (2017-05-11 18:49:45 UTC) #26
vmiura
lgtm
3 years, 7 months ago (2017-05-11 18:50:04 UTC) #27
sunnyps
Thanks everyone! https://codereview.chromium.org/2814843002/diff/300001/gpu/command_buffer/service/scheduler.cc File gpu/command_buffer/service/scheduler.cc (right): https://codereview.chromium.org/2814843002/diff/300001/gpu/command_buffer/service/scheduler.cc#newcode151 gpu/command_buffer/service/scheduler.cc:151: : sequence_id_(sequence_id), priority_(priority), order_data_(order_data) {} On 2017/05/11 ...
3 years, 7 months ago (2017-05-11 20:58:55 UTC) #30
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2814843002/320001
3 years, 7 months ago (2017-05-11 20:59:25 UTC) #31
commit-bot: I haz the power
Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linux/builds/366094)
3 years, 7 months ago (2017-05-11 22:16:24 UTC) #33
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2814843002/340001
3 years, 7 months ago (2017-05-11 23:24:52 UTC) #36
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/452494)
3 years, 7 months ago (2017-05-12 00:32:36 UTC) #38
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2814843002/340001
3 years, 7 months ago (2017-05-12 01:14:02 UTC) #40
commit-bot: I haz the power
Committed patchset #18 (id:340001) as https://chromium.googlesource.com/chromium/src/+/e7e36ccdaa3fcf63b330bc956eeeb73abf7c39ea
3 years, 7 months ago (2017-05-12 02:26:44 UTC) #43
Justin Donnelly
3 years, 7 months ago (2017-05-12 16:43:44 UTC) #44
Message was sent while issue was closed.
A revert of this CL (patchset #18 id:340001) has been created in
https://codereview.chromium.org/2881813002/ by jdonnelly@chromium.org.

The reason for reverting is: Suspected of breaking the Win7 Tests (dbg)(1)
builder:

https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%2...

Sample stack trace:

[6424:6796:0512/085713.197:FATAL:gpu_channel.cc(122)] Check failed:
channel_messages_.empty(). 
Backtrace:
	base::debug::StackTrace::StackTrace [0x100AD557+55]
	base::debug::StackTrace::StackTrace [0x100AD1F1+17]
	logging::LogMessage::~LogMessage [0x1010103E+94]
	gpu::GpuChannelMessageQueue::~GpuChannelMessageQueue [0x0AA6A1DE+126]
	gpu::GpuChannelMessageQueue::`scalar deleting destructor' [0x0AA6D13F+15]
	base::RefCountedThreadSafe<gpu::GpuChannelMessageQueue,base::DefaultRefCountedThreadSafeTraits<gpu::GpuChannelMessageQueue>
>::DeleteInternal [0x0AA6E4A2+34]
	base::DefaultRefCountedThreadSafeTraits<gpu::GpuChannelMessageQueue>::Destruct
[0x0AA6E7BC+12]
	base::RefCountedThreadSafe<gpu::GpuChannelMessageQueue,base::DefaultRefCountedThreadSafeTraits<gpu::GpuChannelMessageQueue>
>::Release [0x0AA731D0+32]
	scoped_refptr<gpu::GpuChannelMessageQueue>::Release [0x0AA7323B+11]
	scoped_refptr<gpu::GpuChannelMessageQueue>::~scoped_refptr<gpu::GpuChannelMessageQueue>
[0x0AA69A5A+26]
	gpu::GpuChannelMessageFilter::~GpuChannelMessageFilter [0x0AA6A0F7+151]
	gpu::GpuChannelMessageFilter::`vector deleting destructor' [0x0AA6CC4D+77]
	base::RefCountedThreadSafe<IPC::MessageFilter,base::DefaultRefCountedThreadSafeTraits<IPC::MessageFilter>
>::DeleteInternal [0x0B154D27+39]
	base::DefaultRefCountedThreadSafeTraits<IPC::MessageFilter>::Destruct
[0x0B154F3C+12]
	base::RefCountedThreadSafe<IPC::MessageFilter,base::DefaultRefCountedThreadSafeTraits<IPC::MessageFilter>
>::Release [0x0B1565DA+58]
	scoped_refptr<IPC::MessageFilter>::Release [0x0B15662E+14]
	scoped_refptr<IPC::MessageFilter>::~scoped_refptr<IPC::MessageFilter>
[0x0B152A7A+26]
	scoped_refptr<IPC::MessageFilter>::`scalar deleting destructor' [0x0B15411F+15]
	std::allocator<scoped_refptr<IPC::MessageFilter>
>::destroy<scoped_refptr<IPC::MessageFilter> > [0x0B151261+17]
	std::allocator_traits<std::allocator<scoped_refptr<IPC::MessageFilter> >
>::destroy<scoped_refptr<IPC::MessageFilter> > [0x0B15127F+15]
	std::_Wrap_alloc<std::allocator<scoped_refptr<IPC::MessageFilter> >
>::destroy<scoped_refptr<IPC::MessageFilter> > [0x0B151234+20]
	std::_Destroy_range1<std::allocator<scoped_refptr<IPC::MessageFilter>
>,scoped_refptr<IPC::MessageFilter> *> [0x0B15074B+43]
	std::_Destroy_range<std::allocator<scoped_refptr<IPC::MessageFilter>
>,scoped_refptr<IPC::MessageFilter> *> [0x0B1507AA+26]
	std::vector<scoped_refptr<IPC::MessageFilter>,std::allocator<scoped_refptr<IPC::MessageFilter>
> >::_Destroy [0x0B15740D+29]
	std::vector<scoped_refptr<IPC::MessageFilter>,std::allocator<scoped_refptr<IPC::MessageFilter>
> >::clear [0x0B15878E+46]
	IPC::ChannelProxy::Context::OnChannelClosed [0x0B1558EB+395]
	IPC::SyncChannel::SyncContext::OnChannelClosed [0x0B190416+38]
	??$Invoke@ABV?$scoped_refptr@VContext@ChannelProxy@IPC@@@@$$V@?$FunctorTraits@P8Context@ChannelProxy@IPC@@AEXXZX@internal@base@@SAXP8Context@ChannelProxy@IPC@@AEXXZABV?$scoped_refptr@VContext@ChannelProxy@IPC@@@@@Z
[0x0B14F978+24]
	base::internal::InvokeHelper<0,void>::MakeItSo<void (__thiscall
IPC::ChannelProxy::Context::*const
&)(void),scoped_refptr<IPC::ChannelProxy::Context> const &> [0x0B1500B8+40]
	base::internal::Invoker<base::internal::BindState<void (__thiscall
IPC::ChannelProxy::Context::*)(void),scoped_refptr<IPC::ChannelProxy::Context>
>,void __cdecl(void)>::RunImpl<void (__thiscall
IPC::ChannelProxy::Context::*const &)(void),std::tuple<scoped [0x0B1504A4+52]
	base::internal::Invoker<base::internal::BindState<void (__thiscall
IPC::ChannelProxy::Context::*)(void),scoped_refptr<IPC::ChannelProxy::Context>
>,void __cdecl(void)>::Run [0x0B156904+36]
	base::Callback<void __cdecl(void),0,0>::Run [0x10049A45+53]
	base::debug::TaskAnnotator::RunTask [0x100B444C+476]
	base::MessageLoop::RunTask [0x1012F94C+620]
	base::MessageLoop::DeferOrRunPendingTask [0x1012DE4B+43]
	base::MessageLoop::DoWork [0x1012E44F+239]
	base::MessagePumpForIO::DoRunLoop [0x10136211+33]
	base::MessagePumpWin::Run [0x101372FB+123]
	base::MessageLoop::RunHandler [0x1012F5C5+293]
	base::RunLoop::Run [0x101EDB26+166]
	base::Thread::Run [0x10289D01+273]
	base::Thread::ThreadMain [0x1028AE4F+863]
	base::PlatformThread::Sleep [0x102659EC+380]
	BaseThreadInitThunk [0x76A9338A+18]
	RtlInitializeExceptionChain [0x77A39902+99]
	RtlInitializeExceptionChain [0x77A398D5+54].

Powered by Google App Engine
This is Rietveld 408576698