Repository navigation
feat(amico-run): attribute CPU cost to principal and Lab from the solve unit cgroup (#2133) - #2134
Merged
Merged
Conversation
…ve unit cgroup Measure a local solve's real CPU from its transient unit's cgroup (cpu.stat usage_usec delta, startRun to settle) instead of the engine process clock. Emit a local receipt with cpu_seconds, principal, lab, and a cost_usd priced from ~/.amico/amicode/rates.json (list_price_estimate); unmeasured when no cgroup. Add costTotals rollup by principal and Lab. Accounting never fails a run.
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2133. Replaces #2121 (closed), whose CPU measurement was wrong. Part of the central hub (ADR 0041 §5).
What: every local solve now writes a receipt carrying
cpu_secondsmeasured from the solve unit's cgroup (cpu.stat usage_usecof theamico-run-<id>unit, read before Julia spawns and again at the start ofsettle, before teardown),principalandlab(fromAMICO_PRINCIPAL/AMICO_LAB, set by the hub frontdoor later), andcost_usdonly when a human has configured~/.amico/amicode/rates.json({"cpu_usd_per_second": n}), withcost_basis: list_price_estimate. No unit/cgroup (macOS,protection: none) recordscost_basis: unmeasured, never an engine-process figure.costTotals()rolls up by principal and Lab, with an(unattributed)bucket. Accounting failure never fails a run.Why #2121 was wrong:
process.cpuUsage()counts only the engine process, but Julia is a child in its own unit, so every solve would have been costed at about zero.Verified by the director (re-run, not the implementer's report):
amico run.Behaviour changes to know about: every local run now appends a receipt (to hold the
unmeasuredcase), so two tests that assumed "no receipt for local runs" were updated;gpuTotalsnow skipsexecutor: "local"rows so GPU sums aren't inflated. No rate is set by default, so dollars appear only after a human supplies one.Needs a human: create
rates.jsonto get dollars; the hub frontdoor must setAMICO_PRINCIPAL/AMICO_LAB. Dollar figures are list-price estimates, not invoices.