Eric Wong [Mon, 31 Aug 2020 04:41:31 +0000 (04:41 +0000)]
watchmaildir: use v5.10.1, drop warnings
Declare 5.10.1 to avoid potential compatibility problems with
Perl 7/8 down the line. We'll rely on the command-line to set
or drop warnings during development, at least.
Eric Wong [Mon, 31 Aug 2020 04:41:30 +0000 (04:41 +0000)]
watch: limit batch size of NNTP and IMAP workers, too
We don't want to monopolize locks because processes can easily
block each other if using `watchspam' on a Maildir while a big
NNTP or IMAP import is happening.
This can also happen if somebody configured a single inbox to
watch from several sources to merge several mailboxes into one
(e.g. both an IMAP and Maildir are watched).
Eric Wong [Fri, 28 Aug 2020 10:12:59 +0000 (10:12 +0000)]
imaptracker: update_last: simplify callers
By making it a no-op if last_uid is not defined. This isn't a
hot code path, so the extra method dispatch isn't an issue.
It'll save some indentation/wrapping in future commits.
Eric Wong [Fri, 28 Aug 2020 10:12:58 +0000 (10:12 +0000)]
watch: flush changes to inbox before updating IMAPTracker
Data needs to hit inboxes, first. Otherwise it's possible to
skip messages in case git-fast-import is killed before it sees
"done\n". Now, -watch will just waste a little bandwidth in
re-downloading a seen message if it's interrupted immediately
before updating IMAPTracker.
Eric Wong [Fri, 28 Aug 2020 04:22:00 +0000 (04:22 +0000)]
Makefile.PL: run check-man for <= 80 columns on check-run, too
I mostly use "make check-run" instead of the slower "make check"
target, nowadays, so add this check to ensure the rendered
manpage is always be visible to more users who need big fonts.
Eric Wong [Thu, 27 Aug 2020 22:05:00 +0000 (22:05 +0000)]
www: more descriptive pagination
Being an easily confused person, I find "next" and "prev"
ambiguous as to whether messages on the next or previous page
will be newer or older than the current page. Clarify that for
the threaded /$INBOX/ view and search results.
For search results sorted by relevance, we'll use "[>= $SCORE]"
or "[<= $SCORE]" to indicate to indicate directionality.
This also fixes $INBOX/new.html for unindexed v1 inboxes.
Eric Wong [Thu, 27 Aug 2020 22:04:59 +0000 (22:04 +0000)]
www: improve navigation around contemporary threads
Sometimes it's useful to quickly get to threads and messages
which are contemporaries of the current thread/message being
focused on. This hopefully improves navigation by making:
a) the top line (where $INBOX_DIR/description) is shown
a link to the latest topics in search results and
per-thread/per-message views.
b) providing a link to contemporaries ("~YYYY-MM-DD") at
around the thread overview skeleton area for per-thread
and per-message views
Eric Wong [Thu, 27 Aug 2020 12:17:05 +0000 (12:17 +0000)]
doc: move watch config docs to -watch manpage
The -config manpage is a bit long and the -watch stuff is
isolated from the rest of it while we start documenting NNTP and
IMAP support.
I'm not entirely happy with the way IMAP and NNTP are
configured, it's still good enough for small setups.
This also fixes a long-standing misplaced comment about
`publicinboxwatch.spamcheck' affecting all configured inboxes,
that comment was actually for `publicinboxwatch.watchspam'.
We'll omit documenting NNTP for `watchspam', for now, given the
lack of \Seen flags in NNTP and I'm not sure if it's even
useful. There may not be any newsgroups for sharing confirmed
spam, either...
Eric Wong [Thu, 27 Aug 2020 12:17:04 +0000 (12:17 +0000)]
watch: imap: only remove \Seen spam
This matches the behavior of Maildir `watchspam' handling in not
removing unseen messages. NNTP can't match this behavior, since
NNTP servers don't store flags, clients do.
Eric Wong [Thu, 27 Aug 2020 12:17:00 +0000 (12:17 +0000)]
imaptracker: preserve WAL journal_mode if set by user
It's no problem for most users to enable WAL, here, since
there's only a single process doing both reading and writing
(unlike the read-only daemons). However, WAL doesn't work on
network filesystems, so it can't be enabled by default.
Eric Wong [Thu, 27 Aug 2020 07:51:25 +0000 (07:51 +0000)]
git: show more context info on failures
I'm seeing "read: Connection timed out" from in my syslog from
-httpd. The fail() calls in PublicInbox::Git seems to be the
only code path of ours which could trigger it...
ETIMEDOUT shouldn't happen on pipes, only sockets; and all of
our socket operations are non-blocking. So this could be
cgit-wwwhighlight-filter.lua, but that's connecting over
localhost, though on fairly loaded HW.
Eric Wong [Wed, 26 Aug 2020 22:02:57 +0000 (22:02 +0000)]
search: allow testing with current xapian.git and 1.5.x
A `PI_XAPIAN' environment variable is now exposed for testing
purposes. We'll also deal with the removal of
`NumberValueRangeProcessor' and use `NumberRangeProcessor'
in its place, but continue favoring the old Search::Xapian
since that's all that's packaged for Debian 10.x stable.
Eric Wong [Wed, 26 Aug 2020 08:17:40 +0000 (08:17 +0000)]
over: recent: remove expensive COUNT query
As noted in commit 87dca6d8d5988c5eb54019cca342450b0b7dd6b7
("www: rework query responses to avoid COUNT in SQLite"),
COUNT on many rows is expensive on big SQLite DBs.
We've already stopped using that code path long ago in WWW
while -imapd and -nntpd never used it. So we'll adjust our
remaining test cases to not need it, either.
Eric Wong [Wed, 26 Aug 2020 08:17:38 +0000 (08:17 +0000)]
over: rename ->connect method to ->dbh
`->connect' is confused with the perlfunc for the `connect(2)'
syscall, and also `DBI->connect'. Since SQLite doesn't use
sockets, the word "connect" needlessly confuses me. Give
it a short name to match the field name we use for it, which
also matches the variable name used by the DBI(3pm) and
DBD::SQLite(3pm) manpages.
Eric Wong [Tue, 25 Aug 2020 10:23:14 +0000 (10:23 +0000)]
grok-pull.post_update_hook: flock(2) before SQLite check
Unlike DBD::SQLite, the sqlite3(1) CLI does not have a default
busy timeout enabled, so it easily times out while acquiring a
SHARED lock for read-only queries. We can avoid battery-wasting
polling from the SQLite timeout handler by relying on flock(2)
as we do in our Perl code.
Furthermore, this avoids triggering some locking problems[1]
from a long "SELECT COUNT(*) ..." query and reindex.
While there may be other SQLite-related parallelism issues[1],
this works around one of them by relying on flock(2).
Eric Wong [Tue, 25 Aug 2020 03:02:47 +0000 (03:02 +0000)]
over+msgmap: respect WAL journal_mode if set
WAL actually seems to have ideal locking characteristics given
concurrency problems I'm experiencing with --reindex running
in parallel with expensive read-only SQLite queries:
<https://public-inbox.org/meta/20200825001204.GA840@dcvr/>
Unfortunately, we cannot blindly use WAL while preserving
compatibility with existing setups nor our guarantees that
read-only daemons are indeed "read-only".
However, respect an user's the choice to set WAL on their
own if they're comfortable with giving -nntpd/-httpd/-imapd
processes write permission to the directory storing SQLite DBs.
Eric Wong [Sat, 22 Aug 2020 06:06:27 +0000 (06:06 +0000)]
mbox: disable "&t" on existing Xapian until full reindex
Expanding threads via over.sqlite3 for mbox.gz downloads without
Xapian effectively collapsing on the THREADID column leads to
repeated messages getting downloaded.
To avoid that situation, use a "has_threadid" Xapian metadata
flag that's only set on --reindex (and brand new Xapian DBs).
This allows admins to upgrade WWW or do --reindex in any order;
without worrying about users eating up bandwidth and CPU cycles.
Eric Wong [Sat, 22 Aug 2020 06:06:26 +0000 (06:06 +0000)]
search: support downloading mboxes results with full thread
Finally, the addition of THREADID for collapsing results
in Xapian lets us emulate the "mairix --threads" feature.
That is, instead of returning only the matching messages,
the entire thread is included in the downloaded mbox.gz
This requires a "public-inbox-index --reindex" to be usable.
Eric Wong [Sat, 22 Aug 2020 06:06:24 +0000 (06:06 +0000)]
searchidx: put all shard-related stuff in SearchIdxShard.pm
We'll also rename the /^remote_/ prefix to "shard_", since
remote implies the process is on a different host. These
methods only pass messages to a child process on the same host
OR perform operations within the same process.
Eric Wong [Sat, 22 Aug 2020 00:41:25 +0000 (00:41 +0000)]
searchview: fix mbox.gz downloads for lynx users
Unlike w3m and links, the lynx browser seems to require a `name'
attribute for `<input type=submit>' elements. Maybe some other
browsers do, too. The `name' attribute for submit elements
doesn't seem to cause any harm for w3m or links, users, either;
despite not (AFAIK) being part of historical or current HTML
specs.
Eric Wong [Thu, 20 Aug 2020 20:24:56 +0000 (20:24 +0000)]
init+index: support --skip-docdata for Xapian
Since we no longer read document data from Xapian, allow users
to opt-out of storing it.
This breaks compatibility with previous releases of
public-inbox, but gives us a ~1.5% space savings on Xapian
storage (and associated I/O and page cache pressure reduction).
Eric Wong [Thu, 20 Aug 2020 20:24:54 +0000 (20:24 +0000)]
smsg: remove from_mitem
We no longer read docdata.glass from anywhere in our code base.
Some adjustments were needed to t/search.t to deal with the
Xapian::WritableDatabase committing at different times, since
our ->query is avoided from PublicInbox::SearchIdx to avoid
needing a {over_ro} field.
Eric Wong [Thu, 20 Aug 2020 20:24:52 +0000 (20:24 +0000)]
extmsg: avoid using Xapian docdata
Once again, over.sqlite3 contains everything necessary for
Message-ID resolution. Also, Xapian may be completely
unnecessary with the advent of over.sqlite3, but that's for
another time.
Eric Wong [Thu, 20 Aug 2020 20:24:51 +0000 (20:24 +0000)]
searchview: convert nested and Atom display to over.sqlite3
git blob retrieval dominates on these, "&x=t" (nested) is
roughly the same due to increased overhead for ->get_percent
storage balancing out the mass-loading from SQLite.
Atom "&x=A" is sped up slightly and uses less memory in the
long-lived response.
Eric Wong [Thu, 20 Aug 2020 20:24:50 +0000 (20:24 +0000)]
searchview: speed up search summary by ~10%
Instead of loading one article at-a-time from over.sqlite3, we
can use SQL to mass-load IN (?,?, ...) all results with a single
SQLite query. Despite SQLite being in-process and having no
network latency, the reduction in SQL query executions from
loading multiple rows at once speeds things up significantly.
We'll keep the over->get_art optimizations from the previous
commit, since it still speeds up long-lived responses, slightly.
Eric Wong [Thu, 20 Aug 2020 20:24:49 +0000 (20:24 +0000)]
searchview: use over.sqlite3 instead of Xapian docdata
This is a step towards improving kernel page cache hit rates by
relying on over.sqlite3 for document data instead of Xapian.
Some micro-optimization to over->get_art was required to
maintain performance.
While this is unlikely to be a problem in current practice,
keeping Xapian DBs open for long responses can interfere with
free space recovery after -compact.
In the future, it will interfere with inbox search grouping
and lead to unexpected results.
Eric Wong [Thu, 20 Aug 2020 20:24:41 +0000 (20:24 +0000)]
search: v2: ensure shards are numerically sorted
This seems required to correctly get the NNTP article number
from Xapian docid on combined Xapian DBs. The default
(ASCII-betical) sorting was only acceptable for -imapd users
until somebody hit 11 (or more) shards, which is a rare case.
Eric Wong [Wed, 19 Aug 2020 08:02:33 +0000 (08:02 +0000)]
smsg: handle wide characters in raw mail headers
There may be messages in the wild with wide characters in
headers which aren't non-RFC2047 encoded. Assume UTF-8 so
those fields can round trip through over.sqlite3.
This doesn't affect docdata.glass in Xapian, but it does
affect how over.sqlite3 stores the same deflated info.
Eric Wong [Thu, 13 Aug 2020 08:04:04 +0000 (08:04 +0000)]
grok-pull.post_update_hook: favor --sequential-shard for HDD
--sequential-shard offers better performance on HDD than -j0
since the on-disk active set can be kept small (with -j $HIGH_NUM).
--batch-size can also be helpful for systems with much RAM.
Eric Wong [Thu, 13 Aug 2020 08:04:37 +0000 (08:04 +0000)]
index|compact|xcpdb: support --all switch
For -index, this is a convenient way to quickly index all
inboxes after a grok-pull. Might as well support it for
rarely used commands like -compact and -xcpdb, too.
Eric Wong [Wed, 12 Aug 2020 09:17:18 +0000 (09:17 +0000)]
xcpdb: wire up new index options and --help
--sequential-shard also disables the copy parallelism (--jobs),
so it can be useful for systems unable to handle parallel random
I/O but still want many shards.
There was a missing "use strict", too, which is fixed.
Eric Wong [Wed, 12 Aug 2020 09:17:16 +0000 (09:17 +0000)]
xapcmd: reduce CPU idling when shards exceeds job count
In case there's unbalanced shards AND we're limiting parallelism
while using many shards, spawn the next task in the queue ASAP
once a task is done, instead of waiting for all tasks to finish
before spawning the next batch.
Unbalanced shards probably isn't a big issue for most users;
however many smaller shards with few jobs can be useful for HDD
users to reduce the effect of random writes.
Eric Wong [Mon, 10 Aug 2020 02:12:04 +0000 (02:12 +0000)]
convert: check ARGV more correctly
Instead of silently ignoring excessive args, don't let a user
specify an extra directory. Furthermore, we'll support the odd
case where BOFH wants to name an $INBOX_DIR to be `0' :P
Eric Wong [Mon, 10 Aug 2020 02:12:00 +0000 (02:12 +0000)]
index: cleanup internal variables
Move away from hard-to-read alllowercase naming and favor
snake_case or separated-by-dashes.
We'll keep `--indexlevel' as-is for now, since it's been around
for several releases; but we'll support `--index-level' in the
CLI and update our documentation in a few months.
We'll also clarify that publicInbox.indexMaxSize is only
intended for -index, and not -watch or -mda.
Eric Wong [Mon, 10 Aug 2020 02:11:57 +0000 (02:11 +0000)]
msgmap: tmp_clone: simplify + meaningful filename
Trying to use the newer ->sqlite_backup_to_dbh method doesn't
seem worth it, as we'll have to support DBD::SQLite <= 1.60
another decade or more.
Dumping 'msgmap-XXXXXXX' into $INBOX_DIR can appear a bit
confusing to users, so give it a "mm_tmp-$PID-XXXXXXXX" name
to emphasize it's a temporary file tied to a given PID.
We also don't want to penalize read-only daemons with
loading File::Temp, so do it lazily.
-index now invokes ->DESTROY like xcpdb does, which is necessary
to cleanup $INBOX_DIR/msgmap-XXXXXXX files. We'll also exit
with the expected values for various signals by adding 128
as described in <https://www.tldp.org/LDP/abs/html/exitcodes.html>
-xcpdb now terminates worker processes and xapian-compact(1)
invocations when prematurely killed, too.
Eric Wong [Mon, 10 Aug 2020 02:11:54 +0000 (02:11 +0000)]
doc: index: more notes about latest changes
With LKML on an HDD, a giant --batch-size of 500m ends up being
pretty useful. I was able to index LKML in ~16 hours on a
system that had other activity on it. The big downside was it
was eating up over 5g of RAM :x.
We'll also fix up a duplicated indexBatchSize section, fix
formatting around global vs per-inbox indexSequentialShard,
and ensure section 5 manpages are linked correctly.
Eric Wong [Mon, 10 Aug 2020 02:11:53 +0000 (02:11 +0000)]
index: --sequential-shard works incrementally
We should never reindex all data in Xapian unless --reindex is
specified on the command-line. This means users who put
publicInbox.indexSequentialShard in their config file won't have
to put up with a full reindex at every invocation, only when
they specify --reindex.
We'll also cleanup the progress output to not emit non-sensical
ranges where the starting number is higher than the end.
Eric Wong [Sat, 8 Aug 2020 11:24:05 +0000 (11:24 +0000)]
favor `getconf _NPROCESSORS_ONLN` over GNU nproc
getconf(1) itself is POSIX, while `_NPROCESSORS_ONLN' is not.
However, FreeBSD (tested 11.4 and 12.1) and glibc (tested CentOS
7.x and Debian 10.x) both support `getconf _NPROCESSORS_ONLN'.
GNU coreutils (and thus `nproc' or `gnproc') are not installed
by default on the *BSDs, so we'll try the option most likely
to exist on both glibc and *BSDs out-of-the-box.
Eric Wong [Sat, 8 Aug 2020 04:59:49 +0000 (04:59 +0000)]
dir_idle: require Perl 5.22+ for kqueue
IO::KQueue requires us to use fileno(DIRHANDLE) for setting up
kqueue watches. This use of fileno() is only supported since
Perl 5.22, so BSD users on older Perl will have to fall back to
old polling.
This affects users of -watch, currently; but will affect other
read-only Xapian users soon.
Eric Wong [Fri, 7 Aug 2020 10:52:18 +0000 (10:52 +0000)]
index: add built-in --help / -?
Eventually, commonly-used commands run by the user will all
support --help / -? for user-friendliness. The changes from
up-front `use' to lazy `require' speed up `--help' by 3x or so.
Eric Wong [Fri, 7 Aug 2020 10:52:17 +0000 (10:52 +0000)]
searchidx: use Perl truthiness to detect XAPIAN_FLUSH_THRESHOLD
XAPIAN_FLUSH_THRESHOLD is a C string in the environment, so
users may be tempted to assign an empty string in in their
shell, e.g. `XAPIAN_FLUSH_THRESHOLD= <command>' instead of using
`unset' POSIX shell built-in.
With either a value of "0" or "" (empty string), Xapian will
fall back to its default (10000 documents), which causes grief
for memory-starved users.
Eric Wong [Fri, 7 Aug 2020 10:52:16 +0000 (10:52 +0000)]
index: max out XAPIAN_FLUSH_THRESHOLD if using --batch-size
If XAPIAN_FLUSH_THRESHOLD is unset, Xapian will default to
10000. That limits the effectiveness of users specifying
extremely large values of --batch-size.
While we're at it, localize the changes to globals since -index
may be eval-ed in tests (and perhaps production code in the
future).
Eric Wong [Fri, 7 Aug 2020 01:14:06 +0000 (01:14 +0000)]
index+xcpdb: rename `--no-sync' to `--no-fsync'
We'll continue supporting `--no-sync' even if its yet-to-make it
it into a release, but the term `sync' is overloaded in our
codebase which may be confusing to new hackers and users.
None of our our code nor dependencies issue the sync(2) syscall,
either, only fsync(2) and fdatasync(2).
Eric Wong [Fri, 7 Aug 2020 01:14:05 +0000 (01:14 +0000)]
index: support --xapian-only switch
This is useful for speeding up indexing runs when only Xapian
rules change but SQLite indexing doesn't change. This mostly
implies `--reindex', but does NOT pick up new messages (because
SQLite indexing needs to occur for that).
I'm leaving this undocumented in the manpage for now since it's
mainly to speed up development and testing. Users upgrading to
1.6.0 will be advised to `--reindex --rethread', anyways, due to
the threading improvements since 1.1.0-pre1.
It may make sense to document for 1.7+ when there's Xapian-only
indexing changes, though.