Skip to content

Commit c2fef63

Browse files
committed
[SYCL] Fix flaky failure of concurrent cache eviction UT
1 parent 075fe28 commit c2fef63

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

sycl/source/detail/persistent_device_code_cache.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,19 @@ void PersistentDeviceCodeCache::repopulateCacheSizeFile(
239239
continue;
240240
} else {
241241
// Calculate the size of the cache directory.
242-
// During directory size calculation, do not add anything
243-
// in the cache. Otherwise, we'll get a std::fs_error.
244-
size_t CacheSize = getDirectorySize(CacheRoot);
242+
size_t CacheSize = 0;
243+
244+
// getDirectorySize can throw if any new file is created or removed
245+
// in the cache by some other process. Retry in that case.
246+
while (true) {
247+
try {
248+
CacheSize = getDirectorySize(CacheRoot);
249+
break;
250+
} catch (...) {
251+
CacheSize = 0;
252+
continue;
253+
}
254+
}
245255

246256
std::ofstream FileStream{CacheSizeFile};
247257
FileStream << CacheSize;

0 commit comments

Comments
 (0)