Eric Wong [Thu, 19 Mar 2020 08:32:56 +0000 (03:32 -0500)]
viewdiff: favor `qr' to precompile regexps
We can also avoid `o' regexp modifier, since it isn't
recommended by Perl upstream, anymore (although we don't
have any bugs or unintended behavior because of it).
Eric Wong [Thu, 19 Mar 2020 08:32:55 +0000 (03:32 -0500)]
daemon: do more immortal allocations up front
Doing immortal allocations late can cause those allocations
to end up in places where it fragments the heap. So do more
things up front for long-lived daemons.
Eric Wong [Thu, 19 Mar 2020 08:32:53 +0000 (03:32 -0500)]
wwwlisting: avoid lazy loading JSON module
We already lazy-load WwwListing for the CGI script, and
hiding another layer of lazy-loading makes things difficult
to do WWW->preload.
We want long-lived processes to do all long-lived allocations up
front to avoid fragmentation in the allocator, but we'll still
support short-lived processes by lazy-loading individual modules
in the PublicInbox::* namespace.
Mixing up allocation lifetimes (e.g. doing immortal allocations
while a large amount of space is taken by short-lived objects)
will cause fragmentation in any allocator which favors large
contiguous regions for performance reasons. This includes any
malloc implementation which relies on sbrk() for the primary
heap, including glibc malloc.
Eric Wong [Thu, 19 Mar 2020 08:32:51 +0000 (03:32 -0500)]
www: update ->preload for newer modules
We'll also avoid explicitly loading standard library modules
like POSIX and Digest::SHA, here; instead we load our own
modules and let those load whatever non-PublicInbox:: modules
they need.
Eric Wong [Thu, 19 Mar 2020 07:51:53 +0000 (07:51 +0000)]
doc: standards: add references to RFC 5322 (and RFC 822)
RFC 5322 is the latest one in this line, but much documentation
and even command-line options in other programs (e.g. git) refer
to RFC 2822 or even RFC 822.
Eric Wong [Tue, 17 Mar 2020 06:52:17 +0000 (06:52 +0000)]
http: fix RFC conformance w.r.t. message length
We need to favor "Transfer-Encoding: chunked" over the value of
the Content-Length header. We should also reject bogus,
duplicate and/or unreasonable values for both these, since they
can trigger unexpected behavior when combined with other HTTP
parsers in proxies such as varnish, nginx, haproxy, etc...
Eric Wong [Tue, 3 Mar 2020 05:03:11 +0000 (05:03 +0000)]
INSTALL: refer to the proper Debian version
Debian 10.0 was released July 2019, so update our documentation
to reflect that. While we're at it, fixup a broken footnote
reference for Inline::C, too.
Eric Wong [Sat, 7 Mar 2020 12:15:23 +0000 (12:15 +0000)]
daemon: remove unused $parent_pipe variable
We can just create a ParentPipe and let PublicInbox::DS
manage its life cycle. While we're at it, favor `\&coderef'
over `*coderef' so we're explicit about it being a code ref
and not some other ref type.
Eric Wong [Tue, 25 Feb 2020 09:23:03 +0000 (09:23 +0000)]
msgtime: assume +0000 if TZ missing when using Date::Parse
Some old emails don't have timezone offsets, since our
Date::Parse code path takes a liberal interpretation of dates,
fallback to using "+0000" as the timezone offset since it's
closer to the actual date of the message than whatever the
current date is.
Eric Wong [Wed, 26 Feb 2020 10:21:12 +0000 (10:21 +0000)]
import: drop '<' and '>' characters in addresses
Some strange "From:" lines will cause Email::Address::XS to
leave '<' (and presumably '>') in the address which
git-fast-import won't accept even if quoted. Workaround this
problem by deleting '<' and '>' the same way we delete them for
the ident name.
Eric Wong [Wed, 26 Feb 2020 00:44:05 +0000 (00:44 +0000)]
searchview: improve naming and simplify hash override
`%over' could be confused for the overview SQLite DB
instance, so call it `%override', instead. There's
also no need to write a loop to override a hash when
the language can do it for us.
Eric Wong [Mon, 24 Feb 2020 08:08:22 +0000 (08:08 +0000)]
v2writable: lookup_content => content_exists
It only needs to return a boolean, since none of the current
callers care about the return value. Thus avoid a hash table
assignment and use of `$smsg->{mime}', here.
Eric Wong [Mon, 24 Feb 2020 07:33:27 +0000 (07:33 +0000)]
viewdiff: remove optional CR handling
The only caller of `flush_diff' is `add_text_body', and that
already did CRLF conversion on the text part. The regexps in
SolverGit still need to preserve CR, however, since that
actually applies patches (instead of rendering them), and we
need to preserve CRLF patches for CRLF files.
Eric Wong [Mon, 24 Feb 2020 07:33:26 +0000 (07:33 +0000)]
hval: ascii_html: drop CRLF => LF conversion
Instead, we add CRLF conversion to the only remaining place
which needs it, ViewVCS. This save many redundant ops in in
many places.
The only other place where this mattered was in
View::add_text_body, but we already started doing CRLF
conversions when we added diff parsing and link generation for
ViewVCS. Otherwise, all other places we used this was for
header viewing and Email::MIME doesn't preserve CRLF in headers.
Eric Wong [Sun, 23 Feb 2020 22:47:15 +0000 (22:47 +0000)]
searchview: set obfuscation inbox properly
We never lookup `$ctx->{-obfuscate}' anywhere, as the
correct key is `$ctx->{-obfs_ibx}' since some of the
address obfuscation stuff is inbox-specific.
Note: some of the obfuscation stuff still needs tests,
but it's low-priority at the moment since I don't think
it's a good feature after all.
Eric Wong [Mon, 17 Feb 2020 11:00:48 +0000 (05:00 -0600)]
view: shorten life of MIME object for permalink
We don't need to hold onto the Email::MIME object across
multiple WwwResponse->getline calls, instead we can stuff
the rendered HTML of the first (and hopefully only) message
of the buffer into ctx->{-html_tip}.
Eric Wong [Sun, 16 Feb 2020 10:24:35 +0000 (10:24 +0000)]
doc: design_www: document solver endpoint
The blob regeneration (solving) part has been stable and
performant for over a year with no problems, even with web
crawlers constantly hitting it without needing rate limits.
All the other stuff is open to bikeshedding (as long as
my crappy hardware supports it :P)
Eric Wong [Sat, 15 Feb 2020 09:46:40 +0000 (09:46 +0000)]
view: remove last Hval->new caller
The object-oriented Hval API turned out to be less useful and
more clunky than I envisioned years ago, so get rid of it.
We'll no longer strip trailing whitespace from From: headers in
the HTML display, but I doubt anybody cares.
Eric Wong [Sat, 15 Feb 2020 09:46:39 +0000 (09:46 +0000)]
view: escape ampersand in Message-IDs
We need to escape ampersands (and some other characters for href
attributes), so introduce a `mid_href' sub to do just that.
'<', '>' and '"' were always escaped, so there's no risk of tag
or attribute injection, but creative Message-IDs could cause
confusion for some parsers and generate invalid URLs.
Start getting rid of the bloated, over-engineered OO Hval API
while we're at it, I only noticed this bug because I started
killing off Hval->new* callers.
Eric Wong [Sat, 15 Feb 2020 09:46:37 +0000 (09:46 +0000)]
view,searchview: avoid smsg method calls when using SQLite/Xapian
We already pre-populate the hashref when loading $smsg
(PublicInbox::SearchMsg) objects out of over.sqlite3 or Xapian,
so making expensive method calls isn't necessary in those cases.
We only need to use the method calls when SQLite or Xapian are
not available or are being populated (such as during indexing).
Eric Wong [Sat, 15 Feb 2020 09:46:36 +0000 (09:46 +0000)]
view: cleanup topic accumulation and dumping
Avoid needlessly normalizing the subject when dumping, since
it's pushed into the @$topic array during accumulation in
normalized form.
We can also safely treat $smsg as a hashref and avoid
calling "->ds" as a method since we know we've got that
loaded via Over||Search and won't have to use Email::MIME
header lookup methods.
Eric Wong [Fri, 7 Feb 2020 08:31:57 +0000 (02:31 -0600)]
doc: mark some TODO items as done
NNTP TLS and COMPRESS support and cgit spawning from
the WWW interface were implemented last year.
Given the lack of syscall number stability guarantee on the
OpenBSD and FreeBSD, I don't think supporting a pure-Perl kevent
is feasible. Inline::C may still be an option since IO::KQueue
is abandoned, though, as it is for some Linux-only syscalls and
maybe some POSIX ones not covered by POSIX.pm.
Eric Wong [Thu, 6 Feb 2020 20:59:45 +0000 (20:59 +0000)]
tests: switch to XML::TreePP for testing Atom feeds
XML::Feed pulls in a lot of dependencies, some of which XS.
That makes testing with blead or any non-OS-supplied Perl
installations more time consuming and more difficult because
of the need to have development headers and libraries for
libexpat1 or libxml2.
Performance from libexpat1 or libxml2 for our small tests cases
isn't relevant, either, and the pure Perl XML::TreePP seems up
to the task. It's also available in CentOS 7.x, FreeBSD 11.x,
and Debian, at least.
Eric Wong [Thu, 6 Feb 2020 08:49:36 +0000 (08:49 +0000)]
syscall: support Linux x32 ABI
The x32 ABI allows users to take advantage of the extra
registers on x86-64 without the bloat of 64-bit pointers and
longs.
This ought to be significant since Perl was designed when 32-bit
was prevalent; and the common structs for ops, hashes, scalars,
and arrays use longs (SSize_t/Size_t) for things which should
never need 64-bits when processing emails.
Debian's x32 port seems to work quite nicely under a chroot
on an amd64 Linux system. All tests pass under x32, now.
Eric Wong [Thu, 6 Feb 2020 04:03:47 +0000 (22:03 -0600)]
doc: remove .x/ subdirectory for Xapian manpages
There's no need to keep Xapian manpage renderings in a separate
subdirectory, after all.
Eliminating this difference between the local FS and URL path
will allow relative URLs to the Xapian manpages in our local
HTML documentation to work smoothly, since there was never any
".x/" path component for files served from public-inbox.org
Eric Wong [Tue, 4 Feb 2020 21:44:04 +0000 (21:44 +0000)]
doc: recommend -compact after --reindex
It's likely a user will be low on space after running --reindex,
so recommend the use of public-inbox-compact afterwards.
And add a few more notes about using public-inbox-compact to
clarify it's for inboxes-only (and not any old Xapian DBs) that
using xapian-compact(1) directly is error-prone and likely to
break things.
Eric Wong [Tue, 4 Feb 2020 04:44:23 +0000 (04:44 +0000)]
inbox: simplify ->description and ->cloneurl
We can use "//=" from Perl 5.10 to simplify the logic for these
methods. The use of chomp() in ->cloneurl was also unnecessary
since split(/\s+/s,...) already removes newlines.
Eric Wong [Tue, 4 Feb 2020 04:44:21 +0000 (04:44 +0000)]
www: stricter regexp for 405 errors
We want to match "GET" and "HEAD" exactly, not requests which
start with "GET" or end with "HEAD". This doesn't seem like
a real problem for public-inboxes which are actually public
data anyways.
Eric Wong [Tue, 4 Feb 2020 11:15:15 +0000 (11:15 +0000)]
doc: spellling fixes for manpages
The wording for publicinbox.nntpserver was awkward, too, and I
took this as opportunity to hopefully clarify it and favor
"hostname" for Internet addresses, because we already use
"address" to mean "email address" in the config.
Eric Wong [Sun, 2 Feb 2020 17:51:26 +0000 (17:51 +0000)]
spawn: actually die on (vfork|fork) failures
Commit 9f5a583694396f84 ("spawn (and thus popen_rd) die on failure")
was incomplete in that it only removed error checking for spawn
failures for non-(vfork|fork) calls, but the actual (vfork|fork)
PID result could still be undef.
Fixes: 9f5a583694396f84 ("spawn (and thus popen_rd) die on failure")
Eric Wong [Sun, 2 Feb 2020 06:52:18 +0000 (06:52 +0000)]
searchidxshard: rely on autoflush instead of ->flush
It reduces the number of ops and simplifies the code, slightly.
Add a missing IO::Handle import while we're at it, to be
explicit about which methods we use.
Eric Wong [Sun, 2 Feb 2020 06:52:15 +0000 (06:52 +0000)]
v2writable: nproc_shards: subtract 1 from given value
This is to be consistent with the `nproc(1)' code path. It also
quiets down a warning from Admin when "-j $JOBS" is specified,
since the master process (which distributes work to shards and
handles OverIdx and Msgmap) is considered a job on its own.
Eric Wong [Sat, 1 Feb 2020 09:12:13 +0000 (09:12 +0000)]
wwwtext: give "url" examples in sample config
inbox.$NAME.url is a common parameter and set by
public-inbox-init(1), so ensure we have lines for it and
emphasize it can be multi-value for .onion hidden services or
otherwise mirrored and available under multiple URLs.
Eric Wong [Thu, 30 Jan 2020 07:51:06 +0000 (07:51 +0000)]
convert: preserve highwater mark from v1 msgmap
If we're reusing the msgmap from a v1 inbox, we also need to
ensure the highwater mark doesn't get doubled in the v1->v2
conversion by internally triggering the equivalent of
"--reindex" on a fresh v2 inbox.
This was needed to convert an indexed v1 inbox which featured
messages with multiple Message-IDs in it. Fresh, unindexed
clones of v1 inboxes would not have been affected by this.
Eric Wong [Sun, 26 Jan 2020 23:41:02 +0000 (23:41 +0000)]
v2writable: newest epochs go first in alternates
New epochs are the most likely to have loose objects. git won't
be able to take advantage of pack indices and needs to scan
every alternate for the loose object via open/openat syscalls.
Those syscalls will add up some day when we've got hundreds or
thousands of epochs.
Eric Wong [Sun, 26 Jan 2020 10:29:24 +0000 (10:29 +0000)]
t/v2reindex.t: 5.10.1 glob compatibility
I'm not sure when `for (<"quoted string/glob/*">)' became
supported, and maybe it was inadvertant, but it fails
with Perl 5.10.1. Just use the glob() function to be
explicit.
Eric Wong [Sat, 25 Jan 2020 04:45:10 +0000 (04:45 +0000)]
viewdiff: rewrite and simplify
Instead of going line-by-line, use split() with a giant regexp
to capture groups of contiguous lines. This offloads state
management to the regexp itself and makes it FAR easier to
keep track of <span> and </span> pairings.
Performance seems roughly on par after this change for the
meta@public-inbox archives. It seems a tiny bit faster for
git@vger with xt/perf-msgview.t, likely due to the longer
messages and larger contiguous groups of lines having the same
prefix (or no prefix at all) and drastically reduces the number
of subroutine calls and Perl ops executed.
Eric Wong [Sat, 25 Jan 2020 04:45:08 +0000 (04:45 +0000)]
viewdiff: add "b=" param when missing "diff --git" line
<2841d2de-32ad-eae8-6039-9251a40bb00e@tngtech.com> as posted to
git@vger contained an otherwise valid diff without a "diff
--git" line. Generate a "b=" parameter in that case using the
"+++" line instead of the "diff --git" line. SearchIdx.pm no
longer uses the "diff --git" line for filename information,
either.
Eric Wong [Sat, 25 Jan 2020 04:45:07 +0000 (04:45 +0000)]
viewdiff: add "b=" param with non-standard diff prefix
<20180228012207.GB251290@aiede.svl.corp.google.com> (posted to
git@vger) uses "i" and "w" prefixes instead of the standard "a"
and "b" prefixes, ensure we emit a "b=$FILENAME" param for the
solver endpoint to improve search accuracy, syntax highlighting,
and information density in the URL itself.
Eric Wong [Sat, 25 Jan 2020 04:45:04 +0000 (04:45 +0000)]
linkify: move to_html over from ViewDiff
We use the same idiom in many places for doing two-step
linkification and HTML escaping. Get rid of an outdated
comment in flush_quote while we're at it.