perf(corpus): faster remote sessions, with metadata tables cached by sha256 (#64) #82

Merged
jared merged 2 commits from perf/remote-metadata-cache-64 into main 2026-11-12 21:49:45 -05:00
2 Commits
Author SHA1 Message Date
jaredandClaude Opus 5.5 8b92ce33a5 feat(corpus): cache the metadata tables by sha256 between sessions (#64)
R-CMD-check / check (push) Successful in 5m9s
R-CMD-check / check (pull_request) Successful in 4m53s
R/cache.R was a stub, so a remote session read the ten metadata tables
(about 3 MB) over HTTP every time. cog_open() now keeps them in
USCOGDATA_CACHE_DIR/corpus/ and points the metadata views there. A
cached file is used only while its sha256 matches the session's manifest;
a download is checked before it replaces anything. Any failure (an HTTP
error such as Hugging Face's 429, a mismatch, an unwritable directory)
falls back to remote reads with a message. A local corpus is read in place
and never cached. The yearly partitions stay remote; cog_mirror() is
still the tool for repeat work on them.

Against the public corpus, 2026-11-12, one run each, fresh cache:

  session open   1.76 s cold -> 0.38 s warm
  first query    1.16 s cold -> 0.68 s warm

cog_spending() for Madison (552025209777), 2012 and 2020, returns the same
46 rows and the same digest as main. Live-corpus tests pass.

Closes #64

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 21:23:58 -05:00
jaredandClaude Opus 5.5 455ae2f177 perf(corpus): cache HTTP file metadata for the life of a session (#64)
On the remote path every CREATE VIEW and every query re-requested the same
file metadata over HTTP. Against the public Hugging Face corpus on 2026-11-12
(one run per arm, from this Mac), turning on DuckDB's
enable_http_metadata_cache moved:

  session open             5.6 s -> 1.6 s
  first one-year query     1.2 s -> 0.8 s
  same query again         0.55 s -> 0.02 s

parquet_metadata_cache alone changed nothing measurable, so it stays off.
The cache is per connection, so nothing persists between sessions; that half
of #64 is still open. Live-corpus tests pass with the setting on.

Refs #64

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 20:54:37 -05:00