Reduce host capacity headroom and remove learned usage padding
This commit is contained in:
@@ -57,6 +57,7 @@ export function ensureHostSchema(handle: Database.Database): void {
|
||||
CREATE TABLE IF NOT EXISTS ec_resource_allowances (
|
||||
scope TEXT NOT NULL, phase TEXT NOT NULL, cpu_cores REAL NOT NULL, memory_bytes REAL NOT NULL,
|
||||
samples INTEGER NOT NULL, window_start TEXT NOT NULL, observed_at TEXT NOT NULL, computed_at TEXT NOT NULL,
|
||||
usage_margin REAL NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY(scope,phase)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS ec_host_decommissions (
|
||||
@@ -71,5 +72,14 @@ export function ensureHostSchema(handle: Database.Database): void {
|
||||
if (!columns.some(column => column.name === 'last_delivered_at')) handle.exec('ALTER TABLE ec_host_operations ADD COLUMN last_delivered_at TEXT');
|
||||
const hostColumns = handle.prepare('PRAGMA table_info(ec_hosts)').all() as { name: string }[];
|
||||
if (!hostColumns.some(column => column.name === 'deleted_at')) handle.exec('ALTER TABLE ec_hosts ADD COLUMN deleted_at TEXT');
|
||||
const allowanceColumns = handle.prepare('PRAGMA table_info(ec_resource_allowances)').all() as { name: string }[];
|
||||
if (!allowanceColumns.some(column => column.name === 'usage_margin')) {
|
||||
// Existing caches include 25% padding. Preserve learned evidence while
|
||||
// removing that padding exactly once, including dormant startup models.
|
||||
handle.transaction(() => {
|
||||
handle.exec('ALTER TABLE ec_resource_allowances ADD COLUMN usage_margin REAL NOT NULL DEFAULT 1');
|
||||
handle.exec('UPDATE ec_resource_allowances SET cpu_cores=cpu_cores/1.25, memory_bytes=CAST(memory_bytes/1.25 AS INTEGER)');
|
||||
})();
|
||||
}
|
||||
initialized.add(handle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user