Skip to content

isb 3.1.1: egress and metrics-history CPU fixes; inline tests don't count toward the file-size ratchet - #69

Merged
knowsuchagency merged 6 commits into
mainfrom
incusd-netlink-spin
Oct 26, 2026
Merged

knowsuchagency merged 6 commits into
mainfrom
incusd-netlink-spin

Conversation

@knowsuchagency

Copy link
Copy Markdown
Contributor

Two CPU fixes found while diagnosing incusd at ~300% CPU on titan, plus a ratchet change so tests never have to shrink to fit.

Egress listing (7bdd949). The egress manager polled GET /1.0/networks?recursion=1 every 5 s. incus 7.5.1 does a full host netlink link dump for each network in that listing (23 per poll on titan), to find zero egress bridges. It now lists names and GETs only isbbrx* bridges. Test: egress::plumb::tests::listing_fetches_only_egress_bridges (fails on the old code). The bigger incus-side cost, a host dump on every /state and every filtered or recursive instance list, is upstream: lxc/incus#4249.

Metrics-history prune (ec51363). Every 60 s, OrgDb::maintain deleted empty series with NOT EXISTS (SELECT 1 FROM samples WHERE sid = series.id). The samples key starts with tier, so SQLite scanned the whole table once per series. On titan the isb-metrics-history thread spent ~12 s at 100% every minute (exa alone: 139 series × 691k rows = 11.4 s). Naming the tiers lets it seek (tier, sid): 1 ms instead of 6.7 s on a copy of exa's database, deleting the same 46 series. Test: metrics_history::tests::maintain_prunes_empty_series_by_key runs maintain over one series per tier plus an empty one, and checks the query plan. It fails on the old query and fails if a tier is left out.

Ratchet (1a68a44). The 1000-line file limit no longer counts inline #[cfg(test)] mod blocks. Budgets are lowered to the new counts: notify/mod.rs, caddy.rs, machine.rs and audit.rs drop off the list.

scripts/check.sh passes in a sandbox.

https://claude.ai/code/session_01TxiqnSSTD6K8CmxmrsJrGR

The proxy manager polls plumb::list every 5 s. `GET /1.0/networks?recursion=1`
makes incusd dump every host interface once per network it lists (22 on
titan, so 23 full RTM_GETLINK dumps of 196 links per poll), to find bridges
that are always named isbbrx<digest>. List names, then fetch only those.

Claude-Session: https://claude.ai/code/session_01TxiqnSSTD6K8CmxmrsJrGR
The samples key starts with tier, so `WHERE sid = series.id` scanned the
whole table once per series. Every minute the writer spent ~12 s at 100%
on titan (11 s for exa alone: 139 series over 691k rows). Naming the
tiers lets SQLite seek (tier, sid): 1 ms on the same data.

Claude-Session: https://claude.ai/code/session_01TxiqnSSTD6K8CmxmrsJrGR
The limit is there to keep code legible. Counting `#[cfg(test)] mod`
blocks meant a file near 1000 lines could only gain a test by losing
coverage elsewhere. Budgets lowered to the new counts: notify/mod.rs,
caddy.rs, machine.rs and audit.rs drop off the list.

Claude-Session: https://claude.ai/code/session_01TxiqnSSTD6K8CmxmrsJrGR
# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	docs/reference/rpc.md
#	sdk/python/pyproject.toml
#	sdk/python/src/isb/__init__.py
#	sdk/python/tests/test_unit.py
#	sdk/python/uv.lock
#	sdk/typescript/bun.lock
#	sdk/typescript/npm/linux-arm64/package.json
#	sdk/typescript/npm/linux-x64/package.json
#	sdk/typescript/package.json
@knowsuchagency knowsuchagency changed the title isb 3.0.1: egress and metrics-history CPU fixes; inline tests don't count toward the file-size ratchet isb 3.1.1: egress and metrics-history CPU fixes; inline tests don't count toward the file-size ratchet Oct 26, 2026
@knowsuchagency
knowsuchagency merged commit 5f48b2f into main Oct 26, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant