]> git.sesse.net Git - plocate/commit - meson.build
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)
commit75c42d06f8eb513afc1976e82033ffb893b101b8
treea60406fe69af597038b114bd808a4d89a3ed015f
parent436bb5d60934c534b2ddab599236493fbff4da23
Multithread linear scans.

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.
meson.build
plocate.cpp