Repository navigation
feat(parser,store): stream v6 chunks directly into dynamic stores and introduce StructStore - #920
Conversation
… 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
There was a problem hiding this comment.
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
Summary
This PR migrates KHI web frontend data stores and v6 parser assemblers from batch array ingestion to dynamic streaming ingestion, and introduces
StructStoreto drastically reduce peak memory usage during large inspection file parsing:Dynamic Streaming Stores:
LogStore,TimelineStore, andInternPoolStorenow support progressive streaming ingestion (create(),add*(),shrinkToFit()).BufferLayoutBuilder.revisionIds,eventIds) fromTimelineStoremetadata buffer.StructStorefor Interned Structs:Structpayloads in a compact contiguous binary format.Streaming Data Assemblers:
DataAssemblerinterface andV6_BLUEPRINTassemblers stream decoded chunks directly toInspectionDataBuilderduringingest(), avoiding large intermediate array allocations.finalize()hook for cross-chunk entity relationships.InspectionDataBuilderis streamlined to single-item additions (addLog,addTimeline,addRevision,addEvent, etc.).Testing & Verification:
BufferLayoutBuilder,reallocateBuffer,StructStore,LogStore,TimelineStore,InternPoolStore, andKHIFileParser.make pre-commit,make lint-web,make build-storybook).