Skip to content

feat: add persistent disk cache for image existence checks#790

Open
pingsutw wants to merge 3 commits intomainfrom
make-it-faster
Open

feat: add persistent disk cache for image existence checks#790
pingsutw wants to merge 3 commits intomainfrom
make-it-faster

Conversation

@pingsutw
Copy link
Member

@pingsutw pingsutw commented Mar 13, 2026

Summary

  • Adds PersistentCacheImageChecker that caches verified image URIs to ~/.flyte/cache/images/ on disk
  • After the first successful remote registry check (~4s for docker manifest inspect), all subsequent runs hit the local disk cache (~0ms)
  • The cache key includes repository, tag, and architecture, so different platforms are cached independently
  • Inserted as the first checker in the DockerImageBuilder checker chain, before the network-based checkers

Known limitation

  • The persistent cache has no expiration or invalidation mechanism. If an image is deleted from the registry after being cached, the cache will still report it as existing and the build will be skipped. Users would need to manually clear ~/.flyte/cache/images/ or use force=True to trigger a rebuild. A TTL or cache-busting strategy could be added as a follow-up.

Test plan

  • test_cached — verifies persistent cache is checked first and other checkers are skipped
  • test_persistent_cache_write_and_read — verifies write/read round-trip and arch isolation
  • All existing image builder tests pass
  • Manual test: LOG_LEVEL=10 python examples/basics/hello.py — first run writes cache, second run shows "found in persistent cache" in ~0ms

pingsutw and others added 2 commits March 13, 2026 00:24
Adds PersistentCacheImageChecker that caches verified image URIs to
~/.flyte/cache/images/. After the first successful remote manifest
check (~4s), subsequent runs read from disk cache (~0ms), eliminating
repeated network round-trips to the container registry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
logger.debug(f"Image {image_uri} in registry")
return image_uri
# Persist to disk so future process invocations skip network checks
if checker is not PersistentCacheImageChecker:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the problem is the persistent cache never invalidates. If an image is deleted from the registry, the cache will still say it exists, and the build will be skipped

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it makes UX way more better

Signed-off-by: Kevin Su <pingsutw@apache.org>
@kumare3
Copy link
Contributor

kumare3 commented Mar 14, 2026

@pingsutw this is great, i was thinking of adding this and even code bundle hash to the local cache. Shall we just use the sqlite table to store this?

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