Skip to content

perf: lazy load all ingredient resources & remove old to_archive zip format.#2173

Draft
gpeacock wants to merge 11 commits into
mainfrom
gpeacock/store_resolver
Draft

perf: lazy load all ingredient resources & remove old to_archive zip format.#2173
gpeacock wants to merge 11 commits into
mainfrom
gpeacock/store_resolver

Conversation

@gpeacock
Copy link
Copy Markdown
Member

This is a draft PR to test this optimization

gpeacock added 6 commits May 26, 2026 18:14
…resource materialization

- Add StoreResolver newtype (Arc<dyn Fn> + Debug + Clone) to ResourceStore
- Add set_resolver() on ResourceStore; get/exists/write_stream fall back to it
- Add Ingredient::set_store_resolver() wiring Arc<Store> as the resolver
- Call set_store_resolver in Reader::with_store for every ingredient
…resource materialization

- Add StoreResolver newtype (Arc<dyn Fn> + Debug + Clone) to ResourceStore
- Add set_resolver() on ResourceStore; get/exists/write_stream fall back to it
- Add Ingredient::set_store_resolver() wiring Arc<Store> as the resolver
- Call set_store_resolver in Reader::with_store for every ingredient
old_to_archive and ARCHIVE_VERSION removed from builder.rs
to_archive simplified to JUMBF-only with NotImplemented guard for generate_c2pa_archive == Some(false)
merge_resources_from_store and both call sites removed
Zip imports cleaned up (ZipWriter/SimpleFileOptions moved to #[cfg(test)])
resource_store.rs: Deleted add_uri() (which eagerly copied bytes into the HashMap and materialized files to disk). Added chain_resolver_from() to chain an existing resolver as a fallback onto another store. Removed unused io_utils::uri_to_path import.

manifest.rs: Added set_store_resolver() — installs a closure on manifest.resources that fetches assertion bytes from the JUMBF store on demand. Claim thumbnail no longer eagerly copied into the HashMap; a ResourceRef with the JUMBF URI is stored instead.

reader.rs: Calls manifest.set_store_resolver() for each manifest after reading, wiring up lazy resolution.

ingredient.rs: Removed all add_uri() calls in thumbnail/data processing — replaced with ResourceRef::new() (just record the format+URI, no byte copy). Added chain_resolver_to() helper to propagate an ingredient's resolver to another store.

builder.rs: add_ingredient now calls ingredient.chain_resolver_to(&mut self.resources) so builder resources can lazily serve bytes from ingredient stores. Tests updated: test_archive_format_variants loads old_format_archive.zip fixture instead of writing one; test_base_path_not_deserialized_from_archive loads bad_path_archive.zip fixture instead of using ZipWriter. Removed #[cfg(test)] use zip::{write::SimpleFileOptions, ZipWriter}.

utils/mime.rs: format_to_extension made always-available (removed #[cfg(feature = "file_io")], added #[allow(unused)]).

New files: ingredient_memory.rs (dhat-based heap benchmark), old_format_archive.zip, bad_path_archive.zip.
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 27, 2026

Merging this PR will not alter performance

✅ 30 untouched benchmarks
⏩ 64 skipped benchmarks1


Comparing gpeacock/store_resolver (3fe4adb) with main (ef4b618)

Open in CodSpeed

Footnotes

  1. 64 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

❌ Patch coverage is 76.25899% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.33%. Comparing base (ef4b618) to head (3fe4adb).

Files with missing lines Patch % Lines
sdk/src/resource_store.rs 63.15% 21 Missing ⚠️
sdk/src/ingredient.rs 78.72% 10 Missing ⚠️
sdk/src/manifest.rs 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2173      +/-   ##
==========================================
- Coverage   78.38%   78.33%   -0.05%     
==========================================
  Files         176      176              
  Lines       45991    45951      -40     
==========================================
- Hits        36048    35998      -50     
- Misses       9943     9953      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant