Skip to content

grokky : ParseInto - #4729

Merged
buixor merged 2 commits into
masterfrom
grokky_parseInto
Oct 5, 2026
Merged

buixor merged 2 commits into
masterfrom
grokky_parseInto

Conversation

@buixor

@buixor buixor commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Implement ParseInto for both RE2 and regexps, and kill Parse.

ParseInto reduces allocations, as we're writing directly into the provided map, avoid an intermediary alloc. Especially effective when it's a miss, but never more expensive.

Allocations

scenario engine B/op allocs/op
stage walk, no match legacy 393 → 0 8 → 0
stage walk, no match re2 384 → 0 8 → 0
stage walk, match on 1st legacy 3,184 → 2,833 4 → 2
stage walk, match on 1st re2 4,816 → 4,480 11 → 9
stage walk, match on 8th legacy 3,410 → 2,706 11 → 2
stage walk, match on 8th re2 5,152 → 4,480 18 → 9
single pattern, no match legacy 48 → 0 1 → 0
single pattern, no match re2 48 → 0 1 → 0
single pattern, match legacy 3,186 → 2,831 4 → 2
single pattern, match re2 4,816 → 4,480 11 → 9
1.2 KB line, no match re2 664 → 0 4 → 0
1.2 KB line, match re2 5,144 → 4,480 13 → 9

CPU

In terms of pure parsing time, performance impact is neglectable when it's a hit.

scenario engine Parse ParseInto Δ
stage walk, no match legacy 1,098 ns 716 ns -34.8%
stage walk, no match re2 6,416 ns 6,019 ns -6.2%
stage walk, match on 1st legacy 6,983 ns 6,672 ns -4.5%
stage walk, match on 1st re2 7,477 ns 7,026 ns -6.0%
stage walk, match on 8th legacy 7,123 ns 6,526 ns -8.4%
stage walk, match on 8th re2 12.6 µs 12.1 µs -4.1%
single pattern, no match legacy 213 ns 153 ns -28.1%
single pattern, no match re2 801 ns 714 ns -10.8%
single pattern, match legacy 6,798 ns 6,544 ns -3.7%
single pattern, match re2 7,176 ns 7,216 ns +0.6% (noise)
1.2 KB line, no match re2 2,948 ns 2,616 ns -11.3%
1.2 KB line, match re2 81.9 µs 81.0 µs -1.0%

Copilot AI balanced review requested due to automatic review settings October 2, 2026 14:46
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

@buixor: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind enhancement
  • /kind refactoring
  • /kind fix
  • /kind chore
  • /kind dependencies
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

@buixor: There are no area labels on this PR. You can add as many areas as you see fit.

  • /area agent
  • /area local-api
  • /area cscli
  • /area appsec
  • /area security
  • /area configuration
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Tests share mutable destinations across engines, and the PR body lacks the required human review and testing confirmation.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds allocation-efficient grok parsing directly into caller-provided maps for both regex engines.

Changes:

  • Introduces ParseInto and uses it in parser nodes.
  • Preserves Parse compatibility.
  • Adds behavioral tests and performance benchmarks.
File Description
pkg/​parser/​node.go Parses captures directly into event data.
pkg/​grok/​pattern.go Extends the pattern interface.
pkg/​grok/​pattern_re2.go Implements RE2 ParseInto.
pkg/​grok/​pattern_legacy.go Implements legacy ParseInto.
pkg/​grok/​compile_test.go Tests both implementations.
pkg/​grok/​bench_test.go Benchmarks allocations and throughput.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/grok/compile_test.go
Comment on lines +194 to +195
require.Equal(t, tc.want, p.ParseInto(tc.input, tc.dest))
require.Equal(t, tc.after, tc.dest)
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.05%. Comparing base (e3f795d) to head (8261798).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4729      +/-   ##
==========================================
+ Coverage   71.04%   71.05%   +0.01%     
==========================================
  Files         536      536              
  Lines       36259    36261       +2     
==========================================
+ Hits        25759    25765       +6     
+ Misses      10499    10495       -4     
  Partials        1        1              
Flag Coverage Δ
bats 45.72% <37.50%> (-0.02%) ⬇️
unit-linux 46.64% <100.00%> (-0.05%) ⬇️
unit-windows 34.36% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@buixor

buixor commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

/kind enhancement
/area agent

@buixor
buixor added this pull request to stack #4732 October 2, 2026 16:54
@buixor
buixor merged commit bc692f0 into master Oct 5, 2026
15 checks passed
@buixor
buixor deleted the grokky_parseInto branch October 5, 2026 08:58
gabrielcosi pushed a commit to gabrielcosi/home-ops that referenced this pull request Oct 29, 2026
… ➔ v1.8.2) (#1487)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker.io/crowdsecurity/crowdsec](https://github.com/crowdsecurity/crowdsec) | patch | `v1.8.1` → `v1.8.2` |
| [docker.io/crowdsecurity/crowdsec](https://github.com/crowdsecurity/crowdsec) | patch | `v1.8.1-debian` → `v1.8.2-debian` |

---

### Release Notes

<details>
<summary>crowdsecurity/crowdsec (docker.io/crowdsecurity/crowdsec)</summary>

### [`v1.8.2`](https://github.com/crowdsecurity/crowdsec/releases/tag/v1.8.2)

[Compare Source](crowdsecurity/crowdsec@v1.8.1...v1.8.2)

##### Version 1.8.2

- Brings [custom JS fingerprinting capabilities](https://docs.crowdsec.net/docs/next/appsec/bot_detection/custom_js/) to the bot detection feature, allowing both users and us to distribute detection rules directly via the hub.
- Brings [rate limiting feature](https://docs.crowdsec.net/docs/next/appsec/rate_limiting/) to the WAF.
- Brings performance improvements to the Security Engine, optimizing both memory copy behaviors and relying on static analysis to avoid processing unnecessary regular expressions.
- Brings performance improvements to the WAF, optimizing out-of-band rules processing.
- Brings performance improvements to the Bot Detection, optimizing memory usage.

##### New Features & Major improvements

- \[WAF] Add RateLimiting feature ([#&#8203;4721](crowdsecurity/crowdsec#4721)) [@&#8203;blotus](https://github.com/blotus)
- \[bot-detection] Add custom JS fingerprinting capabilities ([#&#8203;4657](crowdsecurity/crowdsec#4657)) [@&#8203;buixor](https://github.com/buixor)
- \[bot-detection] Add cscli bot subcommand ([#&#8203;4666](crowdsecurity/crowdsec#4666)) [@&#8203;blotus](https://github.com/blotus)
- \[WAF] Improve out-of-band rules performances ([#&#8203;4722](crowdsecurity/crowdsec#4722)) [@&#8203;blotus](https://github.com/blotus)
- \[Security Engine] Run postoverflows in a separate goroutine to avoid blocking on slow enrichments ([#&#8203;4672](crowdsecurity/crowdsec#4672)) [@&#8203;blotus](https://github.com/blotus)
- \[bot-detection] Improve memory usage ([#&#8203;4674](crowdsecurity/crowdsec#4674)) [@&#8203;blotus](https://github.com/blotus)
- \[Security Engine] Various performance improvements to regular expression processing ([#&#8203;4736](crowdsecurity/crowdsec#4736)) ([#&#8203;4731](crowdsecurity/crowdsec#4731)) ([#&#8203;4729](crowdsecurity/crowdsec#4729)) [@&#8203;blotus](https://github.com/blotus) [@&#8203;buixor](https://github.com/buixor)

##### Improvements

- Add `cs_features` metric ([#&#8203;4770](crowdsecurity/crowdsec#4770)) [@&#8203;blotus](https://github.com/blotus)
- bot detection: add an option to set SameSite=None + Partitioned flag on cookie ([#&#8203;4764](crowdsecurity/crowdsec#4764)) [@&#8203;blotus](https://github.com/blotus)
- exprhelpers: add GetDecisionsSinceCountByScenario ([#&#8203;4756](crowdsecurity/crowdsec#4756)) [@&#8203;tommy-ng0](https://github.com/tommy-ng0)
- lapi: optionally limit concurrent decision stream requests ([#&#8203;4747](crowdsecurity/crowdsec#4747)) [@&#8203;tommy-ng0](https://github.com/tommy-ng0)
- exprhelpers: LookupHost goes through the DNS cache ([#&#8203;4741](crowdsecurity/crowdsec#4741)) [@&#8203;twiesing](https://github.com/twiesing)
- metrics: add CAPI last pull timestamp and error counter ([#&#8203;4749](crowdsecurity/crowdsec#4749)) [@&#8203;NazarkinRoman](https://github.com/NazarkinRoman)
- prometheus: add kind label to cs_alerts ([#&#8203;4742](crowdsecurity/crowdsec#4742)) [@&#8203;blotus](https://github.com/blotus)
- lapi: make decisions stream page size configurable ([#&#8203;4733](crowdsecurity/crowdsec#4733)) [@&#8203;tommy-ng0](https://github.com/tommy-ng0)
- Fix ValidateChallengeResponse ([#&#8203;4737](crowdsecurity/crowdsec#4737)) [@&#8203;buixor](https://github.com/buixor)
- bot-detection: add new FlagSubmission() helper ([#&#8203;4727](crowdsecurity/crowdsec#4727)) [@&#8203;blotus](https://github.com/blotus)
- appsec: add an optional category to the request score ([#&#8203;4715](crowdsecurity/crowdsec#4715)) [@&#8203;buixor](https://github.com/buixor)
- apiserver: reload the TLS server certificate when its files change ([#&#8203;4709](crowdsecurity/crowdsec#4709)) [@&#8203;ohartwig](https://github.com/ohartwig)
- fix image link ([#&#8203;4702](crowdsecurity/crowdsec#4702)) [@&#8203;buixor](https://github.com/buixor)
- waf: add SkipProcessing() helper ([#&#8203;4667](crowdsecurity/crowdsec#4667)) [@&#8203;blotus](https://github.com/blotus)
- \[bot-detection] drop the URI from the cookie ([#&#8203;4656](crowdsecurity/crowdsec#4656)) [@&#8203;buixor](https://github.com/buixor)

##### Bug Fixes

- acquisition/file: don't send half-written lines, or skip the lines after them ([#&#8203;4678](crowdsecurity/crowdsec#4678)) [@&#8203;n1koo](https://github.com/n1koo), [@&#8203;blotus](https://github.com/blotus), [@&#8203;claude](https://github.com/claude)
- fix(cscli): display human-readable timestamps in local time ([#&#8203;4759](crowdsecurity/crowdsec#4759)) [@&#8203;sep2](https://github.com/sep2)
- remove runtime Fatalf calls ([#&#8203;4760](crowdsecurity/crowdsec#4760)) [@&#8203;blotus](https://github.com/blotus)
- waf: fix log spam when usin unix socket on freebsd ([#&#8203;4745](crowdsecurity/crowdsec#4745)) [@&#8203;blotus](https://github.com/blotus)
- docker: read from now if container restarts ([#&#8203;4605](crowdsecurity/crowdsec#4605)) [@&#8203;blotus](https://github.com/blotus)
- splunk-notification: add an option to configure InsecureSkipVerify ([#&#8203;4720](crowdsecurity/crowdsec#4720)) [@&#8203;blotus](https://github.com/blotus)
- victorialogs: move the datasource to RestartableStreamer interface ([#&#8203;4738](crowdsecurity/crowdsec#4738)) [@&#8203;blotus](https://github.com/blotus)
- metrics: remove series of deleted machines and bouncers ([#&#8203;4712](crowdsecurity/crowdsec#4712)) [@&#8203;somaz94](https://github.com/somaz94)
- buckets: make a copy of all event maps before pouring the event to a bucket ([#&#8203;4481](crowdsecurity/crowdsec#4481)) [@&#8203;blotus](https://github.com/blotus)
- fix(database): keep simulated decisions from suppressing real bans ([#&#8203;4679](crowdsecurity/crowdsec#4679)) [@&#8203;4erdenko](https://github.com/4erdenko), [@&#8203;blotus](https://github.com/blotus)
- fix a nasty bug in transfrom where the effective uuid for a datasource ([#&#8203;4697](crowdsecurity/crowdsec#4697)) [@&#8203;sabban](https://github.com/sabban)
- hubtest: add a tiebreaker based on the alert date to have a consistent order ([#&#8203;4699](crowdsecurity/crowdsec#4699)) [@&#8203;blotus](https://github.com/blotus)
- syslog: copy buffer before handing it to the datasource ([#&#8203;4690](crowdsecurity/crowdsec#4690)) [@&#8203;blotus](https://github.com/blotus)
- Expand env vars in online_api_credentials.yaml ([#&#8203;4677](crowdsecurity/crowdsec#4677)) [@&#8203;kushiemoon-dev](https://github.com/kushiemoon-dev)

##### Chore / Deps

- build(deps): bump the gomod group with 5 updates ([#&#8203;4778](crowdsecurity/crowdsec#4778)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- build(deps): bump the github-actions group with 2 updates ([#&#8203;4777](crowdsecurity/crowdsec#4777)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- build(deps): bump certifi from 2026.1.4 to 2026.10.19 in /build/docker/test ([#&#8203;4780](crowdsecurity/crowdsec#4780)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- build(deps): bump the github-actions group across 1 directory with 8 updates ([#&#8203;4766](crowdsecurity/crowdsec#4766)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- build(deps): bump the gomod group with 16 updates ([#&#8203;4767](crowdsecurity/crowdsec#4767)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- build(deps): bump the gomod group with 8 updates ([#&#8203;4753](crowdsecurity/crowdsec#4753)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- fpscanner: use fork ([#&#8203;4761](crowdsecurity/crowdsec#4761)) [@&#8203;blotus](https://github.com/blotus)
- waf: update to coraza 3.8.0 ([#&#8203;4724](crowdsecurity/crowdsec#4724)) [@&#8203;blotus](https://github.com/blotus), [@&#8203;buixor](https://github.com/buixor)
- build(deps): bump the gomod group across 1 directory with 19 updates ([#&#8203;4730](crowdsecurity/crowdsec#4730)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- CI: skip more docker tests on windows ([#&#8203;4728](crowdsecurity/crowdsec#4728)) [@&#8203;blotus](https://github.com/blotus)
- grok: embed grok library instead of having it as a dep ([#&#8203;4725](crowdsecurity/crowdsec#4725)) [@&#8203;blotus](https://github.com/blotus)
- docker datasource: skip tests on windows ([#&#8203;4719](crowdsecurity/crowdsec#4719)) [@&#8203;blotus](https://github.com/blotus)
- agents.md: keep comments to a reasonable level ([#&#8203;4716](crowdsecurity/crowdsec#4716)) [@&#8203;blotus](https://github.com/blotus)
- build(deps): bump the github-actions group with 7 updates ([#&#8203;4693](crowdsecurity/crowdsec#4693)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- build(deps): bump the gomod group with 11 updates ([#&#8203;4694](crowdsecurity/crowdsec#4694)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- build(deps): bump github.com/go-openapi/validate from 0.26.5 to 1.0.0 ([#&#8203;4682](crowdsecurity/crowdsec#4682)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- build(deps): bump the gomod group with 19 updates ([#&#8203;4681](crowdsecurity/crowdsec#4681)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- build(deps): bump cryptography from 48.0.1 to 50.0.0 in /build/docker/test ([#&#8203;4591](crowdsecurity/crowdsec#4591)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- bump to go 1.27 ([#&#8203;4675](crowdsecurity/crowdsec#4675)) [@&#8203;blotus](https://github.com/blotus)
- build(deps): bump the github-actions group across 1 directory with 3 updates ([#&#8203;4658](crowdsecurity/crowdsec#4658)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- build(deps): bump the gomod group across 1 directory with 21 updates ([#&#8203;4659](crowdsecurity/crowdsec#4659)) [@&#8203;dependabot\[bot\]](https://github.com/apps/dependabot)
- AGENTS.md: clearer guidance on tests ([#&#8203;4713](crowdsecurity/crowdsec#4713)) [@&#8203;blotus](https://github.com/blotus)
- pimp readme ([#&#8203;4701](crowdsecurity/crowdsec#4701)) [@&#8203;buixor](https://github.com/buixor)

##### Geolite2 notice

This product includes GeoLite2 data created by MaxMind, available from <a href="https://www.maxmind.com"><https://www.maxmind.com></a>.

##### Installation

Take a look at the [installation instructions](https://doc.crowdsec.net/docs/getting_started/install_crowdsec).

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/Berlin)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xODEuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjE4MS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19-->

Reviewed-on: https://git.xcd.dev/gabrielcosi/home-ops/pulls/1487
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent kind/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants