8 Commits

Author SHA1 Message Date
Ice3man
8f313629b8
Memory usage optimizations (#2350)
* Replaced strings.Replaced with fasttemplate reducing allocations

Custom template parsing logic was replaced with fasttemplate package for reducing
allocations in the replacer.Replace hotpath leading to allocation reduction which
accounted for 30% of total nuclei allocations.

$ go test -bench=. -benchmem
goos: darwin
goarch: arm64
pkg: github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/replacer
BenchmarkReplacer-8               837232              1422 ns/op            2112 B/op         31 allocs/op
BenchmarkReplacerNew-8           3672765               320.3 ns/op            48 B/op          4 allocs/op

* Fixed tests failing

* Use pre-compiled map of DSL expressions

* Reworked expression parsing logic to reduce memory allocations

$ go test -bench=. -benchmem
goos: darwin
goarch: arm64
pkg: github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/expressions
BenchmarkEvaluate-8        31560             37769 ns/op           31731 B/op        265 allocs/op
BenchmarkEvaluateNew-8       109144              9621 ns/op            6253 B/op        116 allocs/op
2022-08-23 13:16:41 +05:30
mzack
766a3eefb6 Implementing incremental expression replacement 2022-02-01 14:12:16 +01:00
Mzack9999
0e8270c7b5
Replacing expression regex with lexical analyzer (#1440)
* Replacing regex with lexical analyzer taken from 610beb8534/v2/pkg/protocols/common/expressions/expressions.go (L66)
2022-01-09 17:22:04 +05:30
Ice3man543
908889ccb5 Fixed expression parser + misc 2021-03-05 19:25:09 +05:30
Ice3man543
8512b684c5 Lint errors fix 2021-02-26 13:13:11 +05:30
Ice3man543
a455b054e5 Removing redundant code, cleanup + tests 2021-02-04 04:48:45 +05:30
Ice3man543
40d5655328 HTTP request building workflow changes 2020-12-28 01:33:50 +05:30
Ice3man543
2b50d99c0c Misc work on extractor and replacer 2020-12-24 12:56:28 +05:30