]> git.ipfire.org Git - thirdparty/public-inbox.git/log
thirdparty/public-inbox.git
15 months agolei/store: stop shard workers + cat-file on idle
Eric Wong [Tue, 16 Apr 2024 20:56:28 +0000 (20:56 +0000)] 
lei/store: stop shard workers + cat-file on idle

Schedule a timer to stop shard workers and the git-cat-file
process after a `barrier' command.  This allows us to save some
memory again when the lei-daemon is idle but preserves the fork
overhead reduction when issuing many commands in parallel or in
quick succession.

15 months agolei: use ->barrier to commit to lei/store
Eric Wong [Tue, 16 Apr 2024 20:56:27 +0000 (20:56 +0000)] 
lei: use ->barrier to commit to lei/store

barrier (synchronous checkpoint) is better than ->done with
parallel lei commands being issued (via '&' or different
terminals), since repeatedly stopping and restarting processes
doesn't play nicely with expensive tasks like `lei reindex'.

This introduces a slight regression in maintaining more
processes (and thus resource use) when lei is idle, but that'll
be fixed in the next commit.

15 months agov2 + lei/store: always wait for fast-import checkpoint
Eric Wong [Tue, 16 Apr 2024 20:56:26 +0000 (20:56 +0000)] 
v2 + lei/store: always wait for fast-import checkpoint

Since data going to git is the most important, always ensure
data is written to git before attempting to write anything to
SQLite or Xapian.

15 months agodoc: note MALLOC_MMAP_THRESHOLD_ as a potential workaround
Eric Wong [Mon, 15 Apr 2024 19:50:56 +0000 (19:50 +0000)] 
doc: note MALLOC_MMAP_THRESHOLD_ as a potential workaround

Large string processing + concurrency + caching/memoization
really brings out the worst in glibc malloc :<

15 months agolei: remove leftover debugging message
Eric Wong [Fri, 12 Apr 2024 18:04:14 +0000 (18:04 +0000)] 
lei: remove leftover debugging message

Noticed while working on other things...

Fixes: 299aac294ec3 (lei: do label/keyword parsing in optparse, 2023-10-02)
15 months agoio: avoid redundant waitpid in DESTROY
Eric Wong [Fri, 12 Apr 2024 18:04:13 +0000 (18:04 +0000)] 
io: avoid redundant waitpid in DESTROY

We shouldn't attempt to reap a process again after it's been
reaped asynchronously in the SIGCHLD handler.  Noticed while
working on changes to get lei/store to use checkpointing.

15 months agolei_remote: solver supports uncommitted blobs
Eric Wong [Fri, 12 Apr 2024 18:04:12 +0000 (18:04 +0000)] 
lei_remote: solver supports uncommitted blobs

This should improve `lei blob' and `lei rediff' functionality
for folks relying on `lei index' and allows future work to
improve parallelism via checkpointing in lei/store.

15 months agodoc: mknews: fix warnings when generating NEWS.html
Eric Wong [Fri, 12 Apr 2024 06:59:04 +0000 (06:59 +0000)] 
doc: mknews: fix warnings when generating NEWS.html

We need these values in the PSGI $env to generate the cache key,
even if we're not linkifying anything.

Fixes: 48cbe0c3 (www: linkify inbox addresses in To/Cc headers, 2024-01-09)
15 months agolei q: support --thread-id=$MSGID || -T $MSGID
Eric Wong [Fri, 12 Apr 2024 02:01:03 +0000 (02:01 +0000)] 
lei q: support --thread-id=$MSGID || -T $MSGID

This adds support for the "POST /$INBOX/$MSGID/?x=m?q=..."
added last year to support per-thread searches
764035c83 (www: support POST /$INBOX/$MSGID/?x=m&q=, 2023-03-30)
This only supports instances of public-inbox since 764035c83,
but unfortunately there hasn't been a release since then.

15 months agolei blob: fix attachment extraction for unimported||inflight
Eric Wong [Thu, 11 Apr 2024 18:58:26 +0000 (18:58 +0000)] 
lei blob: fix attachment extraction for unimported||inflight

Noticed while trying to make other reliability improvements to
lei...

15 months agowww: speed up global manifest.js.gz w/ "all" extindex
Eric Wong [Mon, 8 Apr 2024 09:49:21 +0000 (09:49 +0000)] 
www: speed up global manifest.js.gz w/ "all" extindex

By reducing internal event loop iterations, this brings 300+
inboxes down ~32ms to ~27ms.  It should also be more consistent
on servers with busy event loops since all the Xapian DB traffic
happens at once, theoretically mproving cache utilization.

15 months agosyscall: set default constants for Inline::C platforms
Eric Wong [Mon, 8 Apr 2024 09:48:43 +0000 (09:48 +0000)] 
syscall: set default constants for Inline::C platforms

This fixes compile errors on platforms we can't explicitly
support from pure Perl due to the lack of syscall stability
guarantees by the OS developers.

Reported-by: Gaelan Steele <gbs@canishe.com>
Tested-by: Gaelan Steele <gbs@canishe.com>
15 months agotreewide: avoid getpid for more ownership checks
Eric Wong [Mon, 1 Apr 2024 06:49:38 +0000 (06:49 +0000)] 
treewide: avoid getpid for more ownership checks

There are still some places where on_destroy isn't suitable,
This gets rid of getpid() calls in most of those cases to
reduce syscall costs and cleanup syscall trace output.

15 months agotreewide: avoid getpid() for OnDestroy checks
Eric Wong [Mon, 1 Apr 2024 06:49:37 +0000 (06:49 +0000)] 
treewide: avoid getpid() for OnDestroy checks

getpid() isn't cached by glibc nowadays and system calls are
more expensive due to CPU vulnerability mitigations.  To
ensure we switch to the new semantics properly, introduce
a new `on_destroy' function to simplify callers.
Furthermore, most OnDestroy correctness is often tied to the
process which creates it, so make the new API default to
guarded against running in subprocesses.

For cases which require running in all children, a new
PublicInbox::OnDestroy::all call is provided.

15 months agolock: get rid of PID guard
Eric Wong [Mon, 1 Apr 2024 06:49:36 +0000 (06:49 +0000)] 
lock: get rid of PID guard

PID guards for OnDestroy will be the default in an upcoming
change.  In the meantime, LeiMirror was the only user and
didn't actually need it.

16 months agoINSTALL: try to be less confusing about optional modules
Štěpán Němec [Sat, 16 Mar 2024 22:37:18 +0000 (23:37 +0100)] 
INSTALL: try to be less confusing about optional modules

16 months agoFix some typos and language nits in docs and comments
Štěpán Němec [Fri, 15 Mar 2024 14:30:48 +0000 (15:30 +0100)] 
Fix some typos and language nits in docs and comments

16 months agodoc: update release notes, marketing, and install
Eric Wong [Wed, 13 Mar 2024 21:02:11 +0000 (21:02 +0000)] 
doc: update release notes, marketing, and install

INSTALL now covers more of lei since I'm less uncomfortable
about it for 2.0 and points users towards the install/ helpers
if installing from source.

16 months agocodesearch: deduplicate $git->{nick} field
Eric Wong [Mon, 11 Mar 2024 19:40:12 +0000 (19:40 +0000)] 
codesearch: deduplicate $git->{nick} field

While PublicInbox::Config is responsible for some instances of
setting $git->{nick}, more PublicInbox::Git objects may be
created from loading the cindex and we should do our best to
reuse that memory, too.

Followup-to: 84ed7ec1c887 (dedupe inbox names, coderepo nicks + git dirs, 2024-03-04)
16 months agodoc: tuning: note reduced fragmentation w/ jemalloc
Eric Wong [Mon, 11 Mar 2024 19:40:11 +0000 (19:40 +0000)] 
doc: tuning: note reduced fragmentation w/ jemalloc

I may be mistaken, but I suspect the reason jemalloc handles
long-lived processes better than glibc is due to granularity
reduction being scaled to larger size classes.  This can waste
20% of an individual allocation, but increases the likelyhood
of reuse (without splitting/consolidating into other sizes).

In other words, glibc seems to try too hard to make the best fit
for initial allocations.  This ends up being suboptimal over
time as those allocations are freed and similar (but not
identical) allocations come in.  jemalloc sacrifices the best
initial fit for better fits over a long process lifetime.

16 months agocodesearch: deduplicate {ibx_score} name pairs
Eric Wong [Mon, 11 Mar 2024 19:40:10 +0000 (19:40 +0000)] 
codesearch: deduplicate {ibx_score} name pairs

With my current mirror of lore + gko, this saves over 300K
allocations and brings the allocation count in this area down
to under 5K.  The reduction in AV refs saves around 45MB RAM
according to measurements done live via Devel::Mwrap.

16 months agowww: use a dedicated limiter for blob solver
Eric Wong [Mon, 11 Mar 2024 19:40:09 +0000 (19:40 +0000)] 
www: use a dedicated limiter for blob solver

Wrap the entire solver command chain with a dedicated limiter.
The normal limiter is designed for longer-lived commands or ones
which serve a single HTTP request (e.g. git-http-backend or
cgit) and not effective for short memory + CPU intensive commands
used for solver.

Each overall solver request is both memory + CPU intensive: it
spawns several short-lived git processes(*) in addition to a
longer-lived `git cat-file --batch' process.

Thus running parallel solvers from a single -netd/-httpd worker
(which have their own parallelization) results in excessive
parallelism that is both memory and CPU-bound (not network-bound)
and cascade into slowdowns for handling simpler memory/CPU-bound
requests.  Parallel solvers were also responsible for the
increased lifetime and frequency of zombies since the event loop
was too saturated to reap them.

We'll also return 503 on excessive solver queueing, since these
require an FD for the client HTTP(S) socket to be held onto.

(*) git (update-index|apply|ls-files) are all run by solver and
    short-lived

16 months agolistener: don't loop on errors
Eric Wong [Mon, 11 Mar 2024 10:06:15 +0000 (10:06 +0000)] 
listener: don't loop on errors

Fortunately, this only affects `--multi-accept=' users, with
`--multi-accept=-1' users getting infinite loops.

I noticed this when EMFILE was reached on my setup, but any
error should cause us to give up accept(2) (at least
temporarily) and allow work for other items in the event loop to
be processed.

16 months agoimport: fix handling of init.defaultBranch
Eric Wong [Sun, 10 Mar 2024 21:41:30 +0000 (21:41 +0000)] 
import: fix handling of init.defaultBranch

We must chomp the newline in the branch name if it's set.

Reported-by: Rob Herring <robh@kernel.org>
Link: https://public-inbox.org/meta/CAL_JsqK7P4gjLPyvzxNEcYmxT4j6Ah5f3Pz1RqDHxmysTg3aEg@mail.gmail.com/
Fixes: 73830410e4336b77 (treewide: use run_qx where appropriate, 2023-10-27)
16 months agoimport: croak (instead of die) on write failures
Eric Wong [Fri, 8 Mar 2024 21:05:04 +0000 (21:05 +0000)] 
import: croak (instead of die) on write failures

This allows accurate reporting of the error location and can be
made to dump a Perl backtrace via PERL5OPT='-MCarp=verbose'.
Noticed while tracking down fast-import failures.

Link: https://public-inbox.org/meta/CAL_JsqK7P4gjLPyvzxNEcYmxT4j6Ah5f3Pz1RqDHxmysTg3aEg@mail.gmail.com/
16 months agolei: prevent empty {bytes} field in saved search
Eric Wong [Fri, 8 Mar 2024 21:05:03 +0000 (21:05 +0000)] 
lei: prevent empty {bytes} field in saved search

Noticed while tracking down fast-import crash bug report.

Link: https://public-inbox.org/meta/CAL_JsqK7P4gjLPyvzxNEcYmxT4j6Ah5f3Pz1RqDHxmysTg3aEg@mail.gmail.com/
16 months agodedupe inbox names, coderepo nicks + git dirs
Eric Wong [Mon, 4 Mar 2024 21:10:46 +0000 (21:10 +0000)] 
dedupe inbox names, coderepo nicks + git dirs

Inbox names, coderepo nicks, git_dir values are used heavily
as hash keys by the read-only coderepo WWW pieces.

Relying on CoW for mutable scalars on newer Perl doesn't work
well since CoW for those scalars are limited to 256 CoW references
and blow past that number when mapping thousands of coderepos
and inboxes to each other.  Instead, make the hash key up-front
and get the resulting string to point directly to the pointer
used by the hash key.

17 months agoeml: reuse ->decode buffer
Eric Wong [Tue, 13 Feb 2024 09:42:42 +0000 (09:42 +0000)] 
eml: reuse ->decode buffer

It's not really relevant at the moment, but a sufficiently
smart implementation could eventually save some memory here.
Perl already optimizes in-place sort (@x = sort @x), so there's
precedent for a potential future where a Perl implementation
could generally optimize in-place operations for non-builtin
subroutines, too.

17 months agoeml: avoid anonymous __WARN__ sub for encode/decode
Eric Wong [Tue, 13 Feb 2024 09:42:41 +0000 (09:42 +0000)] 
eml: avoid anonymous __WARN__ sub for encode/decode

Repeatedly allocating an anonymous sub is an expensive operation
and a potential source of leaks in older Perl.  Instead,
`local'-ize a global and use a permanent sub to workaround the
old Encode 2.87..3.12 leak.

17 months agocodesearch: generate_cxx: drop unused variables
Eric Wong [Mon, 12 Feb 2024 21:28:04 +0000 (21:28 +0000)] 
codesearch: generate_cxx: drop unused variables

We are just using the odd ref+deref (`${\...}') syntax and
don't need to calculate line numbers ourselves, nowadays.

17 months agoxap_helper_cxx: -O2 optimize read-only files by default
Eric Wong [Mon, 12 Feb 2024 21:28:03 +0000 (21:28 +0000)] 
xap_helper_cxx: -O2 optimize read-only files by default

While fast build times from -O0 is critical to my sanity when
actively working on C++, the files installed via package
managers or `make install' aren't likely to change frequently.

In that case, expensive -O2 optimizations make sense since the
10-20s saved from a single large --join more than covers the
cost of waiting on g++ to optimize.

17 months agodoc: fix formatting for CLI switch aliases
Eric Wong [Tue, 13 Feb 2024 09:31:29 +0000 (09:31 +0000)] 
doc: fix formatting for CLI switch aliases

`=item' elements in Pod need to be surrounded by empty lines.
It's an unfortunate waste of vertical space, but Pod is still better
than *roff and usually available out-of-the-box.

17 months agodoc: config: cgit=rewrite isn't implemented, yet
Eric Wong [Tue, 13 Feb 2024 09:31:28 +0000 (09:31 +0000)] 
doc: config: cgit=rewrite isn't implemented, yet

It'll probably be done for another release, I doubt most cgit
users are willing to completely replace it with our coderepo
viewer just yet...

17 months agowww: cgit: support non-standard cgitrc locations
Eric Wong [Tue, 13 Feb 2024 09:31:27 +0000 (09:31 +0000)] 
www: cgit: support non-standard cgitrc locations

If publicinbox.cgitrc is set in the config file, we'll ensure
cgit sees it as CGIT_CONFIG since the configured
publicinbox.cgitrc knob may not be the default path the cgit.cgi
binary was configured to use.

Furthermore, we'll respect CGIT_CONFIG in the environment if
publicinbox.cgitrc is unset in the config file at -httpd/-netd
startup.

17 months agoviewvcs: HTML fixes for commits
Eric Wong [Mon, 12 Feb 2024 13:13:50 +0000 (13:13 +0000)] 
viewvcs: HTML fixes for commits

The "patch is too large to show" text is now broken by an <hr>
to prevent it from being confused as part of a commit message
(or having somebody intentionally insert that text in a commit
message to confuse readers).  A missing </pre> is also necessary
before the <hr> tag for the related commit search form.

17 months agoviewvcs: parallelize commit display
Eric Wong [Mon, 12 Feb 2024 13:13:49 +0000 (13:13 +0000)] 
viewvcs: parallelize commit display

Similar to commit cbe2548c91859dfb923548ea85d8531b90d53dc3
(www_coderepo: use OnDestroy to render summary view,
2023-04-09), we can rely on OnDestroy and Qspawn to run
dependencies in a structured way and with some extra parallelism
for SMP users.

Perl (as opposed to POSIX sh) allows us to easily avoid
expensive patch generation for large root commits, and also avoid
needless `git patch-id' invocations for patches which are too
big to show.

Avoiding patch-id alone saved nearly 2s from the linux.git root
commit[1] with patch generation enabled and brought response
times down to ~6s (still slow).  Avoiding patch generation for
root commits brings it down to a few hundred milliseconds on a
public-facing server (nobody wants a 355MB patch rendered as
HTML, right?).

[1] torvalds/linux.git 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2

17 months agowww: quiet errors for git-{archive,http-backend}
Eric Wong [Fri, 9 Feb 2024 17:37:05 +0000 (17:37 +0000)] 
www: quiet errors for git-{archive,http-backend}

SIGPIPE (13) can be quite common with unreliable connections
and impatient clients, so just ignore them.

17 months agoview: decode In-Reply-To comments added by some MUAs
Eric Wong [Fri, 9 Feb 2024 09:33:01 +0000 (09:33 +0000)] 
view: decode In-Reply-To comments added by some MUAs

Štěpán Němec <stepnem@smrk.net> wrote:
> Eric Wong wrote:
> > Subject: [PATCH] view: decode In-Reply-To comments added by Gnus

> Or just "some MUAs"?  Who knows who else...

Yeah, I wouldn't be surprised if there were more...

---8<---
Subject: [PATCH] view: decode In-Reply-To comments added by some MUAs

Emacs-based MUAs (e.g. Gnus and rmail) can do it, and maybe
some others, too.  I noticed it in
<https://yhbt.net/lore/git/xmqqr0ho9oi9.fsf@gitster.g/>
while scanning for something else.

17 months agodaemon: quiet Email::Address::XS warnings properly
Eric Wong [Wed, 7 Feb 2024 22:49:19 +0000 (22:49 +0000)] 
daemon: quiet Email::Address::XS warnings properly

Setting $SIG{__WARN__} at the top-level no longer has any effect
since we localize $SIG{__WARN__} when entering ->event_step on
a per-listener basis.

Fixes: 60d262483a4d (daemon: use per-listener SIG{__WARN__} callbacks, 2022-08-08)
17 months agopop3d: support fcntl locks on OpenBSD i386
Eric Wong [Thu, 1 Feb 2024 20:59:48 +0000 (20:59 +0000)] 
pop3d: support fcntl locks on OpenBSD i386

The packaged Perl on OpenBSD i386 supports 64-bit file offsets
but not 64-bit integer support for 'q' and 'Q' with `pack'.
Since servers aren't likely to require lock files larger than
2 GB (we'd need an inbox with >2 billion messages), we can
workaround the Perl build limitation with explicit padding.

File::FcntlLock isn't packaged for OpenBSD <= 7.4 (but should be
in future releases), but I can test i386 OpenBSD on an extremely
slow VM.

Big endian support can be done, too, but I have no idea if
there's 32-bit BE users around nowadays...

17 months agolei: sort MH inputs sequentially by default
Eric Wong [Wed, 31 Jan 2024 10:20:20 +0000 (10:20 +0000)] 
lei: sort MH inputs sequentially by default

MH sequence numbers can be analogous to IMAP UIDs and NNTP
article numbers (or more like IMAP MSNs with clients which
pack).  In any case, sort then numerically by default to avoid
surprising users who treat NNTP spools and mlmmj archives as MH
folders.  This gives more coherent git history and resulting
NNTP/IMAP numbering when round-tripping MH -> v2 -> (NNTP|IMAP) -> MH

17 months agoscripts/import_*: update usage to include lei tips
Eric Wong [Wed, 31 Jan 2024 10:20:19 +0000 (10:20 +0000)] 
scripts/import_*: update usage to include lei tips

These scripts probably don't offer anything useful now that
lei has fleshed out read-only MH support and v2 outputs.

17 months agoscripts/slrnspool2maildir: use MHreader and LeiToMail
Eric Wong [Wed, 31 Jan 2024 10:20:18 +0000 (10:20 +0000)] 
scripts/slrnspool2maildir: use MHreader and LeiToMail

This contains gmane-specific header munging to unmunge the
things gmane dones to headers.  While we're at it, document the
generic `lei convert' invocation for users who don't need the
gmane-specific header munging.

17 months agoimport: drop redundant `use' statement
Eric Wong [Wed, 31 Jan 2024 10:20:17 +0000 (10:20 +0000)] 
import: drop redundant `use' statement

We don't need multiple `use PublicInbox::IO' statements to
import a subroutine.

17 months agolei convert: explicitly allow --sort for inputs
Eric Wong [Wed, 31 Jan 2024 10:20:16 +0000 (10:20 +0000)] 
lei convert: explicitly allow --sort for inputs

LeiToMail can't sort v2 output, but sorting MH input (and
NNTP spool + mlmmj archives) numerically makes sense.

17 months agolei_to_mail: improve SIGPIPE handling
Eric Wong [Tue, 30 Jan 2024 10:20:49 +0000 (10:20 +0000)] 
lei_to_mail: improve SIGPIPE handling

I can't reproduce this in t/lei-sigpipe.t with GIANT_INBOX_DIR.
In real-world usage, having a large `lei q -f text ...' output
piped to a pager and killing the pager prematurely could
trigger:

non-fatal error from PublicInbox::LeiToMail $?=256

messages in my terminal.  This is because $self->{lei} was
becoming undefined in the process cleanup process of
git_to_mail.  So flip the cleanup logic around and
unconditionally check for Git::cleanup state to bail out
early.

With this change, the `non-fatal error ...' message no longer
appears when I stop reading results early.

17 months agospawn: support some rlimit uses via Inline::C
Eric Wong [Tue, 30 Jan 2024 07:22:21 +0000 (07:22 +0000)] 
spawn: support some rlimit uses via Inline::C

BSD::Resource isn't packaged for Alpine (as of 3.19), but we
also have optional Inline::C support and already rely on calling
setrlimit(2) directly from the Inline::C version of pi_fork_exec.

17 months agodoc/lei-mail-formats: update MH read-only status
Eric Wong [Tue, 30 Jan 2024 06:31:10 +0000 (06:31 +0000)] 
doc/lei-mail-formats: update MH read-only status

I'm not looking forward to dealing with synchronization
problems if we end up dealing with writes...

17 months agowatch: support incremental updates from MH
Eric Wong [Tue, 30 Jan 2024 06:31:09 +0000 (06:31 +0000)] 
watch: support incremental updates from MH

The good news (compared to lei) is we only have to worry about
imports and don't care about the filename nor keywords, so it's
immune to .mh_sequences writing inconsistencies across MH
implementations and sequence number packing.

We still assume the writer will write the mail file with one of:
* rename(2) to create the final sequence number filename
* a single write(2) if not relying on rename(2)

mlmmj and mutt satisfy these requirements.  Python's Lib/mailbox.py
may, I'm not sure...

17 months agosyscall: use pure Perl sendmsg/recvmsg on *BSD
Eric Wong [Mon, 29 Jan 2024 21:23:19 +0000 (21:23 +0000)] 
syscall: use pure Perl sendmsg/recvmsg on *BSD

While syscall symbols (e.g. SYS_*) have changed on us in FreeBSD
during the history of Sys::Syscall and this project and did bite
us in some cases; the actual numbers don't get recycled for new
syscalls.  We're also fortunate that sendmsg and recvmsg syscalls
and associated msghdr and cmsg structs predate the BSD forks and
are compatible across all the BSDs I've tried.

OpenBSD routes Perl `syscall' through libc; while NetBSD + FreeBSD
document procedures for maintaining backwards compatibility.
It looks like Dragonfly follows FreeBSD, here.

Tested on i386 OpenBSD, and amd64 {Free,Net,Open,Dragonfly}BSD

This enables *BSD users to use lei, -cindex and future SCM_RIGHTS-only
features without needing Inline::C.

[1] https://cvsweb.openbsd.org/src/gnu/usr.bin/perl/gen_syscall_emulator.pl
[2] https://www.netbsd.org/docs/internals/en/chap-processes.html#syscall_versioning
[3] https://wiki.freebsd.org/AddingSyscalls#Backward_compatibily

17 months agosyscall: update formatting to match our codebase
Eric Wong [Mon, 29 Jan 2024 21:23:18 +0000 (21:23 +0000)] 
syscall: update formatting to match our codebase

Sys::Syscall needs separate patches anyways (if it ever gets
updated), and having a mix of indentation styles in our codebase
gets confusing.  We'll also update cfarm-related comments for
the current URL.

18 months agoview: /$INBOX/ links to topics_{new,active}.html
Eric Wong [Tue, 23 Jan 2024 22:09:00 +0000 (22:09 +0000)] 
view: /$INBOX/ links to topics_{new,active}.html

This makes the new endpoints easier-to-find.  The navigation is
still at the bottom of the page since I figured having it at the
top is too cluttered for users on small terminals.

18 months agowww_topics: simplify date column mapping
Eric Wong [Tue, 23 Jan 2024 22:08:59 +0000 (22:08 +0000)] 
www_topics: simplify date column mapping

We can rely on SQLite to map `MAX(ds)' to `ds' rather than
doing it in Perl, reducing the size of our Perl optree at the
(smaller) expense of SQLite bytecode.

18 months agowww: repolist: support globbing in URL
Eric Wong [Tue, 16 Jan 2024 11:52:55 +0000 (11:52 +0000)] 
www: repolist: support globbing in URL

This can make it easier to find deeply-nested repositories on my
mirror of git.kernel.org.  It's not perfect, since projects like
Linux use several completely different basenames (e.g. linux.git
vs vfs.git vs net.git), but it can still help find significant
matches further up a tree.

I don't expect glob characters to conflict with actual git
repositories used by reasonable people, but direct (non-glob)
hits are still tried first.

18 months agoconfig: glob2re: fix over-matching /**/foo
Eric Wong [Tue, 16 Jan 2024 11:52:54 +0000 (11:52 +0000)] 
config: glob2re: fix over-matching /**/foo

Noticed while adding wildcard support to WwwCoderepo...

18 months agoconfig: don't vivify invalid fields for coderepos
Eric Wong [Tue, 16 Jan 2024 11:52:53 +0000 (11:52 +0000)] 
config: don't vivify invalid fields for coderepos

We don't need 404s for non-existent coderepos creating fake
(and invalid) entries.  I noticed this while working on
subsequent changes to support globbing in URLs.

18 months agoexamples/unsubscribe-milter@.service: use KillMode=process
Eric Wong [Tue, 16 Jan 2024 11:52:52 +0000 (11:52 +0000)] 
examples/unsubscribe-milter@.service: use KillMode=process

This can be a multi-process daemon, but systemd should only kill
the top-level one.  And also finish a comment about the User
having access to the shared private key.

18 months agotests: clarify Email::MIME is only for development
Eric Wong [Tue, 16 Jan 2024 11:52:51 +0000 (11:52 +0000)] 
tests: clarify Email::MIME is only for development

We moved to PublicInbox::Eml a while back and have no plans
to go back to using Email::MIME, so don't tempt users and
packagers to waste disk space on Email::MIME.

18 months agolei_to_mail: show supported mbox formats on error
Eric Wong [Wed, 10 Jan 2024 11:18:55 +0000 (11:18 +0000)] 
lei_to_mail: show supported mbox formats on error

Users may accidentally or unknowingly write `mbox' and not know
we support 4 incompatible mbox variants.

18 months agolei+net_reader: show NNTP message in more failures
Eric Wong [Wed, 10 Jan 2024 11:18:54 +0000 (11:18 +0000)] 
lei+net_reader: show NNTP message in more failures

Showing absolutely nothing when hitting a server requiring
authentication is a very bad user experience.  While we're
at it, use Net::Cmd->message in more places where we experience
failure, too.

18 months agonet_reader: fix NNTP credential use
Eric Wong [Wed, 10 Jan 2024 11:18:53 +0000 (11:18 +0000)] 
net_reader: fix NNTP credential use

Clearly this was never tested until now, as passwords being
retrieved by git-credential got completely ignored and unused.
This enables users to connect to NNTP(S) servers requiring a
password.

18 months agowww: use autodie in more coderepo places
Eric Wong [Tue, 9 Jan 2024 11:39:28 +0000 (11:39 +0000)] 
www: use autodie in more coderepo places

This cuts down on code somewhat (before I add more :x)

18 months agoaddress: avoid [ undef, undef ] address pairs
Eric Wong [Tue, 9 Jan 2024 12:49:13 +0000 (12:49 +0000)] 
address: avoid [ undef, undef ] address pairs

For totally bogus things in address fields, we'll fall back to
showing the original entry in the name column when using
Email::Address::XS.

The pure Perl version differs here, but we'll just let them be
different when it comes to handling bogus data.

18 months agowww: linkify inbox addresses in To/Cc headers
Eric Wong [Tue, 9 Jan 2024 11:39:27 +0000 (11:39 +0000)] 
www: linkify inbox addresses in To/Cc headers

This makes it easier to discover contemporary messages
crossposted to other groups within the same WWW instance.
The internal cache is necessary for giant threads, and the
expiry mechanism is necessary to prevent attackers from
trivially OOM-ing.

18 months agogit: lowercase host in host_prefix_url
Eric Wong [Tue, 9 Jan 2024 11:39:26 +0000 (11:39 +0000)] 
git: lowercase host in host_prefix_url

This will make it more effective for use as a cache key.
I'm not entirely happy with this sub being in the Git module
since it's used by lei and command-line tools, but that's
for another day to deal with...

18 months agotest_common: key2sub: don't require final ';' in scripts
Eric Wong [Tue, 9 Jan 2024 11:39:25 +0000 (11:39 +0000)] 
test_common: key2sub: don't require final ';' in scripts

I noticed this when I wrote a new (but probably unnecessary) *.t
test and `make check-run' failed since I omitted the final
semi-colon after `done_testing'.

18 months agodoc: txt2pre: linkify -extindex(1), dedupe -config(5)
Eric Wong [Tue, 9 Jan 2024 11:39:24 +0000 (11:39 +0000)] 
doc: txt2pre: linkify -extindex(1), dedupe -config(5)

I noticed the HTML manpages didn't have -extindex linkification
while checking over the docs.  While adding it, I also noticed
-config(5) had two entries :x

18 months agogit: workaround occasional -watch error message
Eric Wong [Tue, 9 Jan 2024 11:39:23 +0000 (11:39 +0000)] 
git: workaround occasional -watch error message

I'm not sure how this happens (perl 5.34.1 on FreeBSD 13.2)
but it appears the {sock} check can succeed and then go undef
and become unable to call ->owner_pid.

This happens when libgit2 is in use, so perhaps that's a factor.
In any case, the rest of the tests succeed.

18 months agolei: MH: support inotify to detect updates
Eric Wong [Wed, 3 Jan 2024 10:23:15 +0000 (10:23 +0000)] 
lei: MH: support inotify to detect updates

This should help us deal with MH sequence number packing and
invalidating mail_sync.sqlite3.

18 months agoview: always show strict|loose note w/ multi-roots
Eric Wong [Mon, 1 Jan 2024 01:07:49 +0000 (01:07 +0000)] 
view: always show strict|loose note w/ multi-roots

For thread skeletons with multiple roots, it makes sense to
note the strict|loose delineation even when the first message
matches the desired Message-ID.

18 months agoover: re-sort Subject matches for WWW /T/ endpoint
Eric Wong [Mon, 1 Jan 2024 01:07:48 +0000 (01:07 +0000)] 
over: re-sort Subject matches for WWW /T/ endpoint

When retrieving loose (Subject) matches for a thread, we wanted
the most recent matches in reverse chronological order.
However, when displaying the /T/ endpoint generating the thread
skeleton, we prefer ascending chronological order to match the
flow of the conversation.

Reported-by: Askar Safin <safinaskar@gmail.com>
Link: https://public-inbox.org/meta/CAPnZJGAqsh8ZhPaCAy5M2NZVNcWrr_Hr94t32VXiyiTXwD9jRQ@mail.gmail.com/
18 months agolei: support reading MH for convert+import+index
Eric Wong [Fri, 29 Dec 2023 18:05:14 +0000 (18:05 +0000)] 
lei: support reading MH for convert+import+index

The MH format is widely-supported and used by various MUAs such
as mutt and sylpheed, and a MH-like format is used by mlmmj for
archives, as well.  Locking implementations for writes are
inconsistent, so this commit doesn't support writes, yet.

inotify|EVFILT_VNODE watches aren't supported, yet, but that'll
have to come since MH allows packing unused integers and
renaming files.

18 months agopure Perl inotify support
Eric Wong [Thu, 28 Dec 2023 04:23:00 +0000 (04:23 +0000)] 
pure Perl inotify support

This is a step towards improving the out-of-the-box experience
in achieving notifications without XS, extra downloads, and .so
loading + runtime mmap overhead.

This also fixes loongarch support of all Linux syscalls due to
a bad regexp :x

All the reachable Linux architectures listed at
<https://portal.cfarm.net/machines/list/> should be supported.
At the moment, there appears to be no reachable sparc* Linux
machines available to cfarm users.

Fixes: b0e5093aa3572a86 (syscall: add support for riscv64, 2022-08-11)
19 months agolei: use ->child_error API properly
Eric Wong [Sat, 16 Dec 2023 11:13:16 +0000 (11:13 +0000)] 
lei: use ->child_error API properly

I noticed this bug while developing another feature and tests
were getting SIGHUP (since SIGHUP == 1 on most systems).

19 months agolei index: support +L: labels
Eric Wong [Sat, 16 Dec 2023 11:13:15 +0000 (11:13 +0000)] 
lei index: support +L: labels

`lei index' should be capable of indexing the the same way
`lei import' does, but without the indexing.  I only noticed
this omission while developing a new feature.

19 months agot/pop3d-limit: use v1 inbox to test on ancient git
Eric Wong [Fri, 15 Dec 2023 20:22:49 +0000 (15:22 -0500)] 
t/pop3d-limit: use v1 inbox to test on ancient git

We don't need v2 features nor scalability to test POP3 stuff.

19 months agogit: quiet down `rev-parse --git-path' errors
Eric Wong [Fri, 15 Dec 2023 20:22:48 +0000 (15:22 -0500)] 
git: quiet down `rev-parse --git-path' errors

This fixes t/mda.t with git 1.8.5

19 months agocindex: --prune needs git 2.6+
Eric Wong [Fri, 15 Dec 2023 20:22:47 +0000 (15:22 -0500)] 
cindex: --prune needs git 2.6+

Older versions of git lack --batch-all-objects, and 2.6+ is
new enough already since v2, lei, etc all depend on it.

19 months agosearchidx: quiet down old git patchid
Eric Wong [Fri, 15 Dec 2023 20:22:46 +0000 (15:22 -0500)] 
searchidx: quiet down old git patchid

CentOS 7.x ships with git 1.8.5, so unless a CentOS 7.x user
enables 3rd-party repos[1], they'll be stuck with a version
of git without `--stable' (though I'm becoming skeptical of
indexing patchids at all).

[1] https://public-inbox.org/meta/20210421151308.yz5hzkgm75klunpe@nitro.local/

19 months agotests: quiet uninitialized warnings on CentOS 7.x
Eric Wong [Fri, 15 Dec 2023 20:22:45 +0000 (15:22 -0500)] 
tests: quiet uninitialized warnings on CentOS 7.x

Test::More distributed with Perl 5.16.3 on CentOS 7.x expects
the `$how_many' argument for `skip' and warns when its
uninitialized, so quiet that warning down.

19 months agodoc: RelNotes: more 2.0 updates
Eric Wong [Wed, 13 Dec 2023 10:51:07 +0000 (10:51 +0000)] 
doc: RelNotes: more 2.0 updates

But new ideas keep popping into muh brain :x

19 months agot/lei-import: relax EIO regexp
Eric Wong [Wed, 13 Dec 2023 00:50:19 +0000 (00:50 +0000)] 
t/lei-import: relax EIO regexp

musl uses "I/O error" while glibc uses "Input/output error"
I wish something like strerrorname_np(3) were portable
and built into Perl so we could just match on /EIO/.

19 months agogzip_filter: use OO ->zflush dispatch
Eric Wong [Wed, 13 Dec 2023 00:50:18 +0000 (00:50 +0000)] 
gzip_filter: use OO ->zflush dispatch

While it's not in a code path intended WwwCoderepo and RepoAtom,
those classes provide their own ->zflush, this can future-proof
our code against future subclasses at a minor performance cost.

19 months agowww_coderepo: fix read buffering
Eric Wong [Wed, 13 Dec 2023 00:50:17 +0000 (00:50 +0000)] 
www_coderepo: fix read buffering

Our read buffering only worked well with the stdout buffering on
glibc and *BSD libc, but not musl.  When reading the stdout of
git(1), we are likely to get smaller buffers and require more
reads on musl-based systems (tested Alpine Linux 3.19.0).

Thus we must prevent ->translate from being called with an empty
argument list (denoting EOF).  We'll also avoid some local
variable assignments while at it and favor the non-OO ->zflush
dispatch inside RepoAtom and WwwCoderepo subclasses.

19 months agot/convert-compact: allow S_ISGID bit
Eric Wong [Wed, 13 Dec 2023 00:50:16 +0000 (00:50 +0000)] 
t/convert-compact: allow S_ISGID bit

My user home directory on Alpine has S_ISGID set on it and every
subdirectory inherits it.  This includes my work tree and the
t/data-gen/* subdirectories.  So just ignore the presence (or
non-presence) of the S_ISGID bit on directories descended from
the cached t/data-gen/* directories.

Now, public-inbox-convert may want to preserve S_ISGID on the
newly-created v2 inbox, but that's a separate discussion.

19 months agotest_common: extract oct_is from search.t
Eric Wong [Wed, 13 Dec 2023 00:50:15 +0000 (00:50 +0000)] 
test_common: extract oct_is from search.t

And use it in convert-compact.t  This gives us nicer errors for
debugging a problem I noticed on Alpine Linux (tested 3.19.0)

19 months agoinstall: updates for Alpine Linux and apk
Eric Wong [Wed, 13 Dec 2023 00:50:14 +0000 (00:50 +0000)] 
install: updates for Alpine Linux and apk

Somewhat surprising that BSD::Resource hasn't been packaged for
Alpine, but otherwise pretty straightforward mapping with some
dependencies filled in manually.

19 months agoxap_helper_cxx: support clang w/o `c++' executable
Eric Wong [Wed, 13 Dec 2023 00:50:13 +0000 (00:50 +0000)] 
xap_helper_cxx: support clang w/o `c++' executable

This makes the C++ build work on Alpine Linux (tested 3.19.0)
without having to install g++ to get the `c++' executable.
I've tested this change with and without g++ on Alpine so it'll
continue to work if a user decides to install g++.

This should continue to work if the Xapian package on Alpine is
changed to link against libc++ instead of libstdc++, since we
only add `-lstdc++' as a fallback.  For reference, Xapian is
already linked against libc++ and not libstdc++ on FreeBSD 13.x

19 months agoxap_helper_cxx: decouple from Inline::C
Eric Wong [Wed, 13 Dec 2023 00:50:12 +0000 (00:50 +0000)] 
xap_helper_cxx: decouple from Inline::C

We don't actually need Inline::C support to build a standalone
executable implemented in C++.

19 months agotreewide: avoid strftime %k for portability
Eric Wong [Wed, 13 Dec 2023 00:50:11 +0000 (00:50 +0000)] 
treewide: avoid strftime %k for portability

The musl strftime(3) implementation on AlpineLinux 3.19.0
doesn't support `%k' and `%k' isn't in POSIX, either.  So we
fall back to using the `sprintf' perlop in the user-facing UI
since leading zeroes require needless overhead for my eyes and
brain to parse in the time.

19 months agolei inspect: drop unneeded strftime import
Eric Wong [Wed, 13 Dec 2023 00:50:10 +0000 (00:50 +0000)] 
lei inspect: drop unneeded strftime import

`lei inspect' uses the `iso8601' sub from LeiOverview.

19 months agotests: attempt compatibility w/ busybox lsof
Eric Wong [Wed, 13 Dec 2023 00:50:09 +0000 (00:50 +0000)] 
tests: attempt compatibility w/ busybox lsof

BusyBox lsof(1) ignores the `-p PID' argument and shows
the open files for every process it knows about.  BusyBox
lsof also lacks the `NODE' column of the non-BusyBox
implementation, so we'll rely on /proc/PID/fd/ in those
cases since the deleted file checks are Linux-only and
it's common to have procfs is mounted on /proc on Linux.

19 months agot/cindex*: skip --join when join(1) is missing
Eric Wong [Wed, 13 Dec 2023 00:50:08 +0000 (00:50 +0000)] 
t/cindex*: skip --join when join(1) is missing

While join(1) is POSIX, busybox on Alpine 3.19.0 does not
provide its functionality.  So just skip tests for now since
it's too much trouble to provide a workaround for an otherwise
common POSIX command.

19 months agotests: account for missing git-http-backend
Eric Wong [Wed, 13 Dec 2023 00:50:07 +0000 (00:50 +0000)] 
tests: account for missing git-http-backend

Alpine Linux ships git-http-backend in the `git-daemon'
package separately from `git', so we must test for its
existence before attempting to test functionality which
depends on it.

19 months agot/io: strace is optional on Linux
Eric Wong [Wed, 13 Dec 2023 00:50:06 +0000 (00:50 +0000)] 
t/io: strace is optional on Linux

There are many Linux (GNU or otherwise) which do not have
strace(1) installed.

19 months agoimap: replace Mail::Address fallback with AddressPP
Eric Wong [Sun, 10 Dec 2023 13:42:52 +0000 (13:42 +0000)] 
imap: replace Mail::Address fallback with AddressPP

Our pure-Perl (PublicInbox::AddressPP) fallback is closer to the
preferred Email::Address::XS (EAX) behavior than Mail::Address
is for ->name support.  EAX tends to be overkill with good spam
filtering, and using our own fallback means life is easier for
users with neither C/XS build tools nor a pre-built EAX package.

19 months agocindex: switch --join to use dfpost7 by default
Eric Wong [Fri, 8 Dec 2023 03:54:38 +0000 (03:54 +0000)] 
cindex: switch --join to use dfpost7 by default

Post-image blob OIDs are what solver already works with, and
longer OIDs may not be available in historical mail archives.

`patchid' turns out to be unsuitable since:
1) git's default diff algorithm has changed over time
2) users may use different diff options to improve readability

Of course, we could eventually run `lei rediff' during the index
phase to regenerate patchids, but that's out-of-scope for now
and likely to be too expensive.

19 months agoxap_helper: support term length limit
Eric Wong [Fri, 8 Dec 2023 03:54:37 +0000 (03:54 +0000)] 
xap_helper: support term length limit

This will allow us to use p2q-compatible specifications such as
"dfpost7" to only capture blob OIDs which are 7 characters in
length (the indexer will always index down to 7 characters)

19 months agomakefile: add `check-build' target
Eric Wong [Fri, 8 Dec 2023 03:54:36 +0000 (03:54 +0000)] 
makefile: add `check-build' target

A quick build check can detect bugs more quickly normal runtime
tests.

19 months agoxap_helper_cxx: drop chdir usage in build
Eric Wong [Fri, 8 Dec 2023 03:54:35 +0000 (03:54 +0000)] 
xap_helper_cxx: drop chdir usage in build

While chdir simplifies path manipulation on our end, its use
falls over when PERL5LIB/@INC contains relative paths which need
to be made absolute.  It's fewer lines of code to get eliminate
chdir usage than it is to keep using relative paths in most
places.