History log of /external/skia/src/core/SkTaskGroup.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
022cfa258df280d914cfff4dc1466a3fa909ce9c 01-Sep-2017 Mike Klein <mtklein@chromium.org> Add FIFO thread pool, use it for most things.

We like a LIFO default thread pool in tools like DM for better
memory/time locality... the bots use less memory this way, and
generally run faster.

But most use cases want a FIFO queue, so that they can get going
on the next parts of early work while later work is still running.

This splits the implementation into one using SkTArray and pop_back
for LIFO, and a new one using std::deque and pop_front for FIFO.

Change-Id: Ief203b6869a00f1f8084019431a781d15fc63750
Reviewed-on: https://skia-review.googlesource.com/41849
Commit-Queue: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Yuqian Li <liyuqian@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
/external/skia/src/core/SkTaskGroup.cpp
f3c99eecc07a0ac64dc8e796c05fa6df71ea1119 24-Aug-2017 Mike Klein <mtklein@chromium.org> add SkTaskGroup::done()

This lets you check if the work's done without blocking.
Seems handy.

Change-Id: Ie27c7b6fe0d01262b6a777abbc18b0de108641c0
Reviewed-on: https://skia-review.googlesource.com/38120
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
/external/skia/src/core/SkTaskGroup.cpp
416bbd97cee9e221577c729a8072fdb2057cbdf8 22-Feb-2017 Mike Klein <mtklein@chromium.org> Switch SkTaskGroup to std::atomic.

No interesting change, just getting on std APIs.

Change-Id: I0f42cbb6854b49a6ae8266e5b92f977d27f4e032
Reviewed-on: https://skia-review.googlesource.com/8860
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
/external/skia/src/core/SkTaskGroup.cpp
384b90af5ccdbb071f32e20b382f41351b2a0b69 22-Feb-2017 Mike Klein <mtklein@chromium.org> SkExecutor

Refactoring to refamiliarize myself with SkTaskGroup and SkThreadPool.

This adds an SkExecutor interface to describe how we use SkThreadPool,
with a global setter and getter for a default instance. Then I rewrote
SkTaskGroup to work with any executor, the global default by default.

I also think I've made the SkTaskGroup::wait() borrow logic clearer
with the addition of SkSemaphore::try_wait(). This lets me keep the
semaphore count and actual count of work in perfect sync.

Change-Id: I6bbdfaeb0e2c3a43daff6192d34bc4a3f7210178
Reviewed-on: https://skia-review.googlesource.com/8836
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
/external/skia/src/core/SkTaskGroup.cpp
4dbbd04314cc0606f8d3bafe515c97e52c180f73 08-Jun-2016 halcanary <halcanary@google.com> SkLeanWindows.h: #include "Windows.h" fewer places

$ git grep -l '<windows.h>' include src
include/private/SkLeanWindows.h

$ git grep -l SkLeanWindows.h | grep '\.h$'
include/ports/SkTypeface_win.h
include/utils/win/SkHRESULT.h
include/utils/win/SkTScopedComPtr.h
include/views/SkEvent.h
src/core/SkMathPriv.h
src/ports/SkTypeface_win_dw.h
src/utils/SkThreadUtils_win.h
src/utils/win/SkWGL.h

The same for `#include <intrin.h>` that was found in SkMath.h.
Those functions that needed it are moved to SkMathPriv.h.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2041943002

CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_chromium_compile_dbg_ng,win_chromium_compile_rel_ng

Review-Url: https://codereview.chromium.org/2041943002
/external/skia/src/core/SkTaskGroup.cpp
ffa4a9213b4e754adc210fa02a3c4b1ae8d3b6d0 06-May-2016 mtklein <mtklein@chromium.org> SkOncePtr -> SkOnce

It's always nice to kill off a synchronization primitive.
And while less terse, I think this new code reads more clearly.

... and, SkOncePtr's tests were the only thing now using sk_num_cores()
outside of SkTaskGroup, so I've hidden it as static inside SkTaskGroup.cpp.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1953533002
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot

Committed: https://skia.googlesource.com/skia/+/9bd3fc7fa9bb7cad050bd619aa93d4c48ebb5c02

Review-Url: https://codereview.chromium.org/1953533002
/external/skia/src/core/SkTaskGroup.cpp
959a2937d55279c6d020f2511007bb39ed322ace 05-May-2016 reed <reed@google.com> Revert of SkOncePtr -> SkOnce (patchset #1 id:1 of https://codereview.chromium.org/1949313003/ )

Reason for revert:
ok, I have no idea what's going on

Original issue's description:
> Reland of SkOncePtr -> SkOnce (patchset #1 id:1 of https://codereview.chromium.org/1945293004/ )
>
> Reason for revert:
> previous revert unneeded (I think)
>
> Original issue's description:
> > Revert of SkOncePtr -> SkOnce (patchset #4 id:60001 of https://codereview.chromium.org/1953533002/ )
> >
> > Reason for revert:
> > broken the Mac and Linux builders, e.g.:
> >
> > https://build.chromium.org/p/chromium/builders/Mac/builds/15151
> > https://build.chromium.org/p/chromium/builders/Linux%20x64/builds/19052
> >
> > Original issue's description:
> > > SkOncePtr -> SkOnce
> > >
> > > It's always nice to kill off a synchronization primitive.
> > > And while less terse, I think this new code reads more clearly.
> > >
> > > ... and, SkOncePtr's tests were the only thing now using sk_num_cores()
> > > outside of SkTaskGroup, so I've hidden it as static inside SkTaskGroup.cpp.
> > >
> > > BUG=skia:
> > > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1953533002
> > > CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
> > >
> > > Committed: https://skia.googlesource.com/skia/+/9bd3fc7fa9bb7cad050bd619aa93d4c48ebb5c02
> >
> > TBR=herb@google.com,mtklein@chromium.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=skia:
> >
> > Committed: https://skia.googlesource.com/skia/+/7eb33da7eede34c050b865dbb1b60c3dcea7191b
>
> TBR=herb@google.com,mtklein@chromium.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/82da9a8aa0ce648f36882830765b42e0ada6c0fa

TBR=herb@google.com,mtklein@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review-Url: https://codereview.chromium.org/1948313002
/external/skia/src/core/SkTaskGroup.cpp
82da9a8aa0ce648f36882830765b42e0ada6c0fa 05-May-2016 reed <reed@google.com> Reland of SkOncePtr -> SkOnce (patchset #1 id:1 of https://codereview.chromium.org/1945293004/ )

Reason for revert:
previous revert unneeded (I think)

Original issue's description:
> Revert of SkOncePtr -> SkOnce (patchset #4 id:60001 of https://codereview.chromium.org/1953533002/ )
>
> Reason for revert:
> broken the Mac and Linux builders, e.g.:
>
> https://build.chromium.org/p/chromium/builders/Mac/builds/15151
> https://build.chromium.org/p/chromium/builders/Linux%20x64/builds/19052
>
> Original issue's description:
> > SkOncePtr -> SkOnce
> >
> > It's always nice to kill off a synchronization primitive.
> > And while less terse, I think this new code reads more clearly.
> >
> > ... and, SkOncePtr's tests were the only thing now using sk_num_cores()
> > outside of SkTaskGroup, so I've hidden it as static inside SkTaskGroup.cpp.
> >
> > BUG=skia:
> > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1953533002
> > CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
> >
> > Committed: https://skia.googlesource.com/skia/+/9bd3fc7fa9bb7cad050bd619aa93d4c48ebb5c02
>
> TBR=herb@google.com,mtklein@chromium.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/7eb33da7eede34c050b865dbb1b60c3dcea7191b

TBR=herb@google.com,mtklein@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review-Url: https://codereview.chromium.org/1949313003
/external/skia/src/core/SkTaskGroup.cpp
7eb33da7eede34c050b865dbb1b60c3dcea7191b 05-May-2016 reed <reed@google.com> Revert of SkOncePtr -> SkOnce (patchset #4 id:60001 of https://codereview.chromium.org/1953533002/ )

Reason for revert:
broken the Mac and Linux builders, e.g.:

https://build.chromium.org/p/chromium/builders/Mac/builds/15151
https://build.chromium.org/p/chromium/builders/Linux%20x64/builds/19052

Original issue's description:
> SkOncePtr -> SkOnce
>
> It's always nice to kill off a synchronization primitive.
> And while less terse, I think this new code reads more clearly.
>
> ... and, SkOncePtr's tests were the only thing now using sk_num_cores()
> outside of SkTaskGroup, so I've hidden it as static inside SkTaskGroup.cpp.
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1953533002
> CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
>
> Committed: https://skia.googlesource.com/skia/+/9bd3fc7fa9bb7cad050bd619aa93d4c48ebb5c02

TBR=herb@google.com,mtklein@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review-Url: https://codereview.chromium.org/1945293004
/external/skia/src/core/SkTaskGroup.cpp
9bd3fc7fa9bb7cad050bd619aa93d4c48ebb5c02 04-May-2016 mtklein <mtklein@chromium.org> SkOncePtr -> SkOnce

It's always nice to kill off a synchronization primitive.
And while less terse, I think this new code reads more clearly.

... and, SkOncePtr's tests were the only thing now using sk_num_cores()
outside of SkTaskGroup, so I've hidden it as static inside SkTaskGroup.cpp.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1953533002
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot

Review-Url: https://codereview.chromium.org/1953533002
/external/skia/src/core/SkTaskGroup.cpp
d9dd4282118fc14eac735e6fa0b3ec53047b457f 18-Apr-2016 mtklein <mtklein@chromium.org> Modernize and trim down SkOnce.

The API and implementation are very much simplified.
You may not want to bother reading the diff.

As is our trend, SkOnce now uses <atomic> directly.

Member initialization means we don't need SK_DECLARE_STATIC_ONCE.
SkSpinlock already works this same way.

All uses of the old API taking an external bool* and Lock* were pessimal,
so I have not carried this sort of API forward. It's simpler, faster,
and more space-efficient to always use this single SkOnce class interface.

SkOnce weighs 2 bytes: a done bool and an SkSpinlock, also a bool internally.
This API refactoring opens up the opportunity to fuse those into a single
three-state byte if we'd like.

No public API changes.
TBR=reed@google.com

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1894893002

Review URL: https://codereview.chromium.org/1894893002
/external/skia/src/core/SkTaskGroup.cpp
9d524f22bfde5dc3dc8f48e1be39bdebd3bb0304 29-Mar-2016 halcanary <halcanary@google.com> Style bikeshed - remove extraneous whitespace

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1842753002

Review URL: https://codereview.chromium.org/1842753002
/external/skia/src/core/SkTaskGroup.cpp
048494c1e236c4db9d18952de83d2602c1abc7c3 17-Feb-2016 mtklein <mtklein@chromium.org> clean up more dead code

- SkSHA1 is unused
- SkRunnable is obsolete now that we have std::function

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1705583003

Review URL: https://codereview.chromium.org/1705583003
/external/skia/src/core/SkTaskGroup.cpp
279c7864090a7b96c34c3594e38ced35967c673f 05-Jan-2016 mtklein <mtklein@chromium.org> If we swap its arguments, SkTaskGroup::batch() _is_ sk_parallel_for.

Why have two names if we can get away with one?

This kills off sk_parallel_for_thread_count(), which was only used to avoid forcing a deadlock in OncePtrTest on multicore machines in singlethreaded mode... a really niche use case. Instead just don't explicitly force a race.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1552093002

Review URL: https://codereview.chromium.org/1552093002
/external/skia/src/core/SkTaskGroup.cpp
30da5f7a1e4cf0daa2f284b4cae5128b23f0db96 10-Dec-2015 herb <herb@google.com> Change SkTaskGroup to use std::function. Ripple all the changes.

BUG=skia:4634

Review URL: https://codereview.chromium.org/1519573003
/external/skia/src/core/SkTaskGroup.cpp
7f97a76b805b4cc05f83a965063767f0256ea270 04-Nov-2015 kkinnunen <kkinnunen@nvidia.com> Avoid hang in OncePtr test with --threads 1

Avoid hang in OncePtr test when using "dm --threads 1".

The test will hang the threads until sk_num_cores() threads have run
the code. This requires that sk_num_cores() threads to be run in
parallel, which the global thread pool will not do if the thread count
is smaller than sk_num_cores().

BUG=skia:

Review URL: https://codereview.chromium.org/1419593004
/external/skia/src/core/SkTaskGroup.cpp
96fcdcc219d2a0d3579719b84b28bede76efba64 27-Aug-2015 halcanary <halcanary@google.com> Style Change: NULL->nullptr
DOCS_PREVIEW= https://skia.org/?cl=1316233002

Review URL: https://codereview.chromium.org/1316233002
/external/skia/src/core/SkTaskGroup.cpp
385fe4d4b62d7d1dd76116dd570df3290a2f487b 26-Aug-2015 halcanary <halcanary@google.com> Style Change: SkNEW->new; SkDELETE->delete
DOCS_PREVIEW= https://skia.org/?cl=1316123003

Review URL: https://codereview.chromium.org/1316123003
/external/skia/src/core/SkTaskGroup.cpp
a760942b3579f7d863345b9d083abdc187266e08 01-Jul-2015 mtklein <mtklein@chromium.org> Don't cap num_cores at 32 on 32-bit Windows.

See here for a similar change in Ninja. Wanna bet they just got Z840s too?
https://github.com/martine/ninja/commit/8c8834acffdc0da0d94119725929acc712c9dfad

BUG=skia:

Review URL: https://codereview.chromium.org/1213063011
/external/skia/src/core/SkTaskGroup.cpp
00b621cfc0dac2a0028757a974de33a78bb8579d 18-Jun-2015 mtklein <mtklein@chromium.org> Add sk_parallel_for()

This should be a drop-in replacement for most for-loops to make them run in parallel:
for (int i = 0; i < N; i++) { code... }
~~~>
sk_parallel_for(N, [&](int i) { code... });

This is just syntax sugar over SkTaskGroup to make this use case really easy to write.
There's no more overhead that we weren't already forced to add using an interface like batch(),
and no extra heap allocations.

I've replaced 3 uses of SkTaskGroup with sk_parallel_for:
1) My unit tests for SkOnce.
2) Cary's path fuzzer.
3) SkMultiPictureDraw.
Performance should be the same. Please compare left and right for readability. :)

BUG=skia:

No public API changes.
TBR=reed@google.com

Review URL: https://codereview.chromium.org/1184373003
/external/skia/src/core/SkTaskGroup.cpp
61fa22be104a3e98998fa1b24cd47b886df5721c 17-Jun-2015 mtklein <mtklein@chromium.org> Add and use SkSemaphore

This allows a faster implementation of our SkTaskGroup thread pool.
It also means we don't need SkCondVar (which, remember, isn't supported on XP.)

Doing some testing with SampleApp, this really cuts down on the overhead from SkTaskGroup, e.g. 30% to 10%.

BUG=skia:

Review URL: https://codereview.chromium.org/1192573003
/external/skia/src/core/SkTaskGroup.cpp
942e99b9c411d093851db8d12c8357f409563007 17-Jun-2015 mtklein <mtklein@chromium.org> Modernize atomics in SkTaskGroup's threadpool.

- Use SkAtomic<int32_t> for pending work count so we're statically
forced to operate on it with atomic methods.
- Replacing old methods like sk_atomic_inc/dec gives us finer control
over which barriers we need for each operation.

No public API changes.
TBR=reed@google.com

BUG=skia:

Review URL: https://codereview.chromium.org/1193493003
/external/skia/src/core/SkTaskGroup.cpp
db8d0e5bb018594d0ced3bfa68484115d8cf76b8 04-Nov-2014 mtklein <mtklein@chromium.org> Manually load CONDITION_VARIABLE methods on Windows, checking for failure (XP).

Tested by running DM on XP. Before this patch, it fails at startup (even just out/Debug/dm --help). Now it asserts for other reasons later on in user code, which is just fine by me.

The net effect is that SkTaskGroups will always be synchronous on XP. That's not ideal, but a step up from crashing.

CQ_EXTRA_TRYBOTS=client.skia:Test-Win7-ShuttleA-HD2000-x86-Release-Trybot,Test-Win7-ShuttleA-HD2000-x86_64-Release-Trybot

BUG=skia:

Review URL: https://codereview.chromium.org/700683002
/external/skia/src/core/SkTaskGroup.cpp
e71cd54ed4d83310d718490d40643c35b622b9f5 29-Oct-2014 mtklein <mtklein@chromium.org> SkTaskGroup::batch(fn, args, N)

Porting QuiltTask isn't important in itself; this is mostly an API feeler.

BUG=skia:

Review URL: https://codereview.chromium.org/689673003
/external/skia/src/core/SkTaskGroup.cpp
89889b69391a730f0ba2a1efb549864b7762263f 29-Oct-2014 reed <reed@google.com> MultiPictureDraw is taskgroup aware.
SampleApp is multipicturedraw aware.

BUG=skia:

Review URL: https://codereview.chromium.org/684923002
/external/skia/src/core/SkTaskGroup.cpp