|
61 | 61 |
|
62 | 62 |
|
63 | 63 | ## cached compilation
|
| 64 | + |
| 65 | +### Disk cache notes |
| 66 | +# Julia uses package images (pkgimg) to cache both the result of inference, |
| 67 | +# and the result of native code emissions. Up until Julia v1.11 neither the |
| 68 | +# inferred nor the nativce code of foreign abstract interpreters was cached |
| 69 | +# across sessions. Julia v1.11 allows for caching of inference results across |
| 70 | +# sessions as long as those inference results are created during precompilation. |
| 71 | +# |
| 72 | +# Julia cache hierarchy is roughly as follows: |
| 73 | +# Function (name of a thing) |
| 74 | +# -> Method (particular piece of code to dispatch to with a signature) |
| 75 | +# -> MethodInstance (A particular Method + particular signature) |
| 76 | +# -> CodeInstance (A MethodInstance compiled for a world) |
| 77 | +# |
| 78 | +# In order to cache code across sessions we need to insert CodeInstance(owner=GPUCompilerCacheToken) |
| 79 | +# into the internal cache. Once we have done so we know that a particular CodeInstance is unique in |
| 80 | +# the system. (During pkgimg loading conflicts will be resolved). |
| 81 | +# |
| 82 | +# When a pkgimg is loaded we check it's validity, this means checking that all depdencies are the same, |
| 83 | +# the pkgimg was created for the right set of compiler flags, and that all source code that was used |
| 84 | +# to create this pkgimg is the same. When a CodeInstance is inside a pkgimg we can extend the chain of |
| 85 | +# validity even for GPU code, we cannot verify a "runtime" CodeInstance in the same way. |
| 86 | +# |
| 87 | +# Therefore when we see a compilation request for a CodeInstance that is originating from a pkgimg |
| 88 | +# we can use it as part of the hash for the on-disk cache. (see `cache_file`) |
| 89 | + |
| 90 | +""" |
| 91 | + disk_cache() |
| 92 | +
|
| 93 | +Query if caching to disk is enabled. |
| 94 | +""" |
64 | 95 | disk_cache() = parse(Bool, @load_preference("disk_cache", "false"))
|
65 | 96 |
|
66 | 97 | """
|
|
175 | 206 | ondisk_hit = false
|
176 | 207 | @static if VERSION >= v"1.11.0-"
|
177 | 208 | # Don't try to hit the disk cache if we are for a *compile* hook
|
178 |
| - if ci !== nothing && obj === nothing && disk_cache() # TODO: (Should we allow backends to opt out?) |
| 209 | + # TODO: |
| 210 | + # - Sould we hit disk cache if Base.generating_output() |
| 211 | + # - Should we allow backend to opt out? |
| 212 | + if ci !== nothing && obj === nothing && disk_cache() |
179 | 213 | path = cache_file(ci, cfg)
|
180 | 214 | @debug "Looking for on-disk cache" job path
|
181 | 215 | if path !== nothing && isfile(path)
|
|
0 commit comments