Show when sccache statistics come from the no-server fallback

Aperta Adatta ai principianti
#3,095 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
77/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cli, tooling

Direzione di ricerca

Inizia da Command::ShowStats in src/commands.rs e segui il fallback senza server fino al formattatore di testo in src/server.rs. Verifica come vengono preservati il fallback JSON esistente e il codice di uscita, quindi aggiungi un test mirato che distingua un server attivo con zero richieste dal fallback senza server. Il lavoro è completato quando l’output testuale indica che i contatori non sono disponibili dopo che il server smette di rispondere, mentre il comportamento JSON rimane intatto.

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

Descrizione

Observed in CI

A successful Windows job used sccache v0.20.1 to compile its Rust targets, then ran integration tests for about 14 minutes without another compiler invocation. The last logged sccache invocation was at 07:27:42 UTC (raw line 2568). Its end-of-job JSON-based summary reported zero compiler requests at 07:41:38 (raw lines 233288–233291). That job did not print the JSON effective mode, so we cannot directly identify why its daemon stopped responding. The timing matches the default 600-second idle timeout. In a separate shorter job using the same workflow and sccache version, the summary recorded 1,330 requests.

Windows job and raw log, comparison Windows job.

Bounded reproduction

In a disposable Linux shell with v0.20.1, GCC and jq available, the following isolates the daemon and reduces the idle timeout to five seconds. This small standalone sequence is derived from the source. Our observed result is the Windows job above.

set -eu
work=$(mktemp -d)
export SCCACHE_DIR="$work/cache"
export SCCACHE_SERVER_UDS="$work/sccache.sock"
export SCCACHE_IDLE_TIMEOUT=5
export SCCACHE_CACHE_SIZE=32M
trap 'sccache --stop-server >/dev/null 2>&1 || true; rm -rf -- "$work"' EXIT
printf 'int sample(void) { return 42; }\n' > "$work/sample.c"
sccache gcc -c "$work/sample.c" -o "$work/sample.o"
sccache --show-stats --stats-format=json |
  jq '{compile_requests: .stats.compile_requests, effective_cache_mode}'
sleep 7
sccache --show-stats
sccache --show-stats --stats-format=json |
  jq '{compile_requests: .stats.compile_requests, effective_cache_mode}'

The first query should report a live mode and a positive request count. After idle shutdown, the text and JSON queries print zero counters and exit successfully. The JSON mode is null. A reader of the text sees counters that look like an idle but still-running daemon's report. The human-readable output prints the effective mode only in advanced mode and when the mode is present.

The code path is the 600-second default, the idle shutdown branch, the empty fallback in ShowStats and the text formatting branch. This is separate from the JSON mode support added for issue #2842.

Workaround and suggested change

Read effective_cache_mode from JSON and report unavailable counters when it is null. For an ephemeral CI job, set SCCACHE_IDLE_TIMEOUT at least as long as the compile-to-report interval or read the counters before a long test-only phase.

In Command::ShowStats, preserve the fallback JSON and exit status, and pass the absence of a connection to the text formatter as an explicit status. For example, print a diagnostic that the server did not respond and that the counters cannot represent previous compiler activity. Test the live server with zero requests separately from the no-server fallback. An opt-in flag that fails on a missing server could also help automation that needs a reliable cache measurement.

Lingua principale
Rust
Stelle
8k
Fork
835
Merge medio
3g 6h
PR unite (30g)
60

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 mozilla/sccache

Tutte le issue di mozilla/sccache

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.