bug-gnulib
[Top][All Lists]
Advanced

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

Re: dfa MT-safe?


From: Norihiro Tanaka
Subject: Re: dfa MT-safe?
Date: Mon, 16 Dec 2019 07:47:59 +0900

On Sun, 15 Dec 2019 05:43:52 -0700
address@hidden wrote:

> Hi.
> 
> Bruno Haible <address@hidden> wrote:
> 
> > > In any case, gawk's use of it is (and will remain) single-threaded.
> > > It'd be nice if your fix did not pull in more libraries, like libpthread
> > > or whatever, since that would considerably complicate things for me,
> > > for no actual gain w.r.t. gawk.
> >
> > If you add these two lines to configure.ac:
> >   gl_cv_func_setlocale_null_all_mtsafe=yes
> >   gl_cv_func_setlocale_null_one_mtsafe=yes
> > no additional libraries will be needed.
> 
> How? I don't use gnulib in gawk.
> 
> > > I'm curious what is the use case for multithreaded dfa?
> >
> > One could speed up
> >   grep -r PATTERN DIRECTORY_WITH_MANY_FILES
> > by a large factor (probably 4x or 5x, on a CPU with 8 threads).
> > This would be done by modifying 'grep' to process each file in a
> > separate thread. The kernel can feed the data of these files to 'grep'
> > in parallel. Only the output phase needs to serialize things.
> 
> I suspect that exactly because of the output phase you won't see
> such a huge speedup in practice, but it's worth a shot.
> 
> On the assumption that setlocale is the only blocker, I would rather
> see an additional `char *locale_name' parameter added to dfa_syntax.
> That way the caller can get the value and pass it in, and the
> dfa code becomes mt-safe at next to no cost.
> 
> Thanks,
> 
> Arnold

In dfa multithreading, the execution phase is more useful than the
compilation phase, and setlocale() is not called during the execution
phase.

By the way, there is currently no way to share a compiled result between
threads except full copy of dfa structure to execute using the result in
multiple threads.




reply via email to

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