DescriptionMake GrMemoryPool play nice with bucketing allocators.
Some memory allocators have very coarse size buckets, so for example on
Android (jemalloc) an attempt to allocate 32 KiB + 1 byte will end up
allocating 40 KiB, wasting 8 KiB.
GrMemoryPool ctor takes two arguments that specify prealloc / block sizes,
and then inflates them to accommodate some bookkeeping structures. Since
most places create GrMemoryPools with pow2 numbers (which have buckets in
most allocators) the inflation causes allocator to select next size bucket,
wasting memory.
This CL makes GrMemoryPool to stop inflating sizes it was created with, and
allocate specified amounts exactly. Part of allocated memory is then used for
bookkeeping structures. Additionally, GrObjectMemoryPool template is provided,
which takes prealloc / block object counts (instead of sizes) and guarantees
that specified number of objects will fit in prealloc / block spaces.
BUG=651872
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2525773002
Committed: https://skia.googlesource.com/skia/+/e4cd00699167cefde9abedbd49ede64f82d552c7
Patch Set 1 #
Total comments: 4
Patch Set 2 : Proper naming; kill friend #
Total comments: 2
Messages
Total messages: 19 (10 generated)
|