缓存 sccache 探测结果避免重复阻塞
在当前 dev 编排进程内复用 sccache wrapper 探测结果 避免 API 与 worker 重启重复同步等待 同步更新排障文档
This commit is contained in:
+11
-1
@@ -146,6 +146,8 @@ function applyLocalFfmpegEnv(env, platform = process.platform) {
|
||||
return env;
|
||||
}
|
||||
|
||||
const localSccacheProbeCache = new Map();
|
||||
|
||||
function resolveLocalDevRustcWrapperBypass(options = {}) {
|
||||
if (process.platform !== 'win32') {
|
||||
return '/usr/bin/env';
|
||||
@@ -154,6 +156,12 @@ function resolveLocalDevRustcWrapperBypass(options = {}) {
|
||||
const sccacheAvailable =
|
||||
options.sccacheAvailable ??
|
||||
(() => {
|
||||
const cacheKey = `${process.platform}:sccache`;
|
||||
const cached = localSccacheProbeCache.get(cacheKey);
|
||||
if (cached !== undefined) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const result = spawnSync('sccache', ['rustc', '-vV'], {
|
||||
cwd: repoRoot,
|
||||
encoding: 'utf8',
|
||||
@@ -161,7 +169,9 @@ function resolveLocalDevRustcWrapperBypass(options = {}) {
|
||||
windowsHide: true,
|
||||
timeout: options.sccacheProbeTimeoutMs ?? 10_000,
|
||||
});
|
||||
return !result.error && result.status === 0;
|
||||
const available = !result.error && result.status === 0;
|
||||
localSccacheProbeCache.set(cacheKey, available);
|
||||
return available;
|
||||
})();
|
||||
return sccacheAvailable ? 'sccache' : '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user