Re: [dev] [sbase] [PATCH] Make grep more memory-efficient

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Mon, 12 May 2014 12:57:57 +0200

On Mon, May 12, 2014 at 12:34 AM, FRIGN <dev_AT_frign.de> wrote:
> Hello,
>
> previously, we allocated one regex_t for each pattern found.
> This gets pretty nasty once the tree of patterns grows.
> Reusing one regex_t and regfreeing it after each use inside grep()
> implies just one simultaneous element in memory and a drastic decrease
> in memory-consumption.
>
> Please let me know what you think!
>

(Re)compiling the regex for each line doesn't make sense (imho) and
slows it down alot.

A simple test:

time seq 1 100000000 | grep 'a'

sbase grep (before patch):
    0m22.21s real 0m0.00s user 0m0.00s system

sbase grep (after patch):
    2m16.28s real 0m0.00s user 0m0.00s system

coreutils grep:
    0m1.15s real 0m0.00s user 0m0.00s system

So the patch should be reverted I think.

Kind regards,
Hiltjo
Received on Mon May 12 2014 - 12:57:57 CEST

This archive was generated by hypermail 2.3.0 : Mon May 12 2014 - 13:00:09 CEST