bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24260: [PATCH 1/6] dfa: thread-safety: remove 'dfa' global in dfa.c


From: Zev Weiss
Subject: bug#24260: [PATCH 1/6] dfa: thread-safety: remove 'dfa' global in dfa.c
Date: Sat, 20 Aug 2016 20:21:33 -0500
User-agent: Mutt/1.6.2-neo (2016-07-23)

On Sun, Aug 21, 2016 at 08:40:59AM +0900, Norihiro Tanaka wrote:

On Fri, 19 Aug 2016 18:03:19 -0500
Zev Weiss <address@hidden> wrote:

Okay -- so your question is about the necessity of making operations other than 
dfaexec() thread-safe?  That's reasonable, though (obviously) I went ahead made 
the other operations thread-safe anyway.

1) It was, in some ways, simpler for me.  Rather than tracing through exactly 
when and how each variable was used to determine which could be safely left as 
globals, it was somewhat easier to just migrate all mutable global state into a 
context struct of some sort.

2) While it's not a terribly elegant approach (and certainly doesn't have to be 
this way), my current multithreading patch set actually does compile the regex 
separately (and concurrently) in each thread (for reasons similar to #1 above 
-- it was just simpler to do it that way).

3) Finally, and perhaps most compellingly in my opinion, especially since dfa.c 
is soon going to become a library component, it seems desirable for compilation 
etc. to be made thread safe anyway.  While grep doesn't really *need* to have 
it be thread-safe (and I'm guessing gawk and sed currently don't either), it 
doesn't seem all that unreasonable for an application to *want* to concurrently 
compile independent regexes, so it would seem a bit unfortunate to me for a 
library (gnulib) to not support that at all.


Zev

Thanks.  dfa exists only to improve performance of regex and regex uses
static variable for syntax which is re_syntax_options.  So we can not
still change compile phase thread-safe.

Hmm, I hadn't noticed that previously -- thanks.


In addition, IMHO, I think that compile should run only one time even
if grep runs multithread as you say in 2, and I do not expect that
members used in only compile not used in execute is generated each more
than one.


Yes, certainly it would be preferable for a multithreaded grep to compile the regex once regardless of the thread count. I've been meaning to implement it that way in my patch set, but haven't quite gotten around to it yet...hopefully soon.


Zev






reply via email to

[Prev in Thread] Current Thread [Next in Thread]