Merge fix/kvb-org-queue/footprint-per-command into master
🎯 Fix: 93 % 💥 Break: 5 % 💸 Cost: 99 % ⏱️ Time: 100 % 🛡️ Security: 100 % 🏆 Score: 89 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
e52db1dca0
3 files changed
+17
-15
No files matched your search
@@ -58,8 +58,7 @@ From the last 30 days, once 5 runs exist:
|
|||||||
- per signature, the disk need is p90 disk taken plus 1 GB;
|
- per signature, the disk need is p90 disk taken plus 1 GB;
|
||||||
- per kind, the slot limit is how many p90 RAM and CPU shares fit between the
|
- per kind, the slot limit is how many p90 RAM and CPU shares fit between the
|
||||||
median load at the grant and `load_limits`, at least 1;
|
median load at the grant and `load_limits`, at least 1;
|
||||||
- per job, the footprint is the larger p90 share of its kind and of its
|
- per job, the footprint is its signature's p90 share, else its kind's.
|
||||||
signature, else the largest of its kind.
|
|
||||||
|
|
||||||
Until then the seeds hold: `slot_need_gb[kind]` for disk, 1 slot per kind,
|
Until then the seeds hold: `slot_need_gb[kind]` for disk, 1 slot per kind,
|
||||||
the whole budget as footprint: it runs alone.
|
the whole budget as footprint: it runs alone.
|
||||||
|
|||||||
@@ -212,21 +212,14 @@ def footprint(kind: str, name: str, signatures: dict[str, dict], kinds: dict[str
|
|||||||
kinds: the kind map of learn().
|
kinds: the kind map of learn().
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
{ram, cpu}: the larger of the kind's p90 share and the signature's, at
|
{ram, cpu}: the signature's p90 share once learned, else the kind's, at
|
||||||
least MIN_SHARE_PERCENT; a signature not learned yet takes the largest
|
least MIN_SHARE_PERCENT. None while the kind is not learned yet.
|
||||||
learned share of its kind. None while the kind is not learned yet.
|
|
||||||
"""
|
"""
|
||||||
if kind not in kinds or kinds[kind]["ram_share"] is None:
|
if kind not in kinds or kinds[kind]["ram_share"] is None:
|
||||||
return None
|
return None
|
||||||
own_kind = kinds[kind]
|
own = signatures.get(name)
|
||||||
if name in signatures and signatures[name]["ram_share"] is not None:
|
source = own if own and own["ram_share"] is not None else kinds[kind]
|
||||||
peers = [signatures[name]]
|
return {resource: max(MIN_SHARE_PERCENT, source[f"{resource}_share"]) for resource in RESOURCES}
|
||||||
else:
|
|
||||||
peers = [s for s in signatures.values() if kind in s["kinds"] and s["ram_share"] is not None]
|
|
||||||
return {
|
|
||||||
resource: max([MIN_SHARE_PERCENT, own_kind[f"{resource}_share"], *(peer[f"{resource}_share"] for peer in peers)])
|
|
||||||
for resource in RESOURCES
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def seed_ram(kinds: dict[str, dict]) -> float:
|
def seed_ram(kinds: dict[str, dict]) -> float:
|
||||||
|
|||||||
+11
-1
@@ -308,7 +308,17 @@ class TestHistory(unittest.TestCase):
|
|||||||
crowded = [history_row(n, mem_before=90, mem_max=95) for n in range(5)]
|
crowded = [history_row(n, mem_before=90, mem_max=95) for n in range(5)]
|
||||||
self.assertEqual(self.learn(crowded)[1]["test"]["limit"], 1)
|
self.assertEqual(self.learn(crowded)[1]["test"]["limit"], 1)
|
||||||
|
|
||||||
def test_footprint_takes_the_larger_of_kind_and_signature_at_least_the_minimum_and_none_for_a_new_kind(self):
|
def test_a_light_command_of_a_heavy_kind_and_an_unlearned_one_are_not_booked_at_the_heaviest_share(self):
|
||||||
|
signatures = {
|
||||||
|
"skills: make test": {"ram_share": 3.3, "cpu_share": 4, "kinds": {"test"}},
|
||||||
|
"gate.py hold": {"ram_share": 42.6, "cpu_share": 93.5, "kinds": {"test", "test-nostack"}},
|
||||||
|
}
|
||||||
|
kinds = {"test": {"ram_share": 35.2, "cpu_share": 83.6}, "test-nostack": {"ram_share": 5.6, "cpu_share": 73.8}}
|
||||||
|
footprint = self.history.footprint
|
||||||
|
self.assertEqual(footprint("test", "skills: make test", signatures, kinds), {"ram": 3.3, "cpu": 4})
|
||||||
|
self.assertEqual(footprint("test-nostack", "core: docker build", signatures, kinds), {"ram": 5.6, "cpu": 73.8})
|
||||||
|
|
||||||
|
def test_footprint_takes_the_learned_signature_else_the_kind_at_least_the_minimum_and_none_for_a_new_kind(self):
|
||||||
small = [history_row(n, signature="make test", mem_max=25, cpu_max=20) for n in range(5)]
|
small = [history_row(n, signature="make test", mem_max=25, cpu_max=20) for n in range(5)]
|
||||||
big = [
|
big = [
|
||||||
history_row(n + 5, kind="quality-high", signature="make verify-test", mem_max=80, cpu_max=90)
|
history_row(n + 5, kind="quality-high", signature="make verify-test", mem_max=80, cpu_max=90)
|
||||||
|
|||||||
Reference in new issue
Block a user