Monitor: the drive-temperature reader (every physical drive, from the first second) runs only while the Monitor is open, not at app start (#4661)
This commit is contained in:
1 parent
ea52e55cd7
commit
68718c33fa
3 files changed
+21
-2
No files matched your search
@@ -4,7 +4,7 @@ import { detect, cachedHardware } from './hardware.mjs';
|
||||
import { readGpuTelemetry, gpuMemoryTotals } from './device-probes.mjs';
|
||||
import { createSystemSampler } from './system-telemetry.mjs';
|
||||
import { sensorPace, WATCH_MS } from './sensor-pace.mjs';
|
||||
import { readTemperatures } from './temperature-telemetry.mjs';
|
||||
import { readTemperatures, stopTemperatures } from './temperature-telemetry.mjs';
|
||||
import { addEnergy, energyWh } from './energy-meter.mjs';
|
||||
import { state as servingState } from './serving.mjs';
|
||||
import { originalDashboard } from './monitor-dashboard.mjs';
|
||||
@@ -127,11 +127,14 @@ function tick() {
|
||||
if(!sensorsPending&&Date.now()-sensorsAt>=pace.intervalMs){
|
||||
sensorsPending=true;sensorsAt=Date.now();
|
||||
const hardware=cachedHardware()??hwCache;
|
||||
void Promise.all([readGpuTelemetry(hardware?.gpus??[],{transfer:pace.transfer}),sampleSystem(hardware?.processors??[]),(process.env.STRATA_REAL_ENGINE==='1'?readTemperatures():Promise.resolve(temperatures)).catch(()=>({cpuTempC:null,ssdTempC:null}))])
|
||||
void Promise.all([readGpuTelemetry(hardware?.gpus??[],{transfer:pace.transfer}),sampleSystem(hardware?.processors??[]),(process.env.STRATA_REAL_ENGINE==='1'&&Date.now()<watchedUntil?readTemperatures():Promise.resolve(temperatures)).catch(()=>({cpuTempC:null,ssdTempC:null}))])
|
||||
.then(([readings,system,temps])=>{state.hardware.gpus=readings;systemReading=system;temperatures=temps;})
|
||||
.catch(()=>{state.hardware.gpus=[];systemReading=null;})
|
||||
.finally(()=>{sensorsPending=false;});
|
||||
}
|
||||
/* #4661: the drive-temperature reader asks every physical drive for its temperature. Only while the Monitor is looked at, never from the first second of the app
|
||||
(on some PCs the storage queries stall the whole system); it ends a couple of minutes after the Monitor was last seen. */
|
||||
if(Date.now()>watchedUntil+120000)stopTemperatures();
|
||||
addEnergy(hardwareSnapshot().powerW,Date.now());
|
||||
const hw = state.hardware;
|
||||
const busy = state.phase === 'generating' || state.phase === 'reading' || state.phase === 'thinking';
|
||||
|
||||
@@ -122,3 +122,8 @@ export async function readTemperatures({ platform = process.platform, now = Date
|
||||
}
|
||||
return { cpuTempC: null, ssdTempC: null };
|
||||
}
|
||||
|
||||
/** Ends the Windows drive-temperature loop (the Monitor has not been open for a while); the next read starts it again. */
|
||||
export function stopTemperatures() {
|
||||
if (windowsReader) { windowsReader.stop(); windowsReader = null; }
|
||||
}
|
||||
@@ -47,3 +47,14 @@ test('the monitor uses the pace, the Monitor screen asks while it is open, and /
|
||||
const screen = await readFile(new URL('../src/screens/Monitor.tsx', import.meta.url), 'utf8');
|
||||
assert.match(screen, /api\.get\('\/api\/monitor'\)/);
|
||||
});
|
||||
|
||||
test('the drive-temperature reader starts only while the Monitor is watched and ends after it is gone (#4661)', async () => {
|
||||
const monitor = await readFile(new URL('../server/monitor.mjs', import.meta.url), 'utf8');
|
||||
assert.match(monitor, /STRATA_REAL_ENGINE==='1'&&Date\.now\(\)<watchedUntil\?readTemperatures\(\)/);
|
||||
assert.match(monitor, /stopTemperatures\(\)/);
|
||||
const { readTemperatures, stopTemperatures } = await import('../server/temperature-telemetry.mjs');
|
||||
assert.equal(typeof stopTemperatures, 'function');
|
||||
// nothing is started by importing or by stopping: on a PC that never opens the Monitor no PowerShell and no disk query exists
|
||||
stopTemperatures();
|
||||
assert.deepEqual(await readTemperatures({ platform: 'darwin' }), { cpuTempC: null, ssdTempC: null });
|
||||
});
|
||||
Reference in new issue
Block a user