aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkTaskGroup.cpp
Commit message (Collapse)AuthorAge
* Add FIFO thread pool, use it for most things.Gravatar Mike Klein2017-09-01
| | | | | | | | | | | | | | | | | | | 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>
* add SkTaskGroup::done()Gravatar Mike Klein2017-08-24
| | | | | | | | | | 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>
* Switch SkTaskGroup to std::atomic.Gravatar Mike Klein2017-02-22
| | | | | | | | | 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>
* SkExecutorGravatar Mike Klein2017-02-22
| | | | | | | | | | | | | | | | | | 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>
* SkLeanWindows.h: #include "Windows.h" fewer placesGravatar halcanary2016-06-07
| | | | | | | | | | | | | | | | | | | | | | | | $ 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
* SkOncePtr -> SkOnceGravatar mtklein2016-05-05
| | | | | | | | | | | | | | | | 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
* Revert of SkOncePtr -> SkOnce (patchset #1 id:1 of ↵Gravatar reed2016-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Reland of SkOncePtr -> SkOnce (patchset #1 id:1 of ↵Gravatar reed2016-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert of SkOncePtr -> SkOnce (patchset #4 id:60001 of ↵Gravatar reed2016-05-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* SkOncePtr -> SkOnceGravatar mtklein2016-05-04
| | | | | | | | | | | | | | 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
* Modernize and trim down SkOnce.Gravatar mtklein2016-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Style bikeshed - remove extraneous whitespaceGravatar halcanary2016-03-29
| | | | | | 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
* clean up more dead codeGravatar mtklein2016-02-16
| | | | | | | | | | - 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
* If we swap its arguments, SkTaskGroup::batch() _is_ sk_parallel_for.Gravatar mtklein2016-01-04
| | | | | | | | | | | 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
* Change SkTaskGroup to use std::function. Ripple all the changes.Gravatar herb2015-12-10
| | | | | | BUG=skia:4634 Review URL: https://codereview.chromium.org/1519573003
* Avoid hang in OncePtr test with --threads 1Gravatar kkinnunen2015-11-04
| | | | | | | | | | | | | 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
* Style Change: NULL->nullptrGravatar halcanary2015-08-27
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316233002 Review URL: https://codereview.chromium.org/1316233002
* Style Change: SkNEW->new; SkDELETE->deleteGravatar halcanary2015-08-26
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316123003 Review URL: https://codereview.chromium.org/1316123003
* Don't cap num_cores at 32 on 32-bit Windows.Gravatar mtklein2015-07-01
| | | | | | | | | 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
* Add sk_parallel_for()Gravatar mtklein2015-06-17
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Add and use SkSemaphoreGravatar mtklein2015-06-17
| | | | | | | | | | | 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
* Modernize atomics in SkTaskGroup's threadpool.Gravatar mtklein2015-06-17
| | | | | | | | | | | | | | - 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
* Manually load CONDITION_VARIABLE methods on Windows, checking for failure (XP).Gravatar mtklein2014-11-03
| | | | | | | | | | | | 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
* SkTaskGroup::batch(fn, args, N)Gravatar mtklein2014-10-29
| | | | | | | | Porting QuiltTask isn't important in itself; this is mostly an API feeler. BUG=skia: Review URL: https://codereview.chromium.org/689673003
* MultiPictureDraw is taskgroup aware.Gravatar reed2014-10-29
SampleApp is multipicturedraw aware. BUG=skia: Review URL: https://codereview.chromium.org/684923002