PublicationAwaiter reads the checkpoint every poll period even when nothing is waiting

Aperta
#1,249 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@grempe ci sta già lavorando.

Dal 22/10/2026.

  • #1250 di @grempe — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
go

Direzione di ricerca

Read await.go, especially pollLoop and the PublicationAwaiter documentation, then run the linked TestAwait_noReadsWhileIdle repro from await_test.go. The issue describes counting blocked Await calls and skipping reads and broadcasts when none are waiting; done means the test passes with no checkpoint reads while idle or after Await returns. A linked open pull request already addresses this work.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Reviewed and filed by me, a human. The investigation, repro and fix were developed with the assistance of an AI coding agent.

Summary: the PublicationAwaiter's poll loop reads the checkpoint every poll period for as long as its context lives, whether or not any Await call is waiting. The type's doc says it "will fetch checkpoints whenever it has clients waiting" (await.go:49). That costs a read every poll period, even for a log that receives no writes:

With the S3 or GCS drivers, each read is a GET. At the listed prices (October 2026), that's about $10 a month per process on S3 Standard or GCS Standard at a 100ms poll period, and about $5 at 200ms; on Cloudflare R2, about $5.70 a month at 100ms beyond its free 10 million reads. Small, but paid by every instance for doing nothing.

Where (main at 012e9e0): pollLoop reads on every tick, at await.go:136–138, and then broadcasts.

Repro (no external services). In a checkout of main:

git fetch https://github.com/grempe/tessera awaiter-idle-polling && git checkout FETCH_HEAD -- await_test.go
go test . -run TestAwait_noReadsWhileIdle -v

The test runs under synctest, with a 10ms poll period:

  1. it waits a second with nothing waiting;
  2. it calls Await once;
  3. it waits another second.

On main (=== RUN lines omitted; each count is 99 or 100, depending on where the last tick falls):

    await_test.go:381: read the checkpoint 99 times in 1s with nothing waiting, want 0
    await_test.go:394: read the checkpoint 100 times in the 1s after Await returned, want 0
--- FAIL: TestAwait_noReadsWhileIdle (0.00s)
FAIL
FAIL	github.com/transparency-dev/tessera	0.197s
FAIL

Fix: I'll open a PR from the same branch.

  • It counts the Await calls that are blocked, under the existing mutex, and skips the read and the broadcast while there are none.
  • Why that's safe: a waiter that arrives finds the last checkpoint read. Its size can only be smaller than the log's current one, so it can't satisfy a waiter wrongly, and the next poll reads a fresh one.
  • Latency: for the usual call pattern, awaiting a just-added entry, it's unchanged: up to one poll period either way.

#1195 and #1196 rework Await in the same file. This change is small, and either can be rebased on the other.

Lingua principale
Go
Stelle
262
Fork
64
Merge medio
1g 6h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di transparency-dev/tessera

Tutte le issue di transparency-dev/tessera

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.