vjeantet / grok

simple library to use/parse grok patterns with go (100%)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

replace compiledin default patterns with only "base" ones

vjeantet opened this issue · comments

Hello,

Currently, 13905 allocations are performed when calling a Grok.New(), about 11ms on my MBPro

If I replace the current patterns.go with one containing only expressions found in the base file
Grok.New() performs 5502 allocations during 2,4 ms on the same MBPro.

What do you think about making patterns.go lighter ?

I don't have a strong opinion.

On one hand, Grok.New is not something you call very frequently (usually once during initialization) so 8ms is not a big deal.

On the other, I think that expressions in gemsi/grok are outdated compared to the "official" ones. It is something hard to maintain and keep up to date.

Said that, what I'd do is:

  • Simplify patterns.go the way you propose. This change breaks backwards compatibility (for people already using some grok expressions), so I'd tag current version as 1.0.0 and make the change in 2.x.

  • Add a new configuration property (PatternsDir if we want to use the same name already used in logstash) for those who want to load additional expressions.

    g := grok.NewWithConfig(&grok.Config{PatternsDir: pathToADir})