perf: stream HAR entries incrementally - #17
Merged
Merged
Conversation
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.
Summary
Replace the monolithic
har::from_sliceparser with a streaming HAR entries reader that iterates entries one at a time via a custom JSON scanner. HAR files from long browser DevTools sessions can exceed 100 MiB; this change keeps memory usage constant regardless of input size, matching the streaming behavior already in place for mitmproxy flow files.stream_har_file()that opens aBufReader, scans forward to the"entries": [array, and yields each entry object individually via bracket-balanced extraction +serde_json::from_sliceread_har_fileshim instream_inputwith the new streaming iteratorread_har_fileas a thin convenience wrapper (stream_har_file().collect())StreamingHarEntrystructs with#[serde(default)]for resilience against incomplete HARsType of Change
Checklist
cargo fmt --allcleancargo clippy --all-targets --all-features -- -D warningscleancargo testpasses locallyCHANGELOG.mdunder[Unreleased](if user-facing)feat:,fix:,docs:, etc.)Testing
stream_har_does_not_materialize_all: constructs a 20-entry HAR, verifies the iterator yields the first entry before consuming all entriesstream_matches_read_for_fixtures: runs all three HAR fixtures through bothstream_har_file().collect()andread_har_file(), asserts field-by-field equalitystream_malformed_entry_returns_error: verifies a bad entry mid-stream surfaces asErrwithout aborting subsequent valid entriesstream_empty_entries_array: verifies"entries": []yields zero items without errorcargo test --test securitypasses (5/5)cargo publish --dry-runsucceedsRelated Issues
None