Reland "thread-local caches?"
This is a reland of 0c9995dc51
PS2 skips program caching on G3/iOS/ARMv7 builds.
It doesn't seem important to cache programs on this build configuration
yet, maybe ever: we're not yet JITting on ARMv7, ARMv7 iOS is a dying
platform, and non-G3 builds, both local and bot, work fine for me so
maybe it's just an old toolchain? For now I'm just disabling caching by
returning nullptr. If the list of platforms grows much bigger or more
important, I may put back a spinlock-based best-effort caching.
Original change's description:
> thread-local caches?
>
> Here's another idea... these SkVMBlitter program caches are probably
> best thread-local. If there are a bunch of threads doing the same work
> with the same program, we don't need them fighting over that one slot in
> the cache, and if there are a bunch of threads doing _different_ work,
> they'll get the best cache behavior if they don't fight over slots in
> the LRU with different programs. Either way, seems like a win?
>
> (I've kept the try-acquire/release pattern just to make the focus of
> this change more clear. We can fold it through more if we like it.)
>
> Change-Id: Ib1ee270069c48446845ce27225652896661c5dfe
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233060
> Commit-Queue: Mike Klein <mtklein@google.com>
> Reviewed-by: Herb Derby <herb@google.com>
Cq-Include-Trybots: skia.primary:Build-Mac-Clang-arm-Debug-iOS
Change-Id: I8d8ef5ab56b914c9c305bb1729b72c8bca373337
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233237
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
54602eaaa6
commit
0b84eab299
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "include/private/SkMacros.h"
|
||||
#include "include/private/SkSpinlock.h"
|
||||
#include "src/core/SkArenaAlloc.h"
|
||||
#include "src/core/SkColorSpacePriv.h"
|
||||
#include "src/core/SkColorSpaceXformSteps.h"
|
||||
@ -44,20 +43,18 @@ namespace {
|
||||
&& x.colorFilter == y.colorFilter;
|
||||
}
|
||||
|
||||
static SkSpinlock gProgramCacheLock;
|
||||
|
||||
SK_TRY_ACQUIRE(true, gProgramCacheLock)
|
||||
static SkLRUCache<Key, skvm::Program>* try_acquire_program_cache() {
|
||||
if (gProgramCacheLock.tryAcquire()) {
|
||||
static auto cache SK_GUARDED_BY(gProgramCacheLock)
|
||||
= new SkLRUCache<Key, skvm::Program>{8};
|
||||
return cache;
|
||||
}
|
||||
return nullptr;
|
||||
#if defined(SK_BUILD_FOR_GOOGLE3) && defined(SK_BUILD_FOR_IOS) && defined(__arm)
|
||||
// Some troublemaker build configurations (so far G3/iOS/armv7) don't support
|
||||
// thread_local. We could use an SkSpinlock and tryAcquire()/release(), or...
|
||||
return nullptr; // ... we could just not cache programs on those platforms.
|
||||
#else
|
||||
thread_local static auto* cache = new SkLRUCache<Key, skvm::Program>{8};
|
||||
return cache;
|
||||
#endif
|
||||
}
|
||||
|
||||
SK_RELEASE_CAPABILITY(gProgramCacheLock)
|
||||
static void release_program_cache() { gProgramCacheLock.release(); }
|
||||
static void release_program_cache() { }
|
||||
|
||||
|
||||
struct Uniforms {
|
||||
|
Loading…
Reference in New Issue
Block a user