Skip to content

Commit 0122fce

Browse files
committed
Update docs
1 parent aef8cb2 commit 0122fce

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

sycl/doc/design/KernelProgramCache.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -415,15 +415,16 @@ When adding a new program to cache, we check if the size of the program cache ex
415415

416416
#### Persistent cache eviction
417417

418-
Persistent cache eviction is going to be applied based on file last access
419-
(read/write) date (access time). On SYCL application shutdown phase cache
420-
eviction process is initiated which walks through cache directories as follows:
421-
422-
- if the file is locked, go to the next file;
423-
- otherwise check file access time:
424-
- if file access time is above threshold, delete the file and remove parent
425-
directory while they are unlocked and empty;
426-
- otherwise do nothing.
418+
Persistent cache eviction can be enabled using the SYCL_CACHE_MAX_SIZE environment variable and is based on the LRU strategy.
419+
420+
- A new file, called `cache_size.txt`, is created at the root of the persistent cache directory. This file contains the total size of the cache in bytes. When a new item is added to the cache, the size of the item is added to the total size in the `cache_size.txt` file. When the total size exceeds the threshold, the eviction process is initiated.
421+
422+
- Whenever a cache entry is added or accessed, the corresponding cache item directory is updated with the current time. This is done by creating a new file, called `<entry name>_access_time.txt`, in the cache item directory. This file contains the current time in nanoseconds since the epoch. When the eviction process is initiated, we use this file to determine the last access time of the cache item.
423+
424+
- When a new item is added to the cache, we check if the total size exceeds the threshold. If so, we iterate through the cache item directories and delete the least recently accessed items until the total size is below half the cache size.
425+
426+
Note that once the eviction is triggered, the cache size is reduced to half the cache size to avoid frequent eviction.
427+
427428

428429
## Cache limitations
429430

0 commit comments

Comments
 (0)