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> |
||
---|---|---|
.. | ||
toolchain | ||
__init__.py | ||
bench.gni | ||
BUILD.gn | ||
BUILDCONFIG.gn | ||
call.py | ||
checkdir.py | ||
checkpath.py | ||
codesign_ios.py | ||
compile_ib_files.py | ||
compile_processors.py | ||
compile_sksl_tests.py | ||
copy_git_directory.py | ||
core.gni | ||
cp.py | ||
create_sksl_fp.py | ||
dehydrate_sksl.py | ||
effects_imagefilters.gni | ||
effects.gni | ||
find_headers.py | ||
find_msvc.py | ||
find_xcode_sysroot.py | ||
flutter_defines.gni | ||
fuchsia_defines.gni | ||
gen_plist_ios.py | ||
gm.gni | ||
gn_meta_sln.py | ||
gn_to_bp_utils.py | ||
gn_to_bp.py | ||
gn_to_cmake.py | ||
gpu.gni | ||
highest_version_dir.py | ||
ios.gni | ||
is_clang.py | ||
make_gm_gni.py | ||
opts.gni | ||
pdf.gni | ||
push_to_android.py | ||
rm.py | ||
run_sksllex.py | ||
samples.gni | ||
shared_sources.gni | ||
skia.gni | ||
sksl_tests.gni | ||
sksl.gni | ||
tests.gni | ||
utils.gni | ||
xps.gni |