]> git.sesse.net Git - plocate/commitdiff
Multithread linear scans.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Thu, 15 Oct 2020 20:41:42 +0000 (22:41 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Thu, 15 Oct 2020 20:41:42 +0000 (22:41 +0200)
When we have a scan that we cannot accelerate with trigrams
(very short patterns, or regexes), we need to go through all of
the file names like mlocate does. This is usually CPU-bound,
so fire up threads. We leave one core/hyperthread for the I/O
and add a thread for each of the rest (this is probably bad
on dualcore, but it's a simple thing that will do for now,
and should be fairly safe).

The bottleneck now is Serializer. I first tried just putting a
mutex on it, which worked fine on eight hyperthreads
(ie., four real cores, my laptop), but caused huge contention with 40
(20 cores, my old dual-socket Haswell). Sending data back through
per-thread queues seems to work a lot better, but we're still
spending a lot of time in Serializer; witness that --count is
much faster for such a search.


No differences found