EGL Multifile Blobcache: Make use of crc32_z algorithm instead of crc32c
To improve the performance in generating crc. Using crc32_z would reduce
the function duration by 98 ~ 99 % as follows.
Test: Genshin Impact Loading
Algorithm Num calls Total Duration (millisec)
crc32_z 3678 9909.88
crc32c 3596 1260876.81
Bug: b/373718861
Change-Id: I0b67265c4bcf199d4433b953a5a399629c9508f9
Signed-off-by: Jisun Lee <jisunnie.lee@samsung.com>
diff --git a/opengl/libs/EGL/MultifileBlobCache.cpp b/opengl/libs/EGL/MultifileBlobCache.cpp
index 9905210..f7e33b3 100644
--- a/opengl/libs/EGL/MultifileBlobCache.cpp
+++ b/opengl/libs/EGL/MultifileBlobCache.cpp
@@ -214,9 +214,8 @@
}
// Ensure we have a good CRC
- if (header.crc !=
- crc32c(mappedEntry + sizeof(MultifileHeader),
- fileSize - sizeof(MultifileHeader))) {
+ if (header.crc != GenerateCRC32(mappedEntry + sizeof(MultifileHeader),
+ fileSize - sizeof(MultifileHeader))) {
ALOGV("INIT: Entry %u failed CRC check! Removing.", entryHash);
if (remove(fullPath.c_str()) != 0) {
ALOGE("Error removing %s: %s", fullPath.c_str(), std::strerror(errno));
@@ -532,9 +531,9 @@
mBuildId.length() > PROP_VALUE_MAX ? PROP_VALUE_MAX : mBuildId.length());
// Finally update the crc, using cacheVersion and everything the follows
- status.crc =
- crc32c(reinterpret_cast<uint8_t*>(&status) + offsetof(MultifileStatus, cacheVersion),
- sizeof(status) - offsetof(MultifileStatus, cacheVersion));
+ status.crc = GenerateCRC32(
+ reinterpret_cast<uint8_t *>(&status) + offsetof(MultifileStatus, cacheVersion),
+ sizeof(status) - offsetof(MultifileStatus, cacheVersion));
// Create the status file
std::string cacheStatus = baseDir + "/" + kMultifileBlobCacheStatusFile;
@@ -599,9 +598,9 @@
}
// Ensure we have a good CRC
- if (status.crc !=
- crc32c(reinterpret_cast<uint8_t*>(&status) + offsetof(MultifileStatus, cacheVersion),
- sizeof(status) - offsetof(MultifileStatus, cacheVersion))) {
+ if (status.crc != GenerateCRC32(reinterpret_cast<uint8_t *>(&status) +
+ offsetof(MultifileStatus, cacheVersion),
+ sizeof(status) - offsetof(MultifileStatus, cacheVersion))) {
ALOGE("STATUS(CHECK): Cache status failed CRC check!");
return false;
}
@@ -840,8 +839,8 @@
// Add CRC check to the header (always do this last!)
MultifileHeader* header = reinterpret_cast<MultifileHeader*>(buffer);
- header->crc =
- crc32c(buffer + sizeof(MultifileHeader), bufferSize - sizeof(MultifileHeader));
+ header->crc = GenerateCRC32(buffer + sizeof(MultifileHeader),
+ bufferSize - sizeof(MultifileHeader));
ssize_t result = write(fd, buffer, bufferSize);
if (result != bufferSize) {