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

Issue 1274023003: compositor-worker: Get the thread to run compositor-workers from the Platform. (Closed)

Created:
5 years, 4 months ago by sadrul
Modified:
5 years, 3 months ago
CC:
blink-reviews, michaeln, jsbell+serviceworker_chromium.org, tzik, serviceworker-reviews, nhiroki, falken, kinuko+serviceworker, kinuko+worker_chromium.org, horo+watch_chromium.org, blink-worker-reviews_chromium.org
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

workers: Slightly change how WorkerThread uses a WebThread. Right now, a WorkerThread creates a WebThreadSupportingGC for each WebThread that runs worker code. So, in the case of normal workers (i.e. shared/dedicated/service), each WorkerThread spins up a new WebThreadSupportingGC (which creates and owns a new WebThread instance). For compositor-workers, a single WebThreadSupportingGC is created for all workers by CompositorWorkerManager. This instance of WebThreadSupportingGC creates and owns the thread that runs the compositor-workers. However, we want to run the compositor workers in the same thread as the compositor. This compositor-thread is created, owned, and maintained by the Platform. Therefore, it is not possible for CompositorWorkerManager to create a WebThreadSupportingGC instance. So, change the WorkerThread to work directly with a WebThread. All the normal workers directly create a WebThread instance, and WorkerThread manages the GC support for it. However, CompositorWorkerManager directly creates both a WebThread instance, and necessary code for adding support for GC (GCSupportForWebThread) separately. In a subsequent CL, this will be changed so that instead of creating and owning the WebThread instance, the CompositorWorkerManager gets the WebThread for running the workers from the Platform. BUG=518708

Patch Set 1 #

Patch Set 2 : . #

Patch Set 3 : . #

Patch Set 4 : . #

Total comments: 2

Patch Set 5 : . #

Unified diffs Side-by-side diffs Delta from patch set Stats (+84 lines, -56 lines) Patch
M Source/core/workers/DedicatedWorkerThread.h View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/workers/DedicatedWorkerThread.cpp View 1 2 3 4 1 chunk +3 lines, -3 lines 0 comments Download
M Source/core/workers/SharedWorkerThread.h View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/workers/SharedWorkerThread.cpp View 1 2 3 4 1 chunk +3 lines, -3 lines 0 comments Download
M Source/core/workers/WorkerThread.h View 1 2 3 chunks +2 lines, -2 lines 0 comments Download
M Source/core/workers/WorkerThread.cpp View 1 2 3 chunks +5 lines, -9 lines 0 comments Download
M Source/core/workers/WorkerThreadTest.cpp View 2 chunks +3 lines, -3 lines 0 comments Download
M Source/modules/compositorworker/CompositorWorkerManager.h View 1 2 3 3 chunks +5 lines, -3 lines 0 comments Download
M Source/modules/compositorworker/CompositorWorkerManager.cpp View 1 2 3 4 chunks +9 lines, -6 lines 0 comments Download
M Source/modules/compositorworker/CompositorWorkerManagerTest.cpp View 5 chunks +6 lines, -6 lines 0 comments Download
M Source/modules/compositorworker/CompositorWorkerThread.h View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/compositorworker/CompositorWorkerThread.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/serviceworkers/ServiceWorkerThread.h View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M Source/modules/serviceworkers/ServiceWorkerThread.cpp View 1 2 3 4 1 chunk +3 lines, -3 lines 0 comments Download
M Source/platform/WebThreadSupportingGC.h View 2 chunks +12 lines, -1 line 0 comments Download
M Source/platform/WebThreadSupportingGC.cpp View 2 chunks +25 lines, -9 lines 0 comments Download

Messages

Total messages: 13 (2 generated)
sadrul
5 years, 4 months ago (2015-08-10 03:38:39 UTC) #2
kinuko
(+toyoshim@ for WorkerThread changes) https://codereview.chromium.org/1274023003/diff/60001/Source/core/workers/WorkerThread.h File Source/core/workers/WorkerThread.h (right): https://codereview.chromium.org/1274023003/diff/60001/Source/core/workers/WorkerThread.h#newcode172 Source/core/workers/WorkerThread.h:172: OwnPtr<GCSupportForWebThread> m_gcSupport; I'm a bit ...
5 years, 4 months ago (2015-08-10 05:01:21 UTC) #4
sadrul
https://codereview.chromium.org/1274023003/diff/60001/Source/core/workers/WorkerThread.h File Source/core/workers/WorkerThread.h (right): https://codereview.chromium.org/1274023003/diff/60001/Source/core/workers/WorkerThread.h#newcode172 Source/core/workers/WorkerThread.h:172: OwnPtr<GCSupportForWebThread> m_gcSupport; On 2015/08/10 05:01:21, kinuko wrote: > I'm ...
5 years, 4 months ago (2015-08-10 06:51:20 UTC) #5
kinuko
I think I prefer regular workers continue to have WebThreadSupportingGC rather than decoupling it only ...
5 years, 4 months ago (2015-08-10 14:10:06 UTC) #6
haraken
On 2015/08/10 14:10:06, kinuko wrote: > I think I prefer regular workers continue to have ...
5 years, 4 months ago (2015-08-10 14:23:37 UTC) #7
sadrul
On 2015/08/10 14:23:37, haraken wrote: > On 2015/08/10 14:10:06, kinuko wrote: > > I think ...
5 years, 4 months ago (2015-08-10 14:36:07 UTC) #8
kinuko
On 2015/08/10 14:36:07, sadrul wrote: > On 2015/08/10 14:23:37, haraken wrote: > > On 2015/08/10 ...
5 years, 4 months ago (2015-08-11 04:36:11 UTC) #9
sadrul
On 2015/08/11 04:36:11, kinuko wrote: > On 2015/08/10 14:36:07, sadrul wrote: > > On 2015/08/10 ...
5 years, 4 months ago (2015-08-11 04:45:29 UTC) #10
Takashi Toyoshima
I don't know the historical background, so my following question could be a newbie's one. ...
5 years, 4 months ago (2015-08-13 18:48:34 UTC) #11
sadrul
On 2015/08/13 18:48:34, Takashi Toyoshima (chromium) wrote: > I don't know the historical background, so ...
5 years, 4 months ago (2015-08-13 20:40:39 UTC) #12
kinuko
5 years, 3 months ago (2015-08-31 11:58:45 UTC) #13
On 2015/08/11 04:45:29, sadrul wrote:
> On 2015/08/11 04:36:11, kinuko wrote:
> > On 2015/08/10 14:36:07, sadrul wrote:
> > > On 2015/08/10 14:23:37, haraken wrote:
> > > > On 2015/08/10 14:10:06, kinuko wrote:
> > > > > I think I prefer regular workers continue to have
WebThreadSupportingGC
> > > rather
> > > > > than decoupling it only for coding issues.  I wonder if we could add
one
> > > more
> > > > > create() method to WebThreadSupportingGC that takes an existing
thread,
> so
> > > > that
> > > > > we can create WebThreadSupportingGC for a given thread.  And the
> WebThread
> > > > > implementation for the compositor thread can be probably made in a way
> > that
> > > > > destructing the WebThread instance doesn't mean stopping the
underlying
> > > > thread. 
> > > > > Then we can consistently use WebThreadSupportingGC in all worker
thread
> > > code.
> > > > > Would something like that work / make sense?
> > > > 
> > > > Sounds like a plan!
> > > 
> > > I actually considered doing that at first. That way, there's little change
> to
> > be
> > > made in blink. However, WorkerThread deals with both the WebThread, and
its
> > > corresponding WebScheduler. So the Platform implementation will need to
> create
> > > proxies for both of these, and it becomes ugly pretty quickly.
> > > 
> > > Is there a particular reason you think having the workers continue to
create
> > > WebThreadSupportingGC is beneficial? We can still make that the case (and
> > > override initializeBackingThread()/shutdownBackingThread()) if you think
> that
> > is
> > > better.
> > 
> > I think I worry that decoupling GC support and WebThread could make the code
> > error-prone. We're going to have three combinations of GC support and
> WebThread
> > usage and every one's going to be implemented in a different file, which
> > concerns me a bit.
> 
> The refactor out of GCSupportForWebThread from WebThreadSupportingGC in this
> patch is with hopes to separate out the GC support from thread-ownership,
while
> still using the same code for doing GC (i.e. GCSupportForWebThread). The
actual
> code that does GC is still in a single place (GCSupportForWebThread), and the
> worker code that manages GC is also in a single place (base WorkerThread
class).
> Making the normal workers create a WebThread, and making the base WorkerThread
> class deal with GC (using GCSupportForWebThread) is also with the hope of
making
> sure we use the same code, and not end up with duplicated code.
> 
> Compositor workers here are different by design, and so manage their own GC.
> 
> > 
> > How would it look to you/haraken if we also add detachThread() or something
to
> > WebThreadSupportingGC, which detaches the associated WebThread from
> > WebThreadSupportingGC?
> 
> If we can add a mechanism in WebThreadSupportingGC where it doesn't own the
> WebThread, then that should be sufficient, yes! So something like
> detachThread(), or even a subclass of WebThreadSupportingGC that doesn't own
the
> WebThread (i.e. essentially GCSupportForWebThread), would both be sufficient
for
> this use.

I wanted to see how it'd look like, so I took a shot in this approach and
created https://codereview.chromium.org/1319363002/.

Powered by Google App Engine
This is Rietveld 408576698