Repository navigation
perf(core,inspection): parallelize log filtering and optimize filter extractors - #940
Merged
Merged
Conversation
…extractors This change improves log filtering performance across inspection tasks by parallelizing NewLogFilterTask and introducing lightweight extractors for filter predicates: 1. Parallelized Log Filtering (pkg/core/inspection/taskbase/logfilter_task.go): - Filter logs concurrently across CPU cores using worker.NewPool while preserving the original log order. - Support thread-safe progress updates with atomic.Int32. - Add unit test verifying log order preservation under concurrent execution. 2. Lightweight Extractors for Filter Predicates: - commonlogk8saudit, googlecloudlogk8saudit, ossclusterk8s: Introduced K8sAuditLogErrorExtractor / ExtractK8sAuditLogError to determine error status from status code alone without extracting the entire audit log field set. - googlecloudlogk8snode: Added ExtractK8sNodeParserType to identify node log component from syslog identifier / log name without parsing message contents. - googlecloudlogserialport: Added ExtractGCESerialPortMessage to extract only the message payload. - googlecloudclustercomposer: Added ExtractComposerComponent to extract component names directly from logName. - googlecloudlogk8scontrolplane: Added ExtractK8sControlplaneComponentParserType to resolve component parser types from component_name without resolving cluster/project metadata. 3. Standardized OSS K8s Audit Log Filters: - Refactored EventAuditLogFilterTask and NonEventAuditLogFilterTask in ossclusterk8s to use inspectiontaskbase.NewLogFilterTask. 4. Testing: - Added table-driven unit tests for all new extractor functions and concurrent log filtering.
kyasbal
requested review from
K53,
RyuSA,
jyane,
kkuchima and
renamoo
as code owners
September 2, 2026 05:10
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces concurrency to the log filtering task (LogFilterTask) using a worker pool to process logs in parallel while preserving their original order. To further optimize performance, it introduces lightweight extractors across various log types (including GCP/OSS K8s Audit, Composer, K8s Controlplane, K8s Node, and GCE Serial Port) to extract only the necessary fields (such as error status, component name, or parser type) for filtering, avoiding full log parsing. Additionally, it refactors several filter tasks to use the simplified NewLogFilterTask helper. There are no review comments, and I have no feedback to provide.
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.
Description
This change improves log filtering performance across inspection tasks by parallelizing
NewLogFilterTaskand introducing lightweight extractors for filter predicates:Parallelized Log Filtering (
pkg/core/inspection/taskbase/logfilter_task.go):worker.NewPool.logsinto contiguous index slices[start, end)per worker and concatenatingworkerResultsin ascending worker order.atomic.Int32.Lightweight Extractors for Filter Predicates:
commonlogk8saudit,googlecloudlogk8saudit,ossclusterk8s: IntroducedK8sAuditLogErrorExtractor/ExtractK8sAuditLogErrorto determine error status from status code alone without extracting the entire audit log field set.googlecloudlogk8snode: AddedExtractK8sNodeParserTypeto identify node log component from syslog identifier / log name without parsing message contents.googlecloudlogserialport: AddedExtractGCESerialPortMessageto extract only the message payload.googlecloudclustercomposer: AddedExtractComposerComponentto extract component names directly fromlogName.googlecloudlogk8scontrolplane: AddedExtractK8sControlplaneComponentParserTypeto resolve component parser types fromcomponent_namewithout resolving cluster/project metadata.Standardized OSS K8s Audit Log Filters:
EventAuditLogFilterTaskandNonEventAuditLogFilterTaskinossclusterk8sto useinspectiontaskbase.NewLogFilterTask.Testing:
Test Plan
make pre-commitmake lint-goandmake test-gomake test-web