Repository navigation
perf(core): optimize orderedMapNode reader access and release raw logs after ingestion - #931
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces CPU and memory profiling support, refactors log ingester tasks to return struct{} instead of []*log.Log to avoid redundant memory allocation, and implements a dynamic re-splitting mechanism in TimePartitioningProgressReportableLogFetcher to optimize concurrent log fetching. The review feedback suggests removing the unused cancelChild field and its redundant assignment in dynamicPartitionTask to clean up dead code.
…s after ingestion
a4e275d to
cdf90ca
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces CPU and memory profiling capabilities via new debug parameters, and refactors log ingester tasks to return struct{} instead of []*log.Log to optimize memory usage. Additionally, it adds an Unwrap method to orderedMapNode to allow direct field lookups on wrapped nodes. Feedback on the changes highlights a potential nil pointer dereference panic in pkg/common/structured/reader.go if currentNode becomes nil during path traversal, and suggests adding a defensive nil check.
Summary
This PR addresses memory consumption during log ingestion in KHI by optimizing two key areas:
orderedMapNode:orderedMapNodewas previously converting map entries to a full array on every call toChildren(), causing massive allocation overhead (~4.49 GB) during structured path traversal. AnUnwrap() Nodemethod was introduced, allowingNodeReaderto directly traverse the underlying map node.[]*log.Login the task DAG for downstream timeline mapper tasks. By updating log ingester tasks to returntaskid.TaskReference[struct{}]and releasing raw logs immediately upon ingestion, we allow the Go GC to reclaim memory during DAG execution.Profiling & Benchmark Comparison
Benchmark on 5 hours of GKE cluster logs (approx. 100k log entries):
alloc_space)orderedMapNode.ChildrenAllocationsinuse_space)Verification
make test-gopassed cleanlymake lint-gopassed with 0 issuesmake pre-commitpassed