mirror of
https://github.com/UniXNU/NativeMetal.git
synced 2026-11-21 02:41:29 +03:00
fix: keep the shader cache inside Metal's cache directory
In the user cache directory the pipeline cache now sits in com.apple.metal/m2v. A sandboxed process may write there whenever its profile lets Metal cache shaders. macOS's iconservicesagent could not write <cache>/m2v (thousands of denials), compiled every pipeline again at each launch and was killed at its memory limit within seconds, over and over. Not run on hardware yet.
This commit is contained in:
@@ -198,6 +198,11 @@ static id clientDevice(unsigned port) {
|
||||
for (unsigned i : {2u, 0u, 1u}) {
|
||||
if (device) break;
|
||||
if (!candidates[i][0]) continue;
|
||||
// In the user cache directory the cache sits inside Metal's own shader cache directory (com.apple.metal): a sandboxed process may
|
||||
// write there whenever its profile lets Metal cache shaders at all (macOS iconservicesagent: its profile allows METAL_CACHE_PATH
|
||||
// and denied every write to <cache>/m2v, so each of its launches compiled every pipeline again and it was killed at its memory
|
||||
// limit within seconds).
|
||||
if (i == 0) {strlcat(candidates[i], "com.apple.metal", sizeof candidates[i]); mkdir(candidates[i], 0700); strlcat(candidates[i], "/", sizeof candidates[i]);}
|
||||
if (i != 2) strlcat(candidates[i], "m2v", sizeof candidates[i]);
|
||||
mkdir(candidates[i], 0700);
|
||||
if (access(candidates[i], W_OK) != 0) continue;
|
||||
@@ -458,6 +463,7 @@ static id deviceForPort(unsigned port) {
|
||||
for (unsigned i : order) {
|
||||
if (device) break;
|
||||
if (!candidates[i][0]) continue;
|
||||
if (i == 0) {strlcat(candidates[i], "com.apple.metal", sizeof candidates[i]); mkdir(candidates[i], 0700); strlcat(candidates[i], "/", sizeof candidates[i]);} // as for the clients below
|
||||
if (i != 5) strlcat(candidates[i], "m2v", sizeof candidates[i]);
|
||||
mkdir(candidates[i], 0700);
|
||||
if (access(candidates[i], W_OK) != 0) continue;
|
||||
|
||||
Reference in New Issue
Block a user