]> Sergey Matveev's repositories - public-inbox.git/commit - lib/PublicInbox/ExtMsg.pm
extmsg: use Xapian only for partial matches
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sun, 22 Apr 2018 08:01:48 +0000 (08:01 +0000)
committerEric Wong <e@80x24.org>
Sun, 22 Apr 2018 08:02:13 +0000 (08:02 +0000)
commita46893a2b5dabfdbcf7b593ac19967daecfb1772
tree4b49778a165ec769a6412b07f965413567954c95
parent866837def71b9d70198f51e634e6141f75f0df3e
extmsg: use Xapian only for partial matches

"LIKE" in SQLite (and other SQL implementations I've seen) is
expensive with nearly 3 million messages in the archives.

This caused some partial Message-ID lookups to take over 600ms
on my workstation (~300ms on a faster Xeon).  Cut that to below
under 30ms on average on my workstation by relying exclusively
on Xapian for partial Message-ID lookups as we have in the past.

Unlike in the past when we tried using Xapian to match partial
Message-IDs; we now optimize our indexing of Message-IDs to
break apart "words" in Message-IDs for searching, yielding
(hopefully) "good enough" accuracy for folks who get long URLs
broken across lines when copy+pasting.

We'll also drop the (in retrospect) pointless stripping of
"/[tTf]" suffixes for the partial match, since anybody who
hits that codepath would be hitting an invalid message ID.

Finally, limit wildcard expansion to prevent easy DoS vectors
on short terms.

And blame Pine and alpine for generating Message-IDs with
low-entropy prefixes :P
lib/PublicInbox/ExtMsg.pm
lib/PublicInbox/Msgmap.pm
lib/PublicInbox/Search.pm
lib/PublicInbox/SearchIdx.pm
t/cgi.t
t/msgmap.t
t/psgi_search.t
t/search.t