]> Sergey Matveev's repositories - public-inbox.git/log
public-inbox.git
4 years agoview,searchview: avoid smsg method calls when using SQLite/Xapian
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).

4 years agoview: cleanup topic accumulation and dumping
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.

4 years agoview: dump_topics: better naming of top Subject
Eric Wong [Sat, 15 Feb 2020 09:46:35 +0000 (09:46 +0000)]
view: dump_topics: better naming of top Subject

We use `$top' in other places, so name it to `$top_subj'
consistently for `$subj' and `$prev_subj' comparisons down
the function.

4 years agoview: single id="t" for multi-Subject messages
Eric Wong [Sat, 15 Feb 2020 09:46:34 +0000 (09:46 +0000)]
view: single id="t" for multi-Subject messages

While multi-Subject messages are unfortunate, try not to
generate confusing/invalid HTML with multiple elements
having the same HTML id attribute.

4 years agoview: remove mhref arg from multipart_text_as_html
Eric Wong [Sat, 15 Feb 2020 09:46:33 +0000 (09:46 +0000)]
view: remove mhref arg from multipart_text_as_html

No point in passing something on stack only to stash it
into the $ctx which holds most other parameters used for
rendering the HTML.

4 years agot/msg_iter: test for X-UNKNOWN charset from Alpine
Eric Wong [Fri, 14 Feb 2020 07:05:22 +0000 (07:05 +0000)]
t/msg_iter: test for X-UNKNOWN charset from Alpine

A long overdue test for behavior established in 2016.

Fixes: 1b28cc7f00a866cb ("view: try assuming UTF-8 for bogus charsets")
4 years agodoc: update v1.3.0.eml with actual headers, start v1.4.0
Eric Wong [Mon, 10 Feb 2020 05:55:21 +0000 (23:55 -0600)]
doc: update v1.3.0.eml with actual headers, start v1.4.0

Bigger changes coming :>

4 years agopublic-inbox 1.3.0 v1.3.0
Eric Wong [Mon, 10 Feb 2020 05:40:27 +0000 (05:40 +0000)]
public-inbox 1.3.0

4 years agot/multi-mid: skip properly w/o DBD::SQLite
Eric Wong [Sat, 8 Feb 2020 18:30:40 +0000 (18:30 +0000)]
t/multi-mid: skip properly w/o DBD::SQLite

SearchIdx always requires DBD::SQLite, so only require it
after we've passed `require_mods(qw(DBD::SQLite))'.

4 years agoconvert: preserve indexlevel on conversions
Eric Wong [Sat, 8 Feb 2020 18:08:49 +0000 (18:08 +0000)]
convert: preserve indexlevel on conversions

We don't want to blow up users storage too badly when converting
v1 to v2 or break because they don't have Xapian bindings installed.

4 years agodoc: more 1.3.0 release notes updates
Eric Wong [Fri, 7 Feb 2020 08:31:58 +0000 (02:31 -0600)]
doc: more 1.3.0 release notes updates

4 years agodoc: mark some TODO items as done
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.

4 years agodoc: update copyright for standards.perl
Eric Wong [Fri, 7 Feb 2020 08:31:56 +0000 (02:31 -0600)]
doc: update copyright for standards.perl

It was missing "(C)", so gnulib update-copyright missed it.

4 years agotests: switch to XML::TreePP for testing Atom feeds
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.

4 years agosyscall: support Linux x32 ABI
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.

4 years agotreewide: run update-copyrights from gnulib for 2019
Eric Wong [Thu, 6 Feb 2020 19:14:48 +0000 (13:14 -0600)]
treewide: run update-copyrights from gnulib for 2019

I didn't wait until September to do it, this year!

4 years agoMANIFEST: add flow.{ge,txt}
Eric Wong [Thu, 6 Feb 2020 19:11:49 +0000 (19:11 +0000)]
MANIFEST: add flow.{ge,txt}

Oops :x

4 years agodoc: v1: add a reference to git-filter-repo(1), too
Eric Wong [Thu, 6 Feb 2020 04:03:49 +0000 (22:03 -0600)]
doc: v1: add a reference to git-filter-repo(1), too

The git-filter-branch(1) manpage itself recommends git-filter-repo,
nowadays due to performance and safety problems.

4 years agodoc: txt2pre: auto-linkify manpage references
Eric Wong [Thu, 6 Feb 2020 04:03:48 +0000 (22:03 -0600)]
doc: txt2pre: auto-linkify manpage references

This can be more convenient for people browsing HTML docs
remotely or locally.

4 years agodoc: remove .x/ subdirectory for Xapian manpages
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

4 years agodoc: add data flow diagram using Graph::Easy
Eric Wong [Thu, 6 Feb 2020 04:03:46 +0000 (22:03 -0600)]
doc: add data flow diagram using Graph::Easy

Maybe this can make it easier for new and potential
users to understand what's going on.

4 years agot/multi-mid: don't access ~/.public-inbox/config
Eric Wong [Thu, 6 Feb 2020 09:18:37 +0000 (09:18 +0000)]
t/multi-mid: don't access ~/.public-inbox/config

It can cause unpredictable behavior and also slow things down.

Followup-to: e4d3be19612b2082 ("t: localize the PI_CONFIG env")
4 years agodoc: recommend -compact after --reindex
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.

4 years agoover: simplify read-only vs read-write checking
Eric Wong [Tue, 4 Feb 2020 04:44:25 +0000 (04:44 +0000)]
over: simplify read-only vs read-write checking

No need to call ref() and do a string comparison.  Add some
extra tests using the {ReadOnly} attribute in DBI.pm.

4 years agoinbox: remove TODO item for msg_by_path
Eric Wong [Tue, 4 Feb 2020 04:44:24 +0000 (04:44 +0000)]
inbox: remove TODO item for msg_by_path

It's an old function which only gets called by inboxes w/o
SQLite indices.

4 years agoinbox: simplify ->description and ->cloneurl
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.

4 years agowww: serve $INBOX_DIR/description as $INBOX_URL/description
Eric Wong [Tue, 4 Feb 2020 04:44:22 +0000 (04:44 +0000)]
www: serve $INBOX_DIR/description as $INBOX_URL/description

Instead of serving $INBOX_DIR/all.git/description, since
$INBOX_DIR/all.git/description is not described in the
default message when it's missing.

4 years agowww: stricter regexp for 405 errors
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.

4 years agodoc: spellling fixes for manpages
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.

4 years agospawn: actually die on (vfork|fork) failures
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")
4 years agov2writable: more ways to detect online CPU count
Eric Wong [Sun, 2 Feb 2020 06:52:22 +0000 (06:52 +0000)]
v2writable: more ways to detect online CPU count

OpenBSD and FreeBSD support `getconf NPROCESSORS_ONLN` (no
leading underscore).  They may also have GNU nproc installed as
"gnproc".

We may also encounter Linux systems w/o GNU coreutils, but able
to use `getconf _NPROCESSORS_ONLN` (with leading underscore).

4 years agodoc: -convert: document switches
Eric Wong [Sun, 2 Feb 2020 06:52:21 +0000 (06:52 +0000)]
doc: -convert: document switches

These switches have always been there, but were not
documented until now.

4 years agoconvert: fix --no-index switch
Eric Wong [Sun, 2 Feb 2020 06:52:20 +0000 (06:52 +0000)]
convert: fix --no-index switch

The (currently undocumented) "--no-index" flag did not trigger
the V2Writable->done call necessary to make the import
successful.

Fixes: eea47b676127bcdb ("convert: preserve highwater mark from v1 msgmap")
4 years agoconvert: shift @ARGV explicitly
Eric Wong [Sun, 2 Feb 2020 06:52:19 +0000 (06:52 +0000)]
convert: shift @ARGV explicitly

Relying on implicit "@_" for shift fails with
TestCommon::_run_sub iff GetOptions modifies @ARGV.

4 years agosearchidxshard: rely on autoflush instead of ->flush
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.

4 years agoconvert: remove unused variables capturing :from
Eric Wong [Sun, 2 Feb 2020 06:52:17 +0000 (06:52 +0000)]
convert: remove unused variables capturing :from

Looking at git history, they were never used.

4 years agov2writable: do not clobber {shards} or {parallel} if unset
Eric Wong [Sun, 2 Feb 2020 06:52:16 +0000 (06:52 +0000)]
v2writable: do not clobber {shards} or {parallel} if unset

The $jobs parameter in `public-inbox-convert' is passed to
V2Writable->init_inbox as `undef' by default, causing
parallelization to be disabled.

Instead, leave the underlying {parallel} flag untouched if
$shards is undef and do not clobber the default shard count.

This allows us to take advantage of multicore systems when
running public-inbox-convert with no command-line switches.

4 years agov2writable: nproc_shards: subtract 1 from given value
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.

4 years agot/multi-mid.t: extra test for -convert highwater mark
Eric Wong [Sun, 2 Feb 2020 06:52:14 +0000 (06:52 +0000)]
t/multi-mid.t: extra test for -convert highwater mark

This is derived from a real-world test case where I encounterd
multiple Message-IDs in a v1 inbox causing regen problems.

Fixes: eea47b676127bcdb ("convert: preserve highwater mark from v1 msgmap")
4 years agodoc: more 1.3.0 release notes updates
Eric Wong [Fri, 31 Jan 2020 23:45:18 +0000 (23:45 +0000)]
doc: more 1.3.0 release notes updates

Some updates with recent bugfixes and a few wording/formatting
improvements.

4 years agoconfig: assume multiple cgit URLs, too
Eric Wong [Sat, 1 Feb 2020 09:12:15 +0000 (09:12 +0000)]
config: assume multiple cgit URLs, too

Since we support inboxes with multiple URLs and multiple
infourls to reduce reliance on SPOFs, we'll do the same with
cgit URLs.

4 years agosolver: join multiple URLs with "||"
Eric Wong [Sat, 1 Feb 2020 09:12:14 +0000 (09:12 +0000)]
solver: join multiple URLs with "||"

It seems to make sense to the target audience that any of
the URLs displayed could work.

4 years agowwwtext: give "url" examples in sample config
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.

4 years agowwwtext: show multiple infourl values properly
Eric Wong [Sat, 1 Feb 2020 09:12:12 +0000 (09:12 +0000)]
wwwtext: show multiple infourl values properly

This is now an array, so ensure it's shown properly in the
sample config, instead of "ARRAY(0xI8BADBEEF)" or similar.

Fixes: 1988d730c0088e8b "config: support multi-value inbox.*.*url"
4 years agoconvert: preserve highwater mark from v1 msgmap
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.

4 years agomboxgz: ensure gzipped mboxes always have filenames
Eric Wong [Thu, 30 Jan 2020 09:19:06 +0000 (09:19 +0000)]
mboxgz: ensure gzipped mboxes always have filenames

Lets always have Content-Disposition for files intended
to be downloaded for consumption by non-browsers, such
as pigz, zcat, "git am".

This is also to be consistent with the non-gzipped mbox
$MESSAGE_ID/raw endpoint.

4 years agot/psgi_search: test for subject-free messages
Eric Wong [Thu, 30 Jan 2020 09:19:05 +0000 (09:19 +0000)]
t/psgi_search: test for subject-free messages

Apparently I fixed this bug a while back in commit
f94c3a195a25a31d0215cd175938008fca473378 but did
not write tests.

4 years agov2writable: newest epochs go first in alternates
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.

4 years agoINSTALL: fix Linux::Inotify2 package name
Eric Wong [Tue, 28 Jan 2020 02:23:03 +0000 (02:23 +0000)]
INSTALL: fix Linux::Inotify2 package name

The "2" is important, since "Linux::Inotify" without the "2"
is not available from Debian 9/10 or CentOS 7.x and seems
unmaintained.

4 years agot/v2reindex.t: 5.10.1 glob compatibility
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.

4 years agot/hl_mod: document IO::Handle for autoflush
Eric Wong [Sun, 26 Jan 2020 10:29:23 +0000 (10:29 +0000)]
t/hl_mod: document IO::Handle for autoflush

We don't need IO::File for this test, but IO::Handle
is needed for ->autoflush with Perl <5.14.

Note: I haven't tested highlight.pm under 5.10.1 since
it's a weird dependency which isn't easy to install w/o
distro support.

4 years agoavoid relying on IO::Handle/IO::File autoload
Eric Wong [Sun, 26 Jan 2020 10:29:22 +0000 (10:29 +0000)]
avoid relying on IO::Handle/IO::File autoload

Perl 5.14+ gained the ability to autoload IO::File
(and IO::Handle) on missing methods, so relying on
this breaks under 5.10.1.

There's no reason to load IO::File or IO::Handle
when built-in perlops work fine and are even a hair
faster.

4 years agodaemon: provide TCP_DEFER_ACCEPT for Perl <5.14
Eric Wong [Sun, 26 Jan 2020 10:29:21 +0000 (10:29 +0000)]
daemon: provide TCP_DEFER_ACCEPT for Perl <5.14

Socket::TCP_DEFER_ACCEPT() did not appear in the Socket module
distributed with Perl until 5.14, despite it being available
since Linux 2.4.

4 years agoviewdiff: rewrite and simplify
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.

4 years agoviewdiff: use autovivification for long_path hash
Eric Wong [Sat, 25 Jan 2020 04:45:09 +0000 (04:45 +0000)]
viewdiff: use autovivification for long_path hash

No sense in wasting code to do something the interpreter
already does for us.

4 years agoviewdiff: add "b=" param when missing "diff --git" line
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.

4 years agoviewdiff: add "b=" param with non-standard diff prefix
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.

4 years agosearchidx: don't assume "a/" and "b/" as prefixes
Eric Wong [Sat, 25 Jan 2020 04:45:06 +0000 (04:45 +0000)]
searchidx: don't assume "a/" and "b/" as prefixes

Some people use "--{src,dst}-prefix=", try to deal with those
since git-apply can handle them when called by solver.

4 years agosearchidx: skip filenames on "diff --git ..."
Eric Wong [Sat, 25 Jan 2020 04:45:05 +0000 (04:45 +0000)]
searchidx: skip filenames on "diff --git ..."

We already capture filenames on the lines beginning
with "---" and "+++", so it's redundant work to capture
filenames from "diff --git ..." lines.

4 years agolinkify: move to_html over from ViewDiff
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.

4 years agolinkify: compile $LINK_RE once
Eric Wong [Sat, 25 Jan 2020 04:45:03 +0000 (04:45 +0000)]
linkify: compile $LINK_RE once

This gives a 3-4% performance improvement in xt/perf-msgview.t
with a mirror of https://public-inbox.org/meta/

4 years agoview: inline and eliminate msg_html
Eric Wong [Sat, 25 Jan 2020 04:45:02 +0000 (04:45 +0000)]
view: inline and eliminate msg_html

No need to keep the old sub around, anymore.  Rename auxiliary
subs to "msg_page_*" instead of the "html" version.

4 years agoxt/perf-msgview: switch to multipart_text_as_html
Eric Wong [Sat, 25 Jan 2020 04:45:01 +0000 (04:45 +0000)]
xt/perf-msgview: switch to multipart_text_as_html

It's a more widely-used (but still internal) API which will
probably last longer than msg_html.  It also reaches deeper into
the stack and avoids the overhead of ->getline via PSGI, so it's
faster and gives a more accurate measurement of lower-level parts.

4 years agotests: move the majority of t/view.t into t/plack.t
Eric Wong [Sat, 25 Jan 2020 04:45:00 +0000 (04:45 +0000)]
tests: move the majority of t/view.t into t/plack.t

And some more into t/mid.t.  PublicInbox::View::msg_html may
change internally, so lets rely on the stable PSGI interface
to test it, rather than a test which reaches deep into the
internals.

4 years agoinit: use Import::run_die instead of system()
Eric Wong [Sat, 25 Jan 2020 04:44:59 +0000 (04:44 +0000)]
init: use Import::run_die instead of system()

We already load PublicInbox::Import via
PublicInbox::InboxWritable, so it's not an extra module
to load.  This can give us a slight speedup in tests.

4 years agot/plack.t: modernize and unindent
Eric Wong [Sat, 25 Jan 2020 04:44:58 +0000 (04:44 +0000)]
t/plack.t: modernize and unindent

This test will be expanded, and we can take advantage of
run_script to simplify our internal API use.

4 years agoview: start performing buffering into {obuf}
Eric Wong [Sat, 25 Jan 2020 04:44:57 +0000 (04:44 +0000)]
view: start performing buffering into {obuf}

Get rid of the confusingly named {rv} and {tip} fields
and unify them into {obuf} for readability.

{obuf} usage may be expanded to more areas in the future.  This
will eventually make it easier for us to experiment with
alternative buffering schemes.

4 years agowwwstream: discard single-use $ctx fields after use
Eric Wong [Sat, 25 Jan 2020 04:44:56 +0000 (04:44 +0000)]
wwwstream: discard single-use $ctx fields after use

This should make it clear that we only use these elements
once and can discard them.  While we're in the area, avoid
escaping '"' by using qq() instead of "" to quote strings
requiring interpolation.

4 years agoview: simplify duplicate Message-ID handling
Eric Wong [Sat, 25 Jan 2020 04:44:55 +0000 (04:44 +0000)]
view: simplify duplicate Message-ID handling

It's an uncommon code path, no need to make it more complex
than it needs to be by having extra sub parameters.

4 years agoview: thread_skel: drop constant tpfx parameter
Eric Wong [Sat, 25 Jan 2020 04:44:54 +0000 (04:44 +0000)]
view: thread_skel: drop constant tpfx parameter

It hasn't changed in a few years.  Now we can rely on constant
folding to avoid extraneous ops to the $skel buffer.

4 years agoview: reduce parameters for html_footer
Eric Wong [Sat, 25 Jan 2020 04:44:53 +0000 (04:44 +0000)]
view: reduce parameters for html_footer

Put more logic into html_footer and less in its only caller so
we can control the buffering and string creation.

4 years agosearchview: keep $noop sub private to the package
Eric Wong [Sat, 25 Jan 2020 04:44:52 +0000 (04:44 +0000)]
searchview: keep $noop sub private to the package

It'll always be used as a callback, so there's no point in
giving it a name to be called non-anonymously.  Making
assigments to it is slightly faster since there's no need
to repeatedly do a lookup by name.

4 years agoview: improve readability around walk_thread
Eric Wong [Sat, 25 Jan 2020 04:44:51 +0000 (04:44 +0000)]
view: improve readability around walk_thread

Pass \&coderefs explicitly to walk_thread, and add some
prototypes + comments to describe what goes on.

4 years agowww: use "skel" terminology consistently
Eric Wong [Sat, 25 Jan 2020 04:44:50 +0000 (04:44 +0000)]
www: use "skel" terminology consistently

This saves us a few comments and confusion.   Yes, it's a
destination so "dst" can be appropriate, but we may be using
that term elsewhere.

4 years agowww*stream: favor \&close instead of *close
Eric Wong [Sat, 25 Jan 2020 04:44:49 +0000 (04:44 +0000)]
www*stream: favor \&close instead of *close

Be explicit that we're making a code reference, and not
a reference to a scalar, array, hash, or IO...

4 years agoxapcmd: increase scope of lock
Eric Wong [Sun, 26 Jan 2020 01:17:44 +0000 (01:17 +0000)]
xapcmd: increase scope of lock

The old lock scope was only sufficient for protecting against
concurrent modifications from the common -mda, -watch, or -learn
writers.

It was not sufficient for protecting against parallel -compact
or -xcpdb invocations from eager admins.  Most of the time this
only leads to confusing and misleading warning messages, but
parallel xcpdb --reshard could lead to errors.

4 years agosearch: {version} => {ibx_ver}
Eric Wong [Sun, 26 Jan 2020 01:17:43 +0000 (01:17 +0000)]
search: {version} => {ibx_ver}

We don't confuse human readers with the Xapian schema version.
We also want to make it obvious this is the version of the inbox
we're indexing, these are Search or SearchIdx objects, not Inbox
objects.

4 years agoinbox: add ->version method
Eric Wong [Sun, 26 Jan 2020 01:17:42 +0000 (01:17 +0000)]
inbox: add ->version method

This allows us to simplify version checking by avoiding
"//" or "||" operators sprinkled around.

4 years agoswitch to sysseek + sysread for serving static files
Eric Wong [Sat, 25 Jan 2020 20:57:57 +0000 (20:57 +0000)]
switch to sysseek + sysread for serving static files

The "perlio" layer doesn't do read(2) syscalls over 8192 bytes
at the moment, and binmode($fh, ':unix') leaks[1].  So use
sysseek and sysread for now, since I can't see retaining
compatibility with PerlIO::scalar being worth the trouble.

[1] http://nntp.perl.org/group/perl.perl5.porters/256918

4 years agos/news.gmane.org/news.gmane.io/
Eric Wong [Sat, 25 Jan 2020 08:59:58 +0000 (08:59 +0000)]
s/news.gmane.org/news.gmane.io/

gmane still has a NNTP server, so update links to point to it.

cf. https://lars.ingebrigtsen.no/2020/01/06/whatever-happened-to-news-gmane-org/

4 years agowwwstatic: wire up buffer bypass for -httpd
Eric Wong [Fri, 24 Jan 2020 09:43:52 +0000 (09:43 +0000)]
wwwstatic: wire up buffer bypass for -httpd

This prevents public-inbox-httpd from buffering ->getline
results from a static file into another temporary file when
writing to slow clients.  Instead we inject the static file
ref with offsets and length directly into the {wbuf} queue.

It took me a while to decide to go this route, some
rejected ideas:

1. Using Plack::Util::set_io_path and having PublicInbox::HTTP
   serve the result directly.  This is compatible with what
   some other PSGI servers do using sendfile.  However, neither
   Starman or Twiggy currently use sendfile for partial responses.

2. Parsing the Content-Range response header for offsets and
   lengths to use with set_io_path for partial responses.

These rejected ideas required increasing the complexity of HTTP
response writing in PublicInbox::HTTP in the common, non-static
file cases.  Instead, we made minor changes to the colder write
buffering path of PublicInbox::DS and leave the hot paths
untouched.

We still support generic PSGI servers via ->getline.  However,
since we don't know the characteristics of other PSGI servers,
we no longer do a 64K initial read in an attempt to negotiate a
larger TCP window.

4 years agods: tmpio: store offsets per-buffer
Eric Wong [Fri, 24 Jan 2020 09:43:51 +0000 (09:43 +0000)]
ds: tmpio: store offsets per-buffer

We want to be able to inject existing file handles + offsets and
even lengths into this in the future, without going through the
->getline interface[1]

We also switch to using a 64K buffer size since we can safely
discard whatever got truncated on write and full writes can help
negotiate a larger TCP window for high-latency, high-bandwidth
links.

While we're at it, make it obvious that we're using O_APPEND for
our tmpfile() interface so we can seek freely for reading while
the writer always prints to the end of the file.

[1] the getline interface for serving static files may result
    in us buffering on-FS data into another temporary file,
    which is a waste.

4 years agowwwstatic: offload error handling to PSGI server
Eric Wong [Fri, 24 Jan 2020 09:43:50 +0000 (09:43 +0000)]
wwwstatic: offload error handling to PSGI server

The PSGI server needs to account for ->getline failing
due to disk failures or truncated files, anyways.  So
just die() ourselves and let the PSGI server log and
drop the client.

4 years agohttp: eliminate short-lived cyclic ref for psgix.io
Eric Wong [Fri, 24 Jan 2020 09:43:49 +0000 (09:43 +0000)]
http: eliminate short-lived cyclic ref for psgix.io

While there is no known actual leak due to reference cycles,
here, eliminating a potential source of leaks is helpful.

4 years agospelling: favor `publicly' over `publically'
Eric Wong [Fri, 24 Jan 2020 22:09:33 +0000 (22:09 +0000)]
spelling: favor `publicly' over `publically'

While both can be correct, the former seems more common,
is shorter, and is also consistent with the spelling found
in the AGPL-3.0 text.

4 years agowebsite: omit technical/ and other subdirs
Eric Wong [Fri, 24 Jan 2020 22:09:32 +0000 (22:09 +0000)]
website: omit technical/ and other subdirs

We don't need to clutter the website with unnecessary technical
information.  Anybody who reads the technical/ directory should
be looking at our source code, anyways; and we also have cgit
and gitweb mirrors.

4 years agodoc: INSTALL describe required deps for released versions
Eric Wong [Fri, 24 Jan 2020 22:09:31 +0000 (22:09 +0000)]
doc: INSTALL describe required deps for released versions

1.3.0 isn't out, yet, and sometimes folks will rely on
INSTALL on our website while installing older versions,
so try to clarify that.

4 years agowebsite: re-add top-level files
Eric Wong [Fri, 24 Jan 2020 22:09:30 +0000 (22:09 +0000)]
website: re-add top-level files

I noticed the TODO was out-of-date on the website, among some
other things.  This was broken in moving GNU-isms in the
Makefile to Perl.

4 years agodoc: avoid needless rebuilds of NEWS
Eric Wong [Fri, 24 Jan 2020 22:09:29 +0000 (22:09 +0000)]
doc: avoid needless rebuilds of NEWS

Repeatedly rebuilding `NEWS' because the mtime of `NEWS'
is synched to the latest release .eml is a bit annoying,
but necessary to save bandwidth for the website.

So we'll also update the mtime of the source .eml file when
reading them.  It's kinda gross to be setting mtimes of source
.eml files in Documentation/RelNotes/, but I can't think of
anything better at the moment...

4 years agombox: handle empty subjects after dropping "Re:" prefix
Eric Wong [Sat, 25 Jan 2020 02:47:08 +0000 (02:47 +0000)]
mbox: handle empty subjects after dropping "Re:" prefix

We can't pass empty strings to `to_filename' without
triggering warnings, and `to_filename' on an empty string
makes no sense.

4 years agocontentid: ignore duplicate References: headers
Eric Wong [Thu, 23 Jan 2020 23:05:59 +0000 (23:05 +0000)]
contentid: ignore duplicate References: headers

OverIdx::parse_references already skips duplicate
References (which we use in SearchThread for rendering).
So there's no reason for our content deduplication logic
to care if a Message-Id in the Reference header is mentioned
twice.

4 years agowwwstream: shorten cloneurl uniquification
Eric Wong [Thu, 23 Jan 2020 23:05:58 +0000 (23:05 +0000)]
wwwstream: shorten cloneurl uniquification

Another place where List::Scalar::uniq doesn't make sense,
but there's a small op reduction to be had anyways.

4 years agomid: shorten uniq_mids logic
Eric Wong [Thu, 23 Jan 2020 23:05:57 +0000 (23:05 +0000)]
mid: shorten uniq_mids logic

We won't be able to use List::Util::uniq here, but we can still
shorten our logic and make it more consistent with the rest of
our code which does similar things.

4 years agoinbox: simplify filtering for duplicate NNTP URLs
Eric Wong [Thu, 23 Jan 2020 23:05:56 +0000 (23:05 +0000)]
inbox: simplify filtering for duplicate NNTP URLs

And add a note to remind ourselves to use List::Util::uniq
when it becomes common.

4 years agonntp: simplify setting X-Alt-Message-ID
Eric Wong [Thu, 23 Jan 2020 23:05:55 +0000 (23:05 +0000)]
nntp: simplify setting X-Alt-Message-ID

We can cut down on the number of operations required
using "grep" instead of "foreach".

4 years agocontentid: use map to generate %seen for Message-Ids
Eric Wong [Thu, 23 Jan 2020 23:05:54 +0000 (23:05 +0000)]
contentid: use map to generate %seen for Message-Ids

This use of map {} is a common idiom as we no longer consider
the Message-ID as part of the digest.

4 years agohval: from_attr: move to unit test
Eric Wong [Sun, 19 Jan 2020 09:40:52 +0000 (09:40 +0000)]
hval: from_attr: move to unit test

We don't call from_attr anywhere outside of tests, so don't
bloat normal processes with it.

4 years agohval: to_attr: support wide characters
Eric Wong [Sun, 19 Jan 2020 09:40:51 +0000 (09:40 +0000)]
hval: to_attr: support wide characters

We need to escape wide characters when making attribute names from
filename-looking things in diffstats.

4 years agodoc: some 1.3.0 release notes updates
Eric Wong [Tue, 14 Jan 2020 07:56:26 +0000 (07:56 +0000)]
doc: some 1.3.0 release notes updates

4 years agosigfd: simplify loop and improve documentation
Eric Wong [Sun, 12 Jan 2020 21:17:56 +0000 (21:17 +0000)]
sigfd: simplify loop and improve documentation

We can use the return value of sysread to bound our loop instead
of repeatedly shortening the string.  Furthermore add some
comments which can be easily checked against the signalfd(2)
manpage.