Nineteen seconds after the end

Richard’s call on #1156 was “2 for estimate, 3 for actual”. A Spot job is priced at the catalog’s Spot rates when it ends, and the bill replaces that estimate once the export holds it. Spot is about to become the default for training, so these figures will soon be most of the ledger.

The rates reproduce the bill. A Spot job’s bill comes in two halves. The machine is billed at Compute Engine’s Spot prices over the VM’s whole life; Vertex’s management fee and the boot disk are billed over the time the job ran. I read every price from the Cloud Billing Catalog and checked each against the smoke’s lines. At the billed seconds the table gives $0.556095 against $0.556106; the gap is each line rounded to the micro-dollar. The disk needed one more look. Google spreads a GiB-month over the month’s real length: 720 hours in September, 744 in October. Only that fits both months’ bills.

The bound ran the other way. The decision expected create-to-end to be an upper bound on the machine’s time, since Google doesn’t bill the wait for capacity. On the smoke it was short. The VM billed 797 seconds, and Vertex’s create-to-end is 778. The VM goes on billing for 19 seconds after the job ends, and those 19 seconds are the whole of the estimate’s 2.1% gap. So an estimate can land on either side of its bill: above it when a job waits for capacity, below it by the shutdown otherwise. That is fine for an estimate the bill will replace, but it is not a bound, and the PR says so.

Per job, by a label of its own. Every job of a resumed run carries the run’s label, so a run’s bill can’t be split by job afterwards. Vertex books a job’s rows in the hour it ends, and a stop followed by a quick resume can share that hour. So each new Spot job now carries a label of its own, and the sync sums exactly that job’s rows. A job from before the label is reconciled only if it is its run’s one job, which the smoke is. Anything else keeps its estimate, and its record says why.

Two things the brief didn’t mention.

  • The sync would have counted part of every Spot job twice. A Spot job’s GPU line maps to Vertex and was already dropped at ingest. Its cores and RAM bill under Compute Engine, though, and would have landed as “other” beside the Vertex event that already counts them. No sync has run since May, so nothing was doubled yet. Vertex labels those rows as its own training’s, and they are now dropped too.
  • The recorder’s branch for a job with no submission stub inserted its row and never committed it, so any such job lost its cost record. With the new commit removed, its test fails, which is how I know the loss was real and not a reading of the code.

What the review caught. I had written “the bill replaces the estimate within hours” and given the reconcile a 30-day window. Both assumed someone runs the sync. Nobody has since May 26: the sync is manual, by Richard’s choice. So a Spot job missed by a sync for a month would have kept its estimate forever without a word, and my own end-to-end test would have started failing on November 20. Now nothing ages out: the jobs never checked go first, then those checked longest ago. The reviewer also found two quieter things:

  • A worker started before this change keeps the old pricing module in memory. Importing the new recorder there failed on the new names, and both callers swallow the error, so a job would have had no cost record at all, on demand too. The new names are now looked up only when a Spot job is priced.
  • The record I rescued for a job with no stub was priced at $0, because the finalizer never passes the machine. Vertex reports the machine, and now that fills the gap.

It broke 28 guards on purpose; 7 survived the tests. Each now has one, and breaking any of 14 is caught.

The workers load this on their next draining restart. The next manual sync gives the smoke its actual: $0.556106.