refactor: windows cl_cache eviction mechanism

Refactored eviction mechanism works as follows:
- eviction is needed only if
total size of cache binaries + size of the new binary exceed cache limit
- single evition call removes files with a summed size of 1/3 of the cache limit
- if new binary can not fit in the cache size limit
even after eviction, it will not be saved
- cache limit applies only to
files in cache directory with .cl_cache/.l0_cache extension.
Only these files are counted and only these files are removed

Related-To: NEO-8092
Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwolinski
2023-10-03 09:39:59 +00:00
committed by Compute-Runtime-Automation
parent 8fa0b90f35
commit 1f1af5bb36
5 changed files with 175 additions and 45 deletions

View File

@@ -47,7 +47,7 @@ bool compareByLastAccessTime(const ElementsStruct &a, ElementsStruct &b) {
return a.statEl.st_atime < b.statEl.st_atime;
}
bool CompilerCache::evictCache() {
bool CompilerCache::evictCache(uint64_t &bytesEvicted) {
struct dirent **files = 0;
int filesCount = NEO::SysCalls::scandir(config.cacheDir.c_str(), &files, filterFunction, NULL);
@@ -231,7 +231,8 @@ bool CompilerCache::cacheBinary(const std::string &kernelFileHash, const char *p
size_t maxSize = config.cacheSize;
if (maxSize < directorySize + binarySize) {
if (!evictCache()) {
uint64_t bytesEvicted{0u};
if (!evictCache(bytesEvicted)) {
unlockFileAndClose(std::get<int>(fd));
return false;
}