Increase the size of the sticker LRU cache.

We ship with 49 stickers and the previous cache size of 32 led to
thrasing every time a chat was opened.

Since sticker packs can be as large as 200 stickers and we hold three
pages in cache while the keyboard is open, increase the cache size for
the main app to 600. For the share extension, make it 64 to minimize
memory use while avoiding threashing.

The cost of this cache is just the sticker metadata (unique ID, emoji
description, etc.) so it won't make much difference in memory
utilization.
This commit is contained in:
George Nachman 2022-01-27 12:41:05 -08:00
parent 520da1e000
commit 07d3ce2dec

View File

@ -909,7 +909,18 @@ public class InstalledStickerCache: NSObject {
}
private let cache: ModelReadCache<KeyType, ValueType>
private let adapter = Adapter(cacheName: "InstalledSticker", cacheCountLimit: 32, cacheCountLimitNSE: 8)
private static var cacheCountLimit: Int {
if CurrentAppContext().isMainApp {
// Large enough to hold three pages of max-size stickers.
return 600
} else {
// Large enough to hold the current default 49 stickers with a little room to grow.
return 64
}
}
private let adapter = Adapter(cacheName: "InstalledSticker",
cacheCountLimit: InstalledStickerCache.cacheCountLimit,
cacheCountLimitNSE: 8)
@objc
public override init() {