Worker memory: report available memory, not free memory (#30)
CI / Test (jest) (pull_request) Successful in 19s
CI / Lint (eslint) (pull_request) Successful in 21s
CI / Security (npm audit) (pull_request) Successful in 11s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m54s
CI / Integration (api) (pull_request) Successful in 2m36s
CI / UI (playwright) (pull_request) Successful in 2m15s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m29s
CI / Test (jest) (pull_request) Successful in 19s
CI / Lint (eslint) (pull_request) Successful in 21s
CI / Security (npm audit) (pull_request) Successful in 11s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m54s
CI / Integration (api) (pull_request) Successful in 2m36s
CI / UI (playwright) (pull_request) Successful in 2m15s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m29s
os.freemem() leaves out the page cache, so a healthy Linux box looks full: the production worker (CT 153, 512 MB) has 4 MB free but 449 MB available, and showed as 99% used instead of about 12%. - worker: heartbeat metadata adds availableMem from MemAvailable in /proc/meminfo (falls back to os.freemem()); freeMem stays for old servers. - Workers tab and dashboard compute used memory from availableMem when present, from freeMem for workers that predate it. - Unit tests for the meminfo parsing and the fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2c1eb712f2
commit
789e5651c8
4 files changed
+36
-5
No files matched your search
@@ -198,3 +198,14 @@ describe('connection resilience (#1, #29)', () => {
|
||||
expect(w.connectWebSocket).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('availableMemory (#30)', () => {
|
||||
const { availableMemory } = require('../worker/worker');
|
||||
test('reads MemAvailable (page cache counts as available), in bytes', () => {
|
||||
const meminfo = 'MemTotal: 524288 kB\nMemFree: 4460 kB\nMemAvailable: 459733 kB\n';
|
||||
expect(availableMemory(meminfo)).toBe(459733 * 1024);
|
||||
});
|
||||
test('falls back to os.freemem() without a MemAvailable line', () => {
|
||||
expect(availableMemory('MemTotal: 1 kB\n')).toBe(require('os').freemem());
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user