Skip to content

feat(parser,store): stream v6 chunks directly into dynamic stores and introduce StructStore - #920

Merged
kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-vuplwtoqmnop
Aug 28, 2026
Merged

kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-vuplwtoqmnop

Conversation

@kyasbal

@kyasbal kyasbal commented Aug 28, 2026

Copy link
Copy Markdown
Member

Summary

This PR migrates KHI web frontend data stores and v6 parser assemblers from batch array ingestion to dynamic streaming ingestion, and introduces StructStore to drastically reduce peak memory usage during large inspection file parsing:

  1. Dynamic Streaming Stores:

    • LogStore, TimelineStore, and InternPoolStore now support progressive streaming ingestion (create(), add*(), shrinkToFit()).
    • Memory buffers dynamically resize and shrink to fit exact element counts upon completion.
    • Offsets across compound buffers are unified using BufferLayoutBuilder.
    • Removed unused write-only arrays (revisionIds, eventIds) from TimelineStore metadata buffer.
  2. StructStore for Interned Structs:

    • Stores interned protobuf Struct payloads in a compact contiguous binary format.
    • Decodes values lazily on-demand when requested by the UI (e.g. log inspection dialog, YAML viewer).
    • Supports null, int64, double, bool, string, timestamp, nested structs, and lists.
  3. Streaming Data Assemblers:

    • DataAssembler interface and V6_BLUEPRINT assemblers stream decoded chunks directly to InspectionDataBuilder during ingest(), avoiding large intermediate array allocations.
    • Two-phase lifecycle with priority-based finalize() hook for cross-chunk entity relationships.
    • InspectionDataBuilder is streamlined to single-item additions (addLog, addTimeline, addRevision, addEvent, etc.).
  4. Testing & Verification:

    • Added unit tests for BufferLayoutBuilder, reallocateBuffer, StructStore, LogStore, TimelineStore, InternPoolStore, and KHIFileParser.
    • Verified that all 958 web unit tests pass.
    • Formatted and linted with zero errors (make pre-commit, make lint-web, make build-storybook).
… introduce StructStore

- Migrate LogStore, TimelineStore, and InternPoolStore to dynamic streaming ingestion (create(), add*(), shrinkToFit())
- Introduce StructStore for compact binary layout and on-demand decoding of interned structs
- Introduce BufferLayoutBuilder in buffer-util to calculate aligned offsets for multi-array stores
- Update DataAssembler and V6 assemblers to stream directly into InspectionDataBuilder during ingest()
- Simplify InspectionDataBuilder to single-item additions to match streaming semantics
- Add comprehensive test coverage across dynamic stores, buffer utilities, and file streaming

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the KHI file parsing pipeline to stream decoded Protobuf objects directly into domain stores (such as LogStore, TimelineStore, and a new StructStore for structured body data) during ingestion, eliminating intermediate in-memory array buffering and utilizing a shrinkToFit compaction step. The review feedback highlights several critical improvement opportunities: addressing a prototype pollution vulnerability in StructStore.setPathValue by blocking special keys like proto, optimizing Int64 decoding performance by defining safe integer BigInt bounds as module-level constants, and reducing memory overhead in TimelineStore by sharing a single EMPTY_UINT32_ARRAY constant instead of repeatedly allocating empty typed arrays.

…line allocations

- Mitigate prototype pollution in StructStore.setPathValue by discarding dangerous keys (__proto__, constructor, prototype, empty segments), using Object.hasOwn(), and adopting null-prototype objects
- Hoist MIN_SAFE_INTEGER_BI and MAX_SAFE_INTEGER_BI to module-level constants in StructStore
- Share EMPTY_UINT32_ARRAY constant for empty timeline revisions and events in TimelineStore
@kyasbal
kyasbal merged commit 679ce87 into GoogleCloudPlatform:main Aug 28, 2026
16 checks passed
@kyasbal
kyasbal deleted the push-vuplwtoqmnop branch August 28, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant