Repository navigation
perf(workbench): optimize memory footprint and ingestion performance for .khi datasets - #922
Merged
Merged
Conversation
…for .khi datasets - Introduce pointer-free FlatStructStore (SoA layout) for interned structs and direct YAML serialization. - Introduce ReadonlyInternPool with array-based lookups for strings, fieldsets, and structs, eliminating sync.Map and reverse lookup maps in reading phase. - Streamline LogChunk and TimelineChunk processing directly into primitive-only cel.LogData and raw timelines within parallel worker goroutines. - Resolve log types and severities on demand during CEL evaluation via StyleResolver, eliminating pendingLogChunks buffer. - Add ReadonlyPool interface for polymorphic struct and value restoration across InternPool and ReadonlyInternPool. - Real-data ingestion benchmarks on 1.4M logs show: - Post-GC heap reduced by 75% (6,206 MB -> 1,553 MB, ~4.65 GB reduction) - Ingestion time reduced by 48% (13.51s -> 7.01s) - Peak heap reduced by 11% (7,360 MB -> 6,544 MB) - Total allocations reduced by 42% (16.8 GB -> 9.79 GB)
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a memory-optimized, pointer-free FlatStructStore and ReadonlyInternPool to store interned strings, field path sets, and structs in primitive scalar slices, significantly reducing GC overhead. It also updates the direct YAML serializer and integrates these flat structures into the CEL log and timeline evaluators. The review feedback identifies critical issues, including a recursive locking deadlock in FlatStructStore, an out-of-bounds panic in StoreProtoBatch when the maximum struct ID is 0, a logical error in StructRefs that includes orphaned IDs, and a violation of the interning pool rule regarding the deletion of orphaned IDs.
…ol to prevent OOM
…tStore and retain interned struct pool invariants
kyasbal
marked this pull request as ready for review
August 28, 2026 06:41
kyasbal
requested review from
K53,
RyuSA,
jyane,
kkuchima and
renamoo
as code owners
August 28, 2026 06:41
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
This PR significantly optimizes memory usage and ingestion performance when loading
.khiinspection files in Workbench.Key Optimizations
FlatStructStore& Direct YAML Serializer:uint32slices for ID, FieldPathSet ID, and byte-packed values).ReadonlyInternPoolwith Array Indexing:sync.Mapwith compact, ID-indexed flat slices (strings []string,fieldSets [][]uint32) for reading workflows.strToID,fieldSetToID) during read operations.InternPoolfor write operations (Inspector, Builder, etc.) to keep writing pipelines untainted.ReadonlyPoolInterface:ReadonlyPoolinterface (ResolveStringFromID,ResolveFieldSetFromID,ResolveStructFromID) allowing bothInternPoolandReadonlyInternPoolto be consumed transparently by CEL evaluator, graph builders, and test suites.Primitive-Only
cel.LogData& On-Demand Style Resolution:cel.LogData(now purely primitiveuint32IDs for log type, severity, summary, and struct).StyleResolverto resolve log type strings and severity orders on demand during CEL evaluation.pendingLogChunksbuffer fromWorkbench.Streaming Ingestion in Worker Goroutines:
LogChunk,TimelineChunk, andInterningPoolChunkinside parallel worker goroutines.StoreProtoBatchwithin worker goroutines, completely avoiding queuing raw Protobuf intern chunks in channel buffers.Real-Data Benchmark Results (1.4M Logs / 165k Timelines)
Measured against
data/inspection-imported-1.khi(138.66 MB compressed, 1,413,091 logs, 165,938 timelines):