allocate memory manually in SkLiteDL
Instead of growing at SkTDArray's chosen rate (+4, then *1.25),
grow in additive 4K pages. This is my attempt to make realloc()
have the best chance of not copying and to keep fragmentation down.
Because we use a freelist the rate we grow doesn't affect performance
too much.
I'm not getting very reliable numbers, but this looks maybe 5-10% faster
for recording, mainly I think from inlining the allocation fast path into
push().
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2231553002
Review-Url: https://codereview.chromium.org/2231553002
diff --git a/src/core/SkLiteDL.h b/src/core/SkLiteDL.h
index a0c1685..27e3f27 100644
--- a/src/core/SkLiteDL.h
+++ b/src/core/SkLiteDL.h
@@ -86,10 +86,20 @@
SkRect onGetBounds() override;
void onDraw(SkCanvas*) override;
- SkLiteDL* fNext;
- int fUsesRemaining;
- SkRect fBounds;
- SkTDArray<uint8_t> fBytes;
+ template <typename T, typename... Args>
+ void* push(size_t, Args&&...);
+
+ template <typename Fn>
+ void map(Fn&& fn);
+
+ SkAutoTMalloc<uint8_t> fBytes;
+ size_t fUsed;
+ size_t fReserved;
+ SkRect fBounds;
+
+ // Only used for freelisting.
+ SkLiteDL* fNext;
+ int fUsesRemaining;
};
#endif//SkLiteDL_DEFINED