Eric Wong [Wed, 23 Nov 2022 04:09:57 +0000 (04:09 +0000)]
config: urlmatch $? does not influence our exits
We don't want to leak $? from `git config' failures into
lei nor public-inbox-* processes.
Eric Wong [Wed, 23 Nov 2022 04:09:56 +0000 (04:09 +0000)]
lei_curl: set --proxy for curl(1) properly
curl(1) doesn't accept `--proxy=' with the `=', apparently :x
Eric Wong [Mon, 14 Nov 2022 08:07:02 +0000 (08:07 +0000)]
lei q|up: limit default write --jobs for IMAP(S)
Eric Wong <e@80x24.org> wrote:
> Thanks for confirming things work as intended. I think the
> default should be clamped, though... 15 seems a bit high for
> smaller IMAP servers *shrug*
--------8<-------
Subject: [PATCH] lei q|up: limit default write --jobs for IMAP(S)
IMAP(S) servers often limit per-user connections, so avoid
bumping into limits to improve the out-of-the-box experience.
4 seems like a conservative default, since we already chose
that number for remote HTTP(S) endpoints.
Link: https://public-inbox.org/meta/20220910201958.GA12212@dcvr/
Eric Wong [Thu, 3 Nov 2022 00:48:38 +0000 (00:48 +0000)]
txt2pre: linkify lei/store => lei-store-format.html
Linking to the manpage probably helps clarify what `lei/store'
refers to without too much clutter in the raw POD source.
Eric Wong [Thu, 3 Nov 2022 00:48:37 +0000 (00:48 +0000)]
doc: lei-import: link to lei-store-format(5)
Users should know where `lei import' writes to.
Eric Wong [Thu, 3 Nov 2022 00:48:36 +0000 (00:48 +0000)]
doc: txt2pre: modernize and use v5.12
Another teeny step towards v5.12.
Eric Wong [Thu, 3 Nov 2022 00:48:35 +0000 (00:48 +0000)]
doc: txt2pre: linkify "lei COMMAND" form
While manpages are named `L<lei-COMMAND(1)>', `lei COMMAND'
can be worth linkifying for ease-of-navigation, too.
Eric Wong [Thu, 3 Nov 2022 00:48:34 +0000 (00:48 +0000)]
doc: lei: improve description of *-search commands
The `OUTPUT' use may not be immediately apparent, clarify
that it's from `lei q'.
Eric Wong [Thu, 3 Nov 2022 00:48:33 +0000 (00:48 +0000)]
doc: txt2pre: linkify new commands
lei-index, public-inbox-netd, and public-inbox-pop3d
were not properly linkified in our HTML documentation.
Eric Wong [Tue, 1 Nov 2022 09:36:12 +0000 (09:36 +0000)]
lei: fix globbing semantics to match end-of-filename
Globs such as `*/foo' should not match `*/foobar'. I noticed
this while adding glob support to public-inbox-clone.
This may subtly break some existing cases, but there aren't many
lei users, yet, and globbing semantics should match what most
other glob-using programs, do...
We'll also make `lei ls-mail-sync' behave more consistently with
`lei ls-external', as far as the basename matching fallback
goes.
Eric Wong [Mon, 31 Oct 2022 21:52:59 +0000 (21:52 +0000)]
lei up: improve error for multiple lei.q values
Point users towards the lei.internal.rawstr variable which
may be tripping up handling of lei.q after `lei edit-search'.
Eric Wong [Tue, 25 Oct 2022 11:43:18 +0000 (11:43 +0000)]
tests: expand relative @INC paths
Since the lei-daemon may chdir around and lazy-loads package, we
must ensure @INC uses absolute paths so it can find stuff after
(f)chdir.
I noticed this in running `perl -I lib -w t/lei-q-kw.t'
instead of my usual `prove -bvw t/lei-q-kw.t' to save some
cycles.
Eric Wong [Thu, 20 Oct 2022 08:43:14 +0000 (08:43 +0000)]
lei_mirror: delimit names by `\n' to improve die message
Attempting to clone a top-level manifest should work,
eventually. But for now, make the list of git repos
more readable.
Eric Wong [Thu, 20 Oct 2022 08:43:13 +0000 (08:43 +0000)]
lei_mirror: make _finish_add_external call more obvious
I get easily confused, sometimes :x
Eric Wong [Thu, 20 Oct 2022 08:43:12 +0000 (08:43 +0000)]
treewide: replace /^I: / prefix with /^# /
This is like more familiar to readers of TAP (Test Anywhere
Protocol) output, as well as shell and Perl scripters which also
use `#' for comments.
AFAIK, nobody is parsing our stderr, and I'm not sure how
standardized the `I:' prefix is (nor `W:' and `E:' are). It's
already the prevailing style in Lei* code, too, so things have
been moving in that direction for a bit.
Eric Wong [Thu, 20 Oct 2022 08:43:11 +0000 (08:43 +0000)]
githttpbackend: remove unused $BIN variable
It hasn't been used in many years since commit
c1630b7dc4ef (githttpbackend: match Content-Type of git-http-backend(1), 2016-07-03)
Eric Wong [Thu, 20 Oct 2022 08:43:10 +0000 (08:43 +0000)]
another step towards git SHA-256 support
While SHA-256 isn't supported for inboxes, yet
xt/git-http-backend.t now runs properly against a SHA-256 code
repository
Eric Wong [Thu, 20 Oct 2022 08:43:09 +0000 (08:43 +0000)]
clone|fetch: preserve mtime of modified manifest.js.gz
When we cull manifest.js.gz for ignored epochs, attempt to
preserve mtime of the updated manifest.js.gz since it can
be used to optimize future fetches.
Eric Wong [Mon, 17 Oct 2022 09:30:53 +0000 (09:30 +0000)]
sigfd: set SIGWINCH for MIPS and PA-RISC on Linux
SIGWINCH is actually different for these architectures on Linux
according to the signal(7) man page.
Note: AFAICS there's no parisc machine in the GCC Farm[1],
so it remains untested. I've only tested mips64 for mips,
but I expect them to both work.
OpenBSD (on gcc231) octeon defines SIGWINCH as the common `28',
so it appears Linux is the only one with arch-dependent signal
numbers (ditto with syscalls).
[1] https://cfarm.tetaneutral.net/machines/list/
Eric Wong [Mon, 17 Oct 2022 09:30:52 +0000 (09:30 +0000)]
syscall: avoid needless string comparison on x86-64
For common x86-64 systems, we can avoid a needless
string comparison on `mips64' by restructuring the
branches for architecture detection.
Nicolás Ojeda Bär [Sat, 15 Oct 2022 08:12:46 +0000 (10:12 +0200)]
SIGWINCH is 28 on Darwin-based OSes
[ew: avoid mention of non-Free platform]
Acked-by: Eric Wong <e@80x24.org>
Eric Wong [Tue, 11 Oct 2022 00:05:54 +0000 (00:05 +0000)]
dskqxs: fix loop to allow `next'
`do {} while(...)' loops in Perl don't support `next', actually :x
This only affects *BSD platforms with IO::KQueue installed.
Fixes: d6674af04cb74a4e "httpd|nntpd: avoid missed signal wakeups"
Eric Wong [Mon, 10 Oct 2022 21:34:22 +0000 (21:34 +0000)]
www: viewvcs: display annotated tags as discreet objects
This emphasizes annotated tags as their own object type in the
web UI while being able to link to the existing show_commit()
linkification and dfblob: search.
Eric Wong [Mon, 10 Oct 2022 21:34:21 +0000 (21:34 +0000)]
xt/solver: skip on missing publicinbox.git.coderepo
Solver tests can never succeed without coderepos configured,
since that's the whole point of solver. And improve the
original skip message to note that it's about the `git'
public-inbox, not `git' itself.
Eric Wong [Mon, 10 Oct 2022 21:34:20 +0000 (21:34 +0000)]
viewvcs: avoid one ascii_html call
We can reuse its result for the button text.
Eric Wong [Sat, 8 Oct 2022 08:24:48 +0000 (08:24 +0000)]
www_coderepo: allow searching one extindex|inbox
I'm not sure how to best make a UI for one coderepo to many
inboxes/extindices, yet; but at least allow a simple 1:1
mapping, for now. This ensures /$CODEREPO/$OID/s/ can work
as effectively as /$INBOX/$OID/s/ when looking for emails
associated with a git commit.
Eric Wong [Sat, 8 Oct 2022 08:24:47 +0000 (08:24 +0000)]
www: cgit: fix fallback to WwwCoderepo on array responses
For fast PSGI responses which don't require returning a coderef,
just reuse qspawn.wcb directly on the arrayref to avoid an undef
$wcb from firing in psgi_return_init_cb.
I only noticed this because the ViewVCS search form is broken
for /$CODEREPO/$OID/s/ endpoints at the moment.
Eric Wong [Sat, 8 Oct 2022 08:24:46 +0000 (08:24 +0000)]
www_coderepo: update blurb on the goal/purpose of this
I think putting too much functionality in web services leads
to ignorance of local/offline tools, so this web UI will give
hints here and there for web users. Things like diff options
can get expensive and become cache-unfriendly on the web server,
so promoting local tools can reduce overall network traffic
and server load.
Eric Wong [Sat, 8 Oct 2022 08:24:45 +0000 (08:24 +0000)]
www_coderepo: wire up snapshots from summary
This also ensures we won't waste CPU cycles on snapshots
which aren't configured if somebody attempts them by
guessing URLs.
Eric Wong [Sat, 8 Oct 2022 08:24:44 +0000 (08:24 +0000)]
config: remove {-cgitrc_unparsed} field
This field has been unneeded since commit
6890430df808
(cgit: fix fallout from lazy coderepo loading, 2021-03-18)
Eric Wong [Wed, 5 Oct 2022 22:29:41 +0000 (22:29 +0000)]
www: support publicinbox.cgit knob
For backwards-compatibility, this defaults to `first'. When set
to `fallback', PublicInbox::WwwCoderepo is favored and cgit is
only used as a fallback. Eventually, `rewrite' will also be
supported to rewrite cgit URLs to WwwCoderepo ones.
Of course, WwwCoderepo is still missing search and other key
features, but that's being worked on...
Eric Wong [Wed, 5 Oct 2022 22:29:40 +0000 (22:29 +0000)]
www: cgit: fall back to WwwCoderepo on 404s
We can't rely on 3-element array response when calling
WwwCoderepo for ViewVCS endpoints since that uses Qspawn
internally. Thus, we have to allow two Qspawn objects to run in
parallel and ensure `qspawn.wcb' only gets called once, so we
end up duplicating the entire $ctx to ensure this.
Eric Wong [Wed, 5 Oct 2022 22:29:39 +0000 (22:29 +0000)]
www: do not call ->coderepo->srv on sub ref
The PublicInbox::Cgit wrapper will return a sub-ref for most
responses, so ensure we don't try to treat it as an array-ref.
Eric Wong [Tue, 4 Oct 2022 19:12:40 +0000 (19:12 +0000)]
www_coderepo: start a top nav bar in summary view
This needs to be expanded, but quick links to heads/tags/README
shouldn't hurt...
Eric Wong [Tue, 4 Oct 2022 19:12:39 +0000 (19:12 +0000)]
www_stream: use git->pub_urls for coderepo links
This is already used by */$OID/s/, so just reuse existing code
and make git->local_nick use the assigned nick from the config
file, if there is one.
Eric Wong [Tue, 4 Oct 2022 19:12:38 +0000 (19:12 +0000)]
www_coderepo: wire up snapshot support
These should be compatible with cgit results
Eric Wong [Tue, 4 Oct 2022 19:12:37 +0000 (19:12 +0000)]
git: allow ->local_nick to return undef
It'll be used directly (outside of ->pub_urls) in the
standalone coderepo viewer for tarball snapshots.
Eric Wong [Tue, 4 Oct 2022 19:12:36 +0000 (19:12 +0000)]
www_coderepo: wire up /$CODEREPO/$OID/s/ endpoint
Just reusing ViewVCS::show, since encoding refname and pathnames
into things just makes things slower.
Eric Wong [Tue, 4 Oct 2022 19:12:35 +0000 (19:12 +0000)]
www_coderepo: an alternative to cgit
This will allow it to easily map a single coderepo to multiple
inboxes (or multiple coderepos to any number of inboxes).
For now, this is just a summary, but $REPO/$OID/s/ support
will be added, along with archive downloads.
Indexing of coderepos will probably be supported via -extindex,
only.
Eric Wong [Tue, 4 Oct 2022 19:12:34 +0000 (19:12 +0000)]
git: move cloneurl + description reading here
We'll be using these functions for serving coderepos natively
without cgit.
Eric Wong [Tue, 4 Oct 2022 19:12:33 +0000 (19:12 +0000)]
git: hoist out description
We'll be using this separately, elsewhere.
Eric Wong [Tue, 4 Oct 2022 19:12:32 +0000 (19:12 +0000)]
cgit: use Perl 5.10-isms, optimize, and golf
We can reduce variable assignments in a few places and filter
keys more quickly using the `grep' Perl op rather than relying on
`m// or next' inside a loop. Similar changes to the NNTP and IMAP
(e.g.
b700fce60f25038e (nntp: NEWNEWS: speed up filtering, 2020-11-27))
yielded good improvements.
Eric Wong [Tue, 4 Oct 2022 19:12:31 +0000 (19:12 +0000)]
tests: use test_httpd consistently
This allows us to consolidate our checks for
Plack::Test::ExternalServer and enforce our redirect-disabled
LWP::UserAgent.
Eric Wong [Sun, 2 Oct 2022 15:11:01 +0000 (15:11 +0000)]
viewdiff: fix parts of diff being appended after signature
I'm not sure what kind of brain fart introduced this in
c1e7a048be9d32cd, but it happened :x. We'll undef the $x
variable ASAP to save memory and make future errors like this
one more noticeable.
Fixes: c1e7a048be9d ("www: viewdiff: fix UTF-8 names inside mbox attachments")
Eric Wong [Sat, 1 Oct 2022 18:52:50 +0000 (15:52 -0300)]
www_stream: use DESTROY to cleanup temporary gits
Relying on a timer to handle cleanup in
f9ac22a4b485 was
sub-optimal since the delay could prove expensive under heavy
traffic. So rely on ->DESTROY instead since we we no longer
hold reference cycles by the time the show_blob callback
executes.
Fixes: f9ac22a4b485 ("git_async_cat: automatically cleanup temporary gits")
Eric Wong [Sat, 1 Oct 2022 00:33:15 +0000 (00:33 +0000)]
lei: force --jobs=1,1 for SQLite < 3.8.3
SQLite prior to 3.8.3 did not reset its PRNG for generating
unique temporary file names, so it would barf on t/lei-up.t
occasionally due to O_EXCL -> EEXIST conflicts.
This fixes occasional test failures under CentOS 7.x which ships
SQLite 3.7.17.
Eric Wong [Sat, 1 Oct 2022 00:07:45 +0000 (00:07 +0000)]
git_async_cat: automatically cleanup temporary gits
This prevents temporary directories and git processes from
lingering around after WWW solver requests.
Eric Wong [Fri, 30 Sep 2022 09:21:40 +0000 (09:21 +0000)]
t/altid_v2: improve test style
Favor `is' for equality checks since it reports differences,
and `xbail' over `BAIL_OUT' since it's easier-to-type w/o caps
and more powerful.
These are just things noticed while I was looking at another
odd failure on CentOS 7.x with this test, but I suspect it
was a transient failure caused by running the test suite
from multiple terminals in parallel.
Eric Wong [Fri, 30 Sep 2022 09:21:39 +0000 (09:21 +0000)]
lei_to_mail: propagate errors to script/lei
We need to rely on lei->fail to propagate errors in lei workers
to the script/lei client, otherwise tests and other scripts can
stumble forward with incomplete/incorrect/broken outputs.
This helps me focus on occasional t/lei-up.t failures I see on
CentOS 7.x where OverIdx->adj_counter fails on "lei up --all"...
Eric Wong [Fri, 30 Sep 2022 09:21:38 +0000 (09:21 +0000)]
t/lei-up: improve diagnostics for this test
I'm getting occasional failures for this test on CentOS 7.x (but
not on FreeBSD nor Debian 10/11). I'm not why, yet, so just
improve diagnostics for now.
Eric Wong [Fri, 30 Sep 2022 09:21:37 +0000 (09:21 +0000)]
tests: favor 3 argument `open' with interopolation
It makes code easier to review, and is more robust in case some
weirdos actually start their path names with '<' or '>' :P
Eric Wong [Thu, 29 Sep 2022 20:56:29 +0000 (20:56 +0000)]
www: remove "1\n" lines in $MSGID/t/ view
Fixes: ab9c03ff4aa3 "www: use PerlIO::scalar (zfh) for buffering"
Eric Wong [Thu, 29 Sep 2022 17:48:31 +0000 (17:48 +0000)]
tests: no IPv6 on old Net::NNTP, Mail::IMAPClient, HTTP::Tiny
The versions of these modules which ship with CentOS 7.x did not
support IPv6 properly.
Eric Wong [Thu, 29 Sep 2022 17:48:30 +0000 (17:48 +0000)]
gcf2: fix syntax error and require PublicInbox::Git
I failed to notice these since I uninstalled libgit2 for
benchmarking and kept it uninstalled since my git(1) install
is faster.
Fixes: 1c0ec857d041 "gcf2: support worktree $GIT_DIR"
Eric Wong [Thu, 29 Sep 2022 17:48:29 +0000 (17:48 +0000)]
treewide: use --globoff with curl(1)
curl 7.29.0 (on CentOS 7.x) seems to mishandle square-bracketed
IPv6 addresses, at least. Furthermore, we don't actually need
nor use the globbing in curl for lei when forwarding requests
from the lei command-line. lei has its own globbing and
`--globoff' behavior for externals and none of it is intended
for curl.
Eric Wong [Thu, 29 Sep 2022 17:48:28 +0000 (17:48 +0000)]
syscall: initialize buffer for vec()
This is needed for older Perls (tested perl 5.16.3 on CentOS 7).
Eric Wong [Mon, 26 Sep 2022 10:17:15 +0000 (10:17 +0000)]
git: reduce early bare-bones memory use
The {-git_path} cache can rely on auto-vivification, and
{alt_st} may not be needed for short-lived repos. So don't
populate those fields until they're needed, since we can
expect to handle thousands of git repos, too.
Eric Wong [Mon, 26 Sep 2022 10:17:14 +0000 (10:17 +0000)]
viewvcs: load blobs asynchronously
This actually leads to a nice 3-5% speedup under parallel loads
when using git(1) w/o SHA-1 collision detection enabled. Gcf2
is slower since libgit2 has SHA-1 collision detection enabled
on my system.
Since we're in the area, improve location of comments w.r.t.
cgit CSS class names and note the reliance on scratchpad for
performance in a tight loop.
Eric Wong [Mon, 26 Sep 2022 10:17:13 +0000 (10:17 +0000)]
gcf2: support worktree $GIT_DIR
We must use `git rev-parse --git-path objects' instead of
blindly appending '/objects' to $GIT_DIR, since appending
doesn't work when $GIT_DIR is a worktree.
Eric Wong [Mon, 26 Sep 2022 10:17:12 +0000 (10:17 +0000)]
viewdiff: save memory by eliminating two captures
Avoid relying on $DIGIT captures when @- and @+ to access
last match start and end, respectively. The elimination of
the post capture ought to allow the use of sv_chop to advance
the string start pointer without memory copies.
This ought to save 1-2MB of memory on my system since I've
noticed the captures was using a big chunk of scratchpad
space.
Eric Wong [Wed, 21 Sep 2022 17:02:54 +0000 (17:02 +0000)]
t/pop3d: skip all tests if no certs are found
This test could be written with optional OpenSSL dependencies, but
it's probably not worth it since IO::Socket::SSL seems pretty
common.
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://public-inbox.org/meta/20220921154741.siubptwcv4463w5l@pengutronix.de/
Eric Wong [Mon, 12 Sep 2022 22:54:04 +0000 (22:54 +0000)]
www: viewdiff: fix UTF-8 names inside mbox attachments
This avoids `Wide character in print' warnings and ensures the
UTF-8 characters in `Signed-off-by' trailers are properly rendered
in HTML even when attempting to decode and display
application/octet-stream mbox attachments as HTML.
Linkification and reconstruction for coderepos is probably
still broken, but that is a much bigger task to fix, I think.
Fixes: ab9c03ff4aa369b3 ("www: use PerlIO::scalar (zfh) for buffering")
Eric Wong [Mon, 12 Sep 2022 16:04:48 +0000 (16:04 +0000)]
git_async_cat: don't use Gcf2 for temporary git dirs
We don't want to be holding references to temporary directories
longer than necessary, an Gcf is intended to be long-lived.
Eric Wong [Sat, 10 Sep 2022 20:10:24 +0000 (20:10 +0000)]
solver: do not show redundant URLs in log
Messages in /all/ can get duplicated at times due to
list-appended signatures or buggy/malicious clients.
They'll all show up based on /$INBOX/$MSGID/,
so deduplicate the URLs to avoid noise.
Eric Wong [Sat, 10 Sep 2022 20:10:23 +0000 (20:10 +0000)]
view: fix solver links with multiple messages
For redundant messages sharing Message-IDs, the link to solver
(/$INBOX/$OID/s/) was going up too many levels for /$INBOX/$MSGID/
when there were multiple messages sharing the same $MSGID.
Unfortunately, redundant messages are common with /all/
due to signature trailers. So dynamically assigning {-spfx}
is tricky and error prone from counting `/'.
So simplify the code a bit by setting {-spfx} once per HTTP
request, instead of every single message.
Eric Wong [Sat, 10 Sep 2022 08:17:29 +0000 (08:17 +0000)]
viewvcs: switch to `print $zfh'
Again, ->zmore has proven expensive due to the overhead of
calling ->deflate on small strings, so print directly to the
file handle and let the PerlIO::scalar layer take care of
buffering. One of the ->zmore calls was a no-op, even, so
drop that entirely.
Eric Wong [Sat, 10 Sep 2022 08:17:28 +0000 (08:17 +0000)]
www_listing: switch to `print $zfh'
Again, ->deflate (and thus ->zmore) calls are relatively
expensive compared to `print' ops using PerlIO::scalar
behind-the-scenes. While I can likely optimize the `join' away
here, too, that will happen in a future commit.
Eric Wong [Sat, 10 Sep 2022 08:17:27 +0000 (08:17 +0000)]
mbox*: use multi-arg ->translate and ->write
No need to make multiple method calls from here,
now that ->translate and GzipFilter->write both support
multiple args.
Eric Wong [Sat, 10 Sep 2022 08:17:26 +0000 (08:17 +0000)]
feed: new_html_i: switch from zmore to `print $zfh'
eml_entry will enable zfh (PerlIO::scalar) buffering, anyways,
so there's no point in calling ->zmore to compress small
strings. The use of zfh for the skeleton is debatable, but
probably of no consequence given html_footer will hit it,
anyways.
Eric Wong [Sat, 10 Sep 2022 08:17:25 +0000 (08:17 +0000)]
gzip_filter: write: use multi-arg translate
While we must name this function ->write for PSGI compatibility,
our own uses of it can make it operate more like writev(2)
or `print' in Perl.
Eric Wong [Sat, 10 Sep 2022 08:17:24 +0000 (08:17 +0000)]
translate: support multiple buffer args
This will let us drop some calls to zmore in subsequent commits.
Eric Wong [Sat, 10 Sep 2022 08:17:23 +0000 (08:17 +0000)]
httpd/async: describe which ->write subs it can call
I initially wanted to rename GzipFilter->write to
GzipFilter->writev to reflect the multi-argument nature of the
sub, and it wasn't worth the memory to maintain an alias.
Eric Wong [Sat, 10 Sep 2022 08:17:22 +0000 (08:17 +0000)]
www_static: switch to `print $zfh', and optimize
->zmore isn't cheap, and we can be smarter about how
we place newlines to avoid a `join' operation, now.
We can also drop some unused variables, here.
Eric Wong [Sat, 10 Sep 2022 08:17:21 +0000 (08:17 +0000)]
viewdiff: diff_header: shorten function, slightly
It makes for easier reading with gigantic fonts.
Eric Wong [Sat, 10 Sep 2022 08:17:20 +0000 (08:17 +0000)]
viewdiff: diff_before_or_after: avoid extra capture
/(.*?)\z/ will capture the "$X insertions(+), $Y deletions(-)"
bit anyways, along with whatever extra notes before the
/^diff --git / line. So just rely on /(.*?)\z/ and avoid
the special case before it.
Eric Wong [Sat, 10 Sep 2022 08:17:19 +0000 (08:17 +0000)]
www: use PerlIO::scalar (zfh) for buffering
Calling Compress::Raw::Zlib::deflate is fairly expensive.
Relying on the `.=' (concat) operator inside ->zadd operator is
faster, but the method dispatch overhead is noticeable compared
to the original code where we had bare `.=' littered throughout.
Fortunately, `print' and `say' with the PerlIO::scalar IO layer
appears to offer better performance without high method dispatch
overhead. This doesn't allow us to save as much memory as I
originally hoped, but does allow us to rely less on concat
operators in other places and just pass a list of args to
`print' and `say' as a appropriate.
This does reduce scratchpad use, however, allowing for large
memory savings, and we still ->deflate every single $eml.
Eric Wong [Sat, 10 Sep 2022 08:17:18 +0000 (08:17 +0000)]
www: switch to zadd for the majority of buffering
This allows us to focus string concatenations in one place to
allow Perl internal scratchpad optimizations to reuse memory.
Calling Compress::Raw::Zlib::deflate repeatedly proves too
expensive in terms of CPU cycles.
Eric Wong [Sat, 10 Sep 2022 08:17:17 +0000 (08:17 +0000)]
www: drop {obuf} use entirely, for now
This may help us identify hot spots and reduce pad space
as needed.
Eric Wong [Sat, 10 Sep 2022 08:17:16 +0000 (08:17 +0000)]
view: switch a few things to ctx->zmore
Unfortunately, this is actually slower. However, this
hopefully makes it easier to improve the internals and
make performance improvements down the line.
Eric Wong [Sat, 10 Sep 2022 08:17:15 +0000 (08:17 +0000)]
viewdiff: diff_hunk: shorten conditionals, slightly
I'm not sure if Devel::Size::total_size can be trusted due
to the regexps and crashes[1], but when it works, it's showing
around a 900 byte size reduction, too.
[1] https://rt.cpan.org/Public/Bug/Display.html?id=96421
Eric Wong [Sat, 10 Sep 2022 08:17:14 +0000 (08:17 +0000)]
view: html_footer: avoid escaping " in a few places
qq() is a nice alternative to "" when there's embedded "
characters in HTML entities.
Eric Wong [Sat, 10 Sep 2022 08:17:13 +0000 (08:17 +0000)]
view: html_footer: remove obuf dependency
Another step towards giving us more options for speedups and
memory reductions.
Eric Wong [Sat, 10 Sep 2022 08:17:12 +0000 (08:17 +0000)]
view: html_footer: golf out a few lines
We can build `$u' in one line, and drop an unnecessary empty
line to reduce the amount of scrolling required to read this
sub.
Eric Wong [Sat, 10 Sep 2022 08:17:11 +0000 (08:17 +0000)]
view: reduce ascii_html calls and {obuf} use
We can rely on {-html_tip} for some things at the top of the
page, and reduce ascii_html and obfuscate_addrs calls by
working on the whole buffer at once.
Eric Wong [Sat, 10 Sep 2022 08:17:10 +0000 (08:17 +0000)]
view: _th_index_lite: use `//' defined-or op
Just something I noticed while evaluating this subroutine
for the buffering overhaul.
Eric Wong [Sat, 10 Sep 2022 08:17:09 +0000 (08:17 +0000)]
view: _th_index_lite: avoid one s///, improve symmetry
We can replace an expensive `s///' substitution with a simpler
`chop'. Furthermore, we can delay the "</b>\n" replacement
to ensure it's on the same line of Perl code as the `<b>'
opening tag for readability.
Eric Wong [Sat, 10 Sep 2022 08:17:08 +0000 (08:17 +0000)]
viewdiff: reuse existing string in diff_before_or_after
Instead of appending to an ever-growing {obuf}, we'll reuse
the existing string (which already has pre-allocated memory).
Eric Wong [Sat, 10 Sep 2022 08:17:07 +0000 (08:17 +0000)]
view: attach_link: reduce obuf manipulation
This is another steep towards reducing the maximum size of
an obuf by eventually doing compression earlier while we
render messages as HTML.
And do some golfing while we're at it...
Eric Wong [Sat, 10 Sep 2022 08:17:06 +0000 (08:17 +0000)]
view: reduce subroutine calls for submsg_hdr
Favor fewer, yet more expensive operations than many smaller
ones. While we're still directly manipulating ctx->{obuf} after
this, this change makes it easier for us to avoid doing so in
the future.
Eric Wong [Sat, 10 Sep 2022 08:17:05 +0000 (08:17 +0000)]
view: remove multipart_text_as_html
It seems like a pointless wrapper function that's not saving us
a whole lot. Drop some direct {obuf} manipulation while we're
at it.
Eric Wong [Sat, 10 Sep 2022 08:17:04 +0000 (08:17 +0000)]
gzip_filter: ->translate can reuse zmore/zflush
We can work towards delaying zlib context allocations in future
commits, too.
Eric Wong [Sat, 10 Sep 2022 08:17:03 +0000 (08:17 +0000)]
view: eml_entry: reduce manipulation of ctx->{obuf}
This is another step towards avoid unnecessary copies
and pad space waste.
Eric Wong [Sat, 10 Sep 2022 08:17:02 +0000 (08:17 +0000)]
view: simplify _parent_headers
Having References but lacking In-Reply-To is an uncommon case
with email, nowadays. So just rely on ->linkify_mids to handle
linkification and HTML escaping Furthermore, headers are short
enough to return as-is (and rely on CoW improvements in Perl
5.1x) since linkify_mids needs to operate on an independent
string, anyways.
Eric Wong [Sat, 10 Sep 2022 08:17:01 +0000 (08:17 +0000)]
www: viewdiff: use return value for diff_hunk
It's only a short string, so there's not much copy overhead,
and it'll make future changes easier to reason about.
Eric Wong [Sat, 10 Sep 2022 08:17:00 +0000 (08:17 +0000)]
www_listing: avoid unnecessary work for common cases
We need to branch for non-empty `q=' parameters anyways, but
`q=' is usually empty/unset. While we're in the area, `chomp'
reads `$/' while `chop' is simpler. Furthermore, we can shave
a few bytes off the form HTML by omitting spaces before `/>'
and placing `\n' to wrap long lines before attribute names.
Eric Wong [Sat, 10 Sep 2022 08:16:59 +0000 (08:16 +0000)]
www_listing: consolidate some ->zmore dispatches
`.' concatenation is still faster for small strings, but
passing an array to ->zmore is more efficient for large
search results and full listings.
Eric Wong [Sat, 10 Sep 2022 08:16:58 +0000 (08:16 +0000)]
viewvcs: use shorter and simpler ctx->html_done
We only return 200s for any response large enough to warrant
->html_done, so we can just assume it. ViewVCS can also take
advantage of it with some tweaking to avoid an extra method
dispatch.
Eric Wong [Sat, 10 Sep 2022 08:16:57 +0000 (08:16 +0000)]
www_text: reduce parameter passing for response header
This is a tiny step in making the code slightly less confusing
by reusing common field names and reducing dependencies on
argument ordering.
Eric Wong [Sat, 10 Sep 2022 08:16:56 +0000 (08:16 +0000)]
www_stream: aresponse assumes 200, too
There's no reason to be streaming large amounts of HTML for
anything other than a 200 response.
Eric Wong [Sat, 10 Sep 2022 08:16:55 +0000 (08:16 +0000)]
www_atom_stream: require 200 response
This simplifies parameter passing at the moment. I can't
imagine an Atom feed reader would be parsing XML for 404s or
other error codes.