Repository navigation
perf(analysis-view): retain frozen snapshots across parent readers and index view lookups - #13315
Merged
Merged
Conversation
…d index view lookups
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The PR appears safe to merge; the previous performance issue is fixed and no new blocking issues were found. SummaryThis PR retains frozen parent snapshots and adds indexes for repeated view reads. The latest changes replace the full sort for filtered JavaScript facts with an ordered merge and a shortcut for large offsets.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Parent result] --> B{Sealed immutable snapshot?}
B -->|No| C[Parse and scan]
B -->|Yes| D[Reuse validated frozen snapshot]
D --> E[Reuse fact indexes]
E --> F{Matching buckets}
F -->|One| G[Read requested slice]
F -->|Several| H[Seek for large offsets]
H --> I[Merge ordered positions]
G --> J[Build requested rows]
I --> J
C --> J
Reviews (3) · Last reviewed commit: "perf(analysis-view): use bounded k-way m..." · Reviewed by Greptile |
1 of 22 tasks
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
Fixes
createAnalysisViewResultReaderdiscarding the frozen JSON snapshot it just created, extends immutable snapshot caching to 10 uncached view parent readers, adds secondaryWeakMapindexes for JavaScript module/fact views and PCAP DNS queries, and eliminates redundant route filtering passes:createAnalysisViewResultReader(analysisViewParent.ts): Bindsconst frozen = freezeOwnedJsonTreeSnapshot(normalized.data) as Value, cacheschecked.set(source, frozen), and returnsok(frozen)rather than caching/returning the mutable pre-freezeparsed.value.createAnalysisViewResultReader:safeParseJavaScriptParent,byteEntropySchema,safeParseOwnedBinaryLayout, andfunctionDossierSchemain analysisView.ts.safeParseOwnedWebNetworkCapturein webNetworkCaptureView.ts so repeatedsummary/capture/protobuf/qlogcalls share one immutable snapshot (enablingprotobufCaptureView'sisImmutableJsonSnapshot(report)fast path even whencanBorrowParsedJsonSnapshotis false) and computedsummarizeProtobuf(report.records)once insummary.captureSchemain pcapCaptureView.ts, plus read-only/JSON-safe parsers across managedArtifactView.ts, machoView.ts, dartAotView.ts, wasmArtifactView.ts, evmInterfaceView.ts, commandObservationView.ts, and fridaSessionStatusView.ts.WeakMapindexes & single-pass pagination:WeakMap-indexedmoduleEntries,byNodeId,nodesByPath, andnodesByKindkeyed on immutable snapshots (isImmutableJsonSnapshot(analysis)), forwarding immutablecacheOwnertoprojectJavaScriptFacts.WeakMap-indexedall,byKind,byPath, andbyKindAndPathkeyed on sealed(cacheOwner, Object.isFrozen(nodes)), slicing O(page) or preservingUint32Array-sorted order for multi-bucket filters.selectDnsQuery(capture.dns_queries[view.query_index]O(1) lookup),equalLabelsHex(removingJSON.stringify), and sealeddnsQueriesByNameWeakMap.deliverloop countingtotaland skipping outside[page.offset, page.offset + page.limit)without intermediate.filter(...)array allocations.Problem and expected behavior
createAnalysisViewResultReaderfrozenormalized.dataonly to discard it and return mutableparsed.value, breaking downstreamisImmutableJsonSnapshot(...)fast paths; 10 parent readers re-parsed the full parent Evidence JSON on every view/page request; and JS/PCAP views performed repeated linear scans per lookup.Change and scope
src/domain/analysisView/and 5 test files (analysisViewParent.test.ts,protobufCaptureView.test.ts,pcapCaptureView.test.ts,analysisView.test.ts,javascriptRoutesView.test.ts).analysisViewResult.tsand*SummaryViewResultSchemaexports untouched.Follow the contribution scope.
Not applicable (internal
AnalysisViewsnapshot-sharing and read-only indexing within existing Evidence/contract boundaries).Contract and boundary impact
createAnalysisViewResultReader) and view projectors insrc/domain/analysisView/.pcapRetainedView.test.tsplatform-skipped locally on darwin as onmain).WeakMapindexes attach strictly to frozenisImmutableJsonSnapshotowners).docs/public/product-catalog.json), package, or installation impact: none.Expected effects:
Evidence and regression coverage
createAnalysisViewResultReaderreturns anisImmutableJsonSnapshot === truefrozen snapshot even when borrowing is rejected and hitsWeakMap(parseCount === 1).summary, twoprotobufpages, andcapturepreview plus sealed/unsealed parity.captureSchema.safeParseacross 6 views +query_indexandquery_labels_hexparity.WeakMapreuse & parity forjavascriptApplicationView,javascriptFactsView,inspect_byte_entropy, andanalyze_function.dist/, Apple M5 arm64, Nodev24.22.1):pcap_dns_addresses_by_query_index(200 iters): warm302.534ms -> 1.946ms(155x)pcap_dns_addresses_by_query_labels(200 iters): warm271.418ms -> 2.142ms(127x)web_network_capture_normalized_protobuf_fields(50 iters): warm439.107ms -> 10.007ms(43.9x)byte_entropy_summary(50 iters): warm43.387ms -> 1.265ms(34.3x)js_app_module_page_filtered_by_path(100 iters): warm35.280ms -> 2.773ms(12.7x)js_app_item_by_path(100 iters): warm38.618ms -> 4.652ms(8.3x)js_app_item_by_node_id(100 iters): warm39.345ms -> 5.119ms(7.7x)js_facts_filtered_kind_and_path(100 iters): warm21.103ms -> 4.440ms(4.8x)web_network_capture_summary(50 iters): warm5.126ms -> 1.342ms(3.8x)pcapRetainedView.test.tsis platform-skipped without Linux fixture prerequisites on darwin.For evidence-bearing changes:
Validation performed
npx oxfmton all 19 modified files — passednpm run check:fast— passed (typecheck,lint,verify:architecture-guardsacross2944source files)npm run build:cached— passednpm run test:local -- src/domain/analysisView/*.test.ts—74/74files,1,580/1,580passednpm run test:local -- src/application/analysisView/*.test.ts—8/8files,130/130passednpm run test:focused(analysisViewMcp.test.ts35/35;analysisViewCli.test.ts31/31,javascriptFactsViewMcp.test.ts2/2,javascriptAnalysisResources.test.ts3/3 outside sandbox;pcapRetainedView.test.ts1 skipped on darwin) — passedCompatibility, safety, and release
v24.22.1domain/application/MCP unit and boundary suites on darwin.WeakMapindexes attach strictly to verified frozen immutable snapshots (isImmutableJsonSnapshot) with zero mutation.Author readiness
Human owner:
Before merge
type(scope): outcome.