Skip to content

Cache initialize_diffcheck cost - #28

Open
ArjunS07 wants to merge 13 commits into
spec/ingestion-windowfrom
lsv-cache
Open

Cache initialize_diffcheck cost#28
ArjunS07 wants to merge 13 commits into
spec/ingestion-windowfrom
lsv-cache

Conversation

@ArjunS07

Copy link
Copy Markdown

During setup.sh, LSV invokes initialize_diffcheck. This:

  1. Runs each benchmark once, to get the dependency graph
  2. Get timing measurements for all impactable benchmarks

We now introduce 2 new database tables:

  • lsv_deps_cache keeps the survey. This is correct for all CPUs.
  • lsv_baseline_cache: keeps the baseline timings. Its key has 11 parts. The key includes the CPU model from inside the container. A timing is used again only on the same hardware.

For every task, when the cache is enabled, the runner (which launches containers) does the following

  1. It calls _fetch_deps_db(owner, repo, issue_number), which queries lsv_deps_cache.
    • Hit: include the survey file into the image (environment/cache/lightspeed_deps.db)
    • Miss: put an empty cache/ directory with a .gitkeep, so the Dockerfile COPY cache/ still has a source and the build does not fail.
  2. The runner includes datasmith login data and the 11-part key into setup.sh/test.sh.

The container then spawns. It:

  1. Reads the survey from the image.
  2. Reads the baseline from the database
    If any one result is absent, the container measures up to sufficiency again.

The only thing that can write the cache is an oracle run.

Resource-keyed cache of LSV baseline timings so harbor_healthcheck can skip
the base-commit timing pass on repeat trials. Populated by the oracle trial,
read by every trial. Private (grafana_ro SELECT only), no FK (advisory).
…hit)

Stage the pre-baked deps DB, fetch resource-keyed baselines from
lsv_baseline_cache on datasmith's Supabase, and pass force=False only on a
full hit so initialize_diffcheck skips the survey+timing passes. Any miss or
missing creds falls through to force=True (unchanged behaviour). Records the
key in lsv_resource_attrs.json and hit/miss in lsv_cache_state.json for the
writeback, and exports FORMULACODE_BASELINE_FROM_CACHE for invariant #20.
Preserves the baseline_sha breadcrumb and --repeat/--warmup-time.
Oracle-only writeback that upserts freshly measured baselines into
lsv_baseline_cache when lsv_init recorded a miss. Reads the resource key from
lsv_resource_attrs.json (single source of truth with lsv_init) and the timings
from the deps DB baseline table. Stdlib only; best-effort, never fails the
trial. Not yet baked/invoked -- wiring follows.
Add a render_env dict that renders as shell-quoted export lines in setup.sh and
test.sh, so the LSV cache creds and resource key reach lsv_init (setup.sh, which
Harbor's [verifier.env] misses on Daytona) and the writeback (test.sh). Register
a shell_quote Jinja filter, thread render_env through generate_task, bake
lsv_cache_writeback.py into the image, and invoke it oracle-only after the
reward parser. render_env defaults to empty -> byte-identical output when the
runner has not enabled the cache.
Inject datasmith Supabase creds (DATASMITH_-prefixed) and the resource key
(env, container_name, image_digest, machine_class/docker_host_id, cpu/mem pins)
into each task's render_env so lsv_init can look baselines up and the writeback
can upsert them. Unify the trial cpu/memory pins with the cache key via
_trial_pins so the key describes the hardware the trial actually got (memory
default stays 32 GB on both environments). Gated on DATASMITH_LSV_CACHE_ENABLED
and the presence of creds; off => byte-identical to prior behaviour.
@ArjunS07

Copy link
Copy Markdown
Author

This requires running the following migrations on the Datasmith postgres @atharvas :

  1. 00031_lsv_baseline_cache.sql
  2. 00032_lsv_deps_cache.sql.
    This add new tables so should be non destructive

Merging without these migrations will lead to no-ops and print a warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant