Closed dwisiswant0 closed 10 months ago
Added new candidate, https://github.com/AspieSoft/go-regex.
goos: linux
goarch: amd64
pkg: benchmark-regexp
cpu: 11th Gen Intel(R) Core(TM) i9-11900H @ 2.50GHz
GOMAXPROCS: 16
BenchmarkCompileNonPCRE
Engine | ns/op | B/op | allocs/op | elapsed |
---|---|---|---|---|
regexp | 127972 | 131641 | 690 | 1.323665572s |
AspieSoft/go-regex | 29328 | 2322 | 3 | 1.384703177s |
GRbit/go-pcre | 21163 | 2744 | 6 | 1.330075384s |
scorpionknifes/go-pcre | 20630 | 12 | 2 | 1.735374764s |
BenchmarkCompilePCRE
Engine | ns/op | B/op | allocs/op | elapsed |
---|---|---|---|---|
AspieSoft/go-regex | 6647 | 465 | 3 | 1.122028641s |
GRbit/go-pcre | 4444 | 824 | 6 | 2.195591583s |
scorpionknifes/go-pcre | 4250 | 12 | 2 | 1.267168176s |
Reopening as per https://github.com/kitabisa/teler-waf/pull/90#issuecomment-1714659010.
I will mark this issue as completed, because - upon evaluating the trade-offs associated with migrating the built-in regexp
engine within CustomRule
and the inThreatRegexp
utility (used by BadIPAddress
and DirectoryBruteforce
), there is no performance enhancements were observed.
Background
Currently, teler-waf utilizes two different regexp engines for pattern matching: one from the built-in
regexp
and another fromgo-pcre
. However, to enhance maintainability and performance, we're considering the transition to a single regexp engine. This decision is driven by the need to streamline our codebase and ensure consistent behavior across our library.Objective
The primary objective of this proposal is to select a single regexp engine that best aligns with our requirements. It's crucial that the chosen engine supports PCRE patterns, as these patterns are integral to our use cases, specifically to check the
CommonWebAttack
threat.Options
We have evaluated several alternative regexp engines that are commonly used:
go-pcre
(by @\scorpionknifes)go-pcre
(by @\GRbit)go-re2
gohs
(Chimera)rure-go
go-regex
Criteria
To make an informed decision, we should consider the following criteria:
Proposed Steps
Conclusion
By transitioning to a single regexp engine that supports PCRE patterns, we can simplify our codebase, improve maintainability, and ensure consistent behavior. This proposal outlines the steps to evaluate and select the most appropriate engine for our library's needs. Let's work collaboratively to make this transition successful and beneficial for our users and the longevity of our project.