Reuse a fit's CSV metadata on subsequent reads
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- r
- Ambito
- performance
Direzione di ricerca
Start by reading read_cmdstan_csv() and tracing how CmdStanMCMC and CmdStanGQ call it for repeated reads; the issue names these entry points but not specific files or tests. The proposed change separates metadata merging from reading and reuses raw-name metadata on later reads. Done means subsequent reads on a fit skip rescanning its CSV files while the exported function keeps the same arguments and return value; run relevant tests for CSV reads and both fit classes.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I noticed then when reviewing #1312 and I had Claude run some tests and help generate this report.
read_csv_metadata() greps every chain file for its comment lines, so the cost of reading the metadata grows with the number of draws even though the metadata is a few hundred lines. Every read_cmdstan_csv() call pays it per file: every $draws() on a variable not yet read, every $summary() and $sampler_diagnostics() on a fresh fit, and as_cmdstan_fit().
Measured on macOS with CmdStan 2.40.0, 4 chains, 1000 draws, medians of 5:
| per chain file | 4 metadata scans | one-variable read_cmdstan_csv() call |
|---|---|---|
| 10 parameters, 0.16 MB | 0.12 s | 0.15 s |
| 1000 parameters, 11 MB | 0.44 s | 0.91 s |
So the scan is most of a read on a small fit and about half on a large one, roughly 10 ms per MB of CSV on each read.
The fix is for a fit to reuse its own metadata: after the first read the fit holds the merged metadata and its files don't change, so later reads pass it back to the reader and skip the scan. That leaves one scan per fit, on the first read.
Possible design: the parse-and-merge loop in read_cmdstan_csv() becomes merge_csv_metadata(files), returning the merged metadata with the per-chain inverse metric and step size lists. The body of read_cmdstan_csv() moves to an internal function with a csv_metadata argument that skips the merge when given one and returns it, and the exported function stays a wrapper with the same arguments and return value. CmdStanMCMC and CmdStanGQ (the two classes that read more than once) store the merged metadata on the first read and pass it on later ones. The processed metadata the fit already stores can't be handed back directly: the reader selects columns by the raw CSV names (theta.1) and the fit's copy has the repaired ones (theta[1]).
- Lingua principale
- R
- Stelle
- 162
- Fork
- 69
- Merge medio
- 1g 9h
- PR unite (30g)
- 49
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di stan-dev/cmdstanr
-
internal-code
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
stan-dev/cmdstanr#506 · 7 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Exposing a function that returns an array of tuples fails to compileForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
I maintainer di solito rispondono entro 1 giorno
-
feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
stan-dev/cmdstanr#1175 · 1 commento · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
CmdStanR 1.0 releaseAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
stan-dev/cmdstanr#1059 · 8 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di stan-dev/cmdstanr
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
bennettoxford/opencodecounts#170 ·
-
bug complexity::1-low effort::1-hours priority::2-should
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
jumpingrivers/audit.base#61 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Pascal-Kueng/dyadMLM#92 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
urbio-ecology/urbioconnect#170 ·
-
bug new windows
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno