summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opengl/libs/EGL/MultifileBlobCache.cpp16
-rw-r--r--opengl/libs/EGL/MultifileBlobCache.h3
-rw-r--r--opengl/libs/EGL/MultifileBlobCache_test.cpp9
-rw-r--r--opengl/libs/EGL/egl_cache.cpp12
4 files changed, 22 insertions, 18 deletions
diff --git a/opengl/libs/EGL/MultifileBlobCache.cpp b/opengl/libs/EGL/MultifileBlobCache.cpp
index 1c0c045bb4..b5ddd601ce 100644
--- a/opengl/libs/EGL/MultifileBlobCache.cpp
+++ b/opengl/libs/EGL/MultifileBlobCache.cpp
@@ -62,12 +62,14 @@ void freeHotCacheEntry(android::MultifileHotCache& entry) {
namespace android {
-MultifileBlobCache::MultifileBlobCache(size_t maxTotalSize, size_t maxHotCacheSize,
+MultifileBlobCache::MultifileBlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxTotalSize,
const std::string& baseDir)
: mInitialized(false),
+ mMaxKeySize(maxKeySize),
+ mMaxValueSize(maxValueSize),
mMaxTotalSize(maxTotalSize),
mTotalCacheSize(0),
- mHotCacheLimit(maxHotCacheSize),
+ mHotCacheLimit(0),
mHotCacheSize(0),
mWorkerThreadIdle(true) {
if (baseDir.empty()) {
@@ -78,9 +80,9 @@ MultifileBlobCache::MultifileBlobCache(size_t maxTotalSize, size_t maxHotCacheSi
// Establish the name of our multifile directory
mMultifileDirName = baseDir + ".multifile";
- // Set a limit for max key and value, ensuring at least one entry can always fit in hot cache
- mMaxKeySize = mHotCacheLimit / 4;
- mMaxValueSize = mHotCacheLimit / 2;
+ // Set the hotcache limit to be large enough to contain one max entry
+ // This ensure the hot cache is always large enough for single entry
+ mHotCacheLimit = mMaxKeySize + mMaxValueSize + sizeof(MultifileHeader);
ALOGV("INIT: Initializing multifile blobcache with maxKeySize=%zu and maxValueSize=%zu",
mMaxKeySize, mMaxValueSize);
@@ -254,7 +256,7 @@ void MultifileBlobCache::set(const void* key, EGLsizeiANDROID keySize, const voi
// Ensure key and value are under their limits
if (keySize > mMaxKeySize || valueSize > mMaxValueSize) {
- ALOGV("SET: keySize (%lu vs %zu) or valueSize (%lu vs %zu) too large", keySize, mMaxKeySize,
+ ALOGW("SET: keySize (%lu vs %zu) or valueSize (%lu vs %zu) too large", keySize, mMaxKeySize,
valueSize, mMaxValueSize);
return;
}
@@ -326,7 +328,7 @@ EGLsizeiANDROID MultifileBlobCache::get(const void* key, EGLsizeiANDROID keySize
// Ensure key and value are under their limits
if (keySize > mMaxKeySize || valueSize > mMaxValueSize) {
- ALOGV("GET: keySize (%lu vs %zu) or valueSize (%lu vs %zu) too large", keySize, mMaxKeySize,
+ ALOGW("GET: keySize (%lu vs %zu) or valueSize (%lu vs %zu) too large", keySize, mMaxKeySize,
valueSize, mMaxValueSize);
return 0;
}
diff --git a/opengl/libs/EGL/MultifileBlobCache.h b/opengl/libs/EGL/MultifileBlobCache.h
index f266011fda..5e527dcf35 100644
--- a/opengl/libs/EGL/MultifileBlobCache.h
+++ b/opengl/libs/EGL/MultifileBlobCache.h
@@ -91,7 +91,8 @@ private:
class MultifileBlobCache {
public:
- MultifileBlobCache(size_t maxTotalSize, size_t maxHotCacheSize, const std::string& baseDir);
+ MultifileBlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxTotalSize,
+ const std::string& baseDir);
~MultifileBlobCache();
void set(const void* key, EGLsizeiANDROID keySize, const void* value,
diff --git a/opengl/libs/EGL/MultifileBlobCache_test.cpp b/opengl/libs/EGL/MultifileBlobCache_test.cpp
index 670e1139dd..dbee13bb2e 100644
--- a/opengl/libs/EGL/MultifileBlobCache_test.cpp
+++ b/opengl/libs/EGL/MultifileBlobCache_test.cpp
@@ -28,17 +28,16 @@ namespace android {
template <typename T>
using sp = std::shared_ptr<T>;
+constexpr size_t kMaxKeySize = 2 * 1024;
+constexpr size_t kMaxValueSize = 6 * 1024;
constexpr size_t kMaxTotalSize = 32 * 1024;
-constexpr size_t kMaxPreloadSize = 8 * 1024;
-
-constexpr size_t kMaxKeySize = kMaxPreloadSize / 4;
-constexpr size_t kMaxValueSize = kMaxPreloadSize / 2;
class MultifileBlobCacheTest : public ::testing::Test {
protected:
virtual void SetUp() {
mTempFile.reset(new TemporaryFile());
- mMBC.reset(new MultifileBlobCache(kMaxTotalSize, kMaxPreloadSize, &mTempFile->path[0]));
+ mMBC.reset(new MultifileBlobCache(kMaxKeySize, kMaxValueSize, kMaxTotalSize,
+ &mTempFile->path[0]));
}
virtual void TearDown() { mMBC.reset(); }
diff --git a/opengl/libs/EGL/egl_cache.cpp b/opengl/libs/EGL/egl_cache.cpp
index 3dc93ee0b7..1b68344cb1 100644
--- a/opengl/libs/EGL/egl_cache.cpp
+++ b/opengl/libs/EGL/egl_cache.cpp
@@ -38,8 +38,9 @@ static const size_t kMaxMonolithicTotalSize = 2 * 1024 * 1024;
static const unsigned int kDeferredMonolithicSaveDelay = 4;
// Multifile cache size limits
-constexpr uint32_t kMultifileHotCacheLimit = 8 * 1024 * 1024;
-constexpr uint32_t kMultifileCacheByteLimit = 32 * 1024 * 1024;
+constexpr uint32_t kMaxMultifileKeySize = 1 * 1024 * 1024;
+constexpr uint32_t kMaxMultifileValueSize = 8 * 1024 * 1024;
+constexpr uint32_t kMaxMultifileTotalSize = 32 * 1024 * 1024;
namespace android {
@@ -250,7 +251,7 @@ void egl_cache_t::updateMode() {
if (mMultifileMode) {
mCacheByteLimit = static_cast<size_t>(
base::GetUintProperty<uint32_t>("ro.egl.blobcache.multifile_limit",
- kMultifileCacheByteLimit));
+ kMaxMultifileTotalSize));
// Check for a debug value
int debugCacheSize = base::GetIntProperty("debug.egl.blobcache.multifile_limit", -1);
@@ -274,8 +275,9 @@ BlobCache* egl_cache_t::getBlobCacheLocked() {
MultifileBlobCache* egl_cache_t::getMultifileBlobCacheLocked() {
if (mMultifileBlobCache == nullptr) {
- mMultifileBlobCache.reset(
- new MultifileBlobCache(mCacheByteLimit, kMultifileHotCacheLimit, mFilename));
+ mMultifileBlobCache.reset(new MultifileBlobCache(kMaxMultifileKeySize,
+ kMaxMultifileValueSize, mCacheByteLimit,
+ mFilename));
}
return mMultifileBlobCache.get();
}