perf: lazy load all ingredient resources & remove old to_archive zip format.#2173
Draft
gpeacock wants to merge 11 commits into
Draft
perf: lazy load all ingredient resources & remove old to_archive zip format.#2173gpeacock wants to merge 11 commits into
gpeacock wants to merge 11 commits into
Conversation
…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
…-rs into gpeacock/store_resolver
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.
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a draft PR to test this optimization