Skip to content

[ITG] Implement ITG cache to store reverse dependencies of targets#76

Open
yushan8 wants to merge 2 commits into
mainfrom
itg-cache
Open

[ITG] Implement ITG cache to store reverse dependencies of targets#76
yushan8 wants to merge 2 commits into
mainfrom
itg-cache

Conversation

@yushan8
Copy link
Copy Markdown
Contributor

@yushan8 yushan8 commented Apr 16, 2026

Why?

Implement ITG cache to store reverse dependencies of targets. Storing the ITG graph allows us to search for the commit closest to the base commit and incrementally recompute the target graph of the commit if it's ITG applicable.
The cache is stored in a separate folder by date so when we load the list of cached ITG graphs, it will only load all the entries for the day.

What?

core/storage — Added List(ctx, dir) to the Storage interface

  • storage.go — Added List(ctx context.Context, dir string) ([]string, error) to the Storage interface

  • memstorage.go — Filters keys by strings.HasPrefix(key, dir)

  • disk/disk.go — Walks rootDir/dir, returns paths relative to rootDir; non-existent directory returns empty without error

  • storagemock/storagemock.go — Added List mock method and recorder

  • changedtargetsandedgesreader_test.go — Updated errStorage and nilResponseStorage stubs to satisfy the new interface
    Storage-backed cache for OptimizedGraph entries, keyed by (remote, commit_timestamp, sha) and stored under
    itg/{remote}/{date}/{timestamp}_{sha}.

  • Put — gob-encodes the graph and writes to storage; skips if the key already exists

  • Get — downloads and gob-decodes the graph

  • FloorKey — lists all keys under the remote's prefix, parses timestamps, and binary-searches for the latest entry with commit_timestamp ≤ targetTimeSecond

Test Plan

unit tests

Issue

@yushan8 yushan8 marked this pull request as ready for review April 16, 2026 22:45
@yushan8 yushan8 requested review from a team as code owners April 16, 2026 22:45
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants