Cache the joined log buffer and skip it for single-line rules - #1329
Cache the joined log buffer and skip it for single-line rules#1329DigitalVeer wants to merge 1 commit into
Conversation
The log buffer joins every buffered line and scans all of them for each pattern on every push, which is wasted work when a pattern cannot even match across lines. The buffer now caches the joined string, and Push invalidates the cache. CompilePattern marks the patterns that cannot match across lines (no start anchor, no way to match a newline, and the appended \z anchor binds every branch) and Match checks them against the most recent line alone.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: DigitalVeer The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @DigitalVeer. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This PR makes two changes on top of #1323:
Pushclears the cache.CompilePatternmarks the rules that can match only one line.Matchtests these rules against the last line only.This will help NPD act more reliably during log floods.
Benchmark
BenchmarkPushAndMatchAll(linux/arm64, Go 1.26):API change
CompilePatternreturns*Patterninstead of*regexp.Regexp.String()from theLogBufferinterface as it is not used anymore.