Repository navigation
perf(ci): loader in parallelo prima del build (4 worker) - #308
Merged
Merged
Conversation
This was referenced Nov 25, 2026
Il deploy #307 ha misurato il problema: step Build 704 s, di cui 694 s di 58 loader eseguiti uno alla volta da observable build (12,5 min totali). scripts/prefetch.py legge il report di invalidate_cache.py, esegue i loader in un pool di 4 processi e scrive src/.observablehq/cache/data/<loader>.json: il build trova la cache e non li riesegue (verificato: 'load /data/elezioni-regionali.json [fresh] success in 0ms'). Misurato su 8 loader: 32,7 s con 1 worker, 15,8 s con 4. In CI: 694/4 ~ 175 s + render ~25 s. Un loader che fallisce o non produce JSON ferma il prefetch: nessun fallback silenzioso.
Il prefetch era inserito **sopra** la cancellazione dei metadati: `catalog` e `themes` restavano fuori dai worker e venivano ricostruiti in sequenza dentro `observable build`. Sul deploy del 29/11 `themes` costava 24 s in CI. Ora la cancellazione avviene prima e i due nomi entrano nel report che il prefetch legge (con `grep -qx` per non duplicarli se erano già invalidati). Ordine risultante: invalida → metadati → prefetch → build. Verificato: i 7 test di `prefetch.py` passano, e il prefetch sul report `catalog, themes` esegue entrambi in 1 s con 4 worker.
Gabrymi93
force-pushed
the
perf/prefetch-parallel
branch
from
November 29, 2026 15:39
e67b2d9 to
7393e04
Compare
I loader e le schede leggono i parquet via DuckDB (`safe_connect`), quindi
il token finisce nell'header e distingue questa build dalle altre. Senza,
il build risulta `dcl-unknown/0`: con 58 loader e un prefetch parallelo è
il consumatore più difficile da attribuire a posteriori.
Formato conforme al contratto DCL_CLIENT_NAME di lab-connectors
(^[A-Za-z0-9][A-Za-z0-9._/-]{0,80}$), con run_id per correlare log e run.
4 tasks done
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.
Sintesi
Il deploy di #307 ha misurato dove finiscono i minuti: step Build 704 s, di cui 694 s di 58 loader eseguiti uno alla volta da
observable build. Non è il full refresh a essere lento: è che Observable Framework non parallelizza i data loader. Qui girano in 4 processi e scrivono la cache che il build riusa.Misure (dallo stesso run)
45667155098)Build Observable FrameworkCome funziona
.tmp+replace): il build non legge un file a metà.!= 0o non produce JSON ferma il prefetch → il deploy è rosso. Nessun fallback silenzioso: era il punto di fix(data): tre pagine rotte, loader senza output vuoto, audit dei dati #307.warm_registry()pre-caricatopic_indexuna volta, evitando 4 fetch identici all'avvio.Verificato che il build riusa davvero la cache appena scritta:
Misura del guadagno
Su 8 loader reali (stessa macchina, stessa cache fredda):
In CI: 694 s / 4 ≈ 175 s + render (~25 s) → il full refresh passa da ~12,5 min a ~4-5 min. Il guadagno è limitato dal loader più lento (9,6 s sul subset) e dal runner a 4 core, per questo 4 worker e non 8.
Cosa non cambia
Verifica
tests/test_prefetch.py): output in cache, loader inesistente, exit != 0, JSON non valido, un fallito non ferma gli altri ma viene riportato, lista vuota.npm run audit→ 0 errori, 0 avvisi.[fresh] ... in 0ms.Limiti
_util/_registry/_views/requirements, o su unfull_refresh=true.