[SYCL] Fix flaky failure of concurrent cache eviction UT #16522
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Regression after: #16289
fixes #16515
Problem
The exception is thrown when one process tries to calculate cache size and another process simultaneously inserted/removed any item from the cache. This might cause std::filesystem::recursive_directory iterator to throw std::filesystem_error.
Solution
We catch the exception and just skip over to the next item. This means that while calculating the size of cache we might not consider the size of any item added/removed from cache in the meanwhile. We calculate the cache size only once (for all processes/threads using the same cache) and that too the first-time persistent cache is used by any process. So, this race is rather rare and just ignoring the exception would work.