e16eca95f5
Allocations are redirected by overriding `operator new` and `operator delete` on the IRNode class. This allows us to use our existing `unique_ptr` and `make_unique` calls as-is. The Pool class is simple; it holds a fixed number of nodes and recycles them as they are returned. A fixed pool size of 2000 nodes was chosen. That is large enough to hold the contents of `sksl_large` during compilation, but it can be overflowed by very large shaders, or if multiple programs are converted at the same time. Exhausting the pool is not a problem; if this happens, additional nodes will be allocated via the system allocator as usual. More elaborate schemes are possible but might not add a lot of value. Thread safety is accomplished by placing the pool in a `thread_local` static during a Program's creation and destruction; the pool is freed when the program is destroyed. One important consequence of this strategy is that a program must free every node that it allocated during its creation, or else the node will be leaked. In debug, leaking a node will be detected and causes a DEBUGFAIL. In release, the pool will be freed despite having a live node in it, and if that node is later freed, that pointer will be passed to the system `free` (which is likely to cause a crash). In this CL, iOS does not support pooling, since support for `thread_local` was only added on iOS 9. This is fixed in the followup CL, http://review.skia.org/328837, which uses pthread keys on iOS. Nanobench shows ~15% improvement: (last week) http://screen/5CNBhTaZApcDA8h (today) http://screen/8ti5Rymvf6LUs8i Change-Id: I559de73606ee1be54e5eae7f82129dc928a63e3c Reviewed-on: https://skia-review.googlesource.com/c/skia/+/326876 Commit-Queue: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Auto-Submit: John Stiles <johnstiles@google.com> |
||
---|---|---|
animations | ||
bazel | ||
bench | ||
bin | ||
build/fuchsia | ||
build_overrides | ||
client_utils/android | ||
demos.skia.org | ||
dm | ||
docker | ||
docs/examples | ||
example | ||
experimental | ||
fuzz | ||
gm | ||
gn | ||
include | ||
infra | ||
modules | ||
platform_tools | ||
resources | ||
samplecode | ||
site | ||
specs | ||
src | ||
tests | ||
third_party | ||
tools | ||
.bazelignore | ||
.clang-format | ||
.clang-tidy | ||
.gitignore | ||
.gn | ||
AUTHORS | ||
BUILD.bazel | ||
BUILD.gn | ||
codereview.settings | ||
CONTRIBUTING | ||
CQ_COMMITTERS | ||
DEPS | ||
go.mod | ||
go.sum | ||
LICENSE | ||
OWNERS | ||
PRESUBMIT.py | ||
public.bzl | ||
README | ||
README.chromium | ||
RELEASE_NOTES.txt | ||
whitespace.txt | ||
WORKSPACE.bazel |
Skia is a complete 2D graphic library for drawing Text, Geometries, and Images. See full details, and build instructions, at https://skia.org.