Partition-level caching: R/cache.R is still a stub, and the remote path pays for it every session #64
Open
opened 2026-08-10 19:10:59 -04:00 by jared
·
0 comments
No Branch/Tag Specified
main
ci/mirror-canonical-tags
chore/release-47-badges-mirror-pr
docs/readme-perf-remeasure-56
feat/pagination-search-balances-57
feat/duckdb-threads-60
feat/cohort-predicates-58
fix/windows-backslash-paths
ci/mirror-to-github
ci/github-actions-matrix
feat/public-release-0.3.0
chore/fixture-sb203
ci/apt-https
fix/pushdown-pagination
feat/all-categories-37
fix/partial-coverage-signposting-9
fix/schema-v7
fix/cog-categories-balance-subtype
feat/cog-balances-25
feat/revenue-concepts-12
feat/expenditure-concepts-11
feat/coverage-disclosure-13
feat/complete-argument-18
fix/kodor-batch-14-15-16
fix/all-scoped-series-breaks-19
fix/regen-fixture-corpus-18
test/walkthrough-findings
feat/expenditure-concept
fix/3-url-trailing-slash
feat/phase-r3-signposting
fix/fixture-option-b-aggregates
feat/phase-r2-harmonization
feat/phase-r1-forward
feat/cog-gov-search-basket-mode
v0.4.0
Labels
Clear labels
kodor
kodor/feature-proposal
kodor/fix
kodor/needs-review
kodor/triaged
madison-walkthrough
severity/high
severity/low
severity/medium
south-guide
verdict/defect
verdict/definitional
kodor
kodor/feature-proposal
kodor/fix
kodor/needs-review
kodor/triaged
Kodor should process this issue
Kodor has written a feature proposal
Kodor should implement a fix (assigned to Kodor)
Kodor's work or failure needs Jared's review
Kodor has already triaged this issue (skip)
Surfaced while building the client-facing Southern API guide
needs
human
Cannot move without a person -- a decision, a check an agent cannot make, something outside the repo
origin
client
Came from a client ask
origin
obligation
Created by a change elsewhere
origin
review
Came from human review
origin
roborev
Promoted from a roborev finding
type
chore
Maintenance with no behaviour change
type
debt
Owed work -- docs, tests, cleanup a change obligated
type
decision
Needs a decision before work can proceed
type
defect
Something is wrong
type
feature
New capability
ws
api
Query verbs and results
ws
corpus
Corpus, mirror, provenance
ws
docs
Vignettes and guides
Assign a task to kodor
Kodor thinks this needs a feature.
Kodor should fix this
Kodor thinks the user is ready to review this.
Kodor is done with this issue.
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Civilytics/uscogdata#64
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Carried out of the #56 performance pass, which named this "likely the single
highest-leverage change" on the remote path and then deferred it. Filing so it survives
that issue closing.
The finding
R/cache.Ris a six-line stub:USCOGDATA_CACHE_DIRtherefore holds exactly one file —manifest.json. Nothing else iscached between sessions, so every query goes back to the network, and every session
re-pays the cost of touching partitions it touched last time.
Why it is the leverage
The #56 pass established that the reader's cost on the default (remote) path is dominated
by HTTP, not by the R pipeline: the same
cog_spending()call is 66 ms against a localmirror and 3.9 s remote, ~50–60x. Everything else the pass looked at — provenance
assembly, crosswalk joins, the suggestion and suppression machinery — sums to tens of
milliseconds and cannot move that number. Caching bytes locally is the only thing in this
package that addresses the actual cost.
Measured on
efronagainst the live corpus (schema v7,pipeline_commit 3d28ddd), freshR session per arm, Madison WI:
Two things that table shows which the issue text should not lose:
first result. That is the manifest fetch plus registering 23 SQL views over HTTP.
getting value from holding parquet footers in memory. A persistent cache would extend
that across sessions instead of discarding it at every exit.
Shape
Whatever is built should decide explicitly:
first-touch win) versus whole partitions (190 MB, at which point it converges on
cog_mirror()).sha256, so correctnessis available without guessing. Use it; do not invent a TTL.
cog_mirror()with better ergonomics. A serious answer mightbe "no new cache; make mirroring the documented default for repeat work" — the README
now says outright that a mirror is dramatically faster. That would be a legitimate
resolution of this issue rather than a dodge, and it is cheaper than building a cache.
Not a blocker
Filed as follow-up, not as a release gate.
cog_mirror()already gives a user the wholewin in one function call, and the README documents it. This is about the default path
being better for people who never mirror.
Related: #56 (the pass this came from), cog_pipeline#93 (row-group layout, the other half
of the remote-read cost, shipped and published).