* [PATCH 2/6] nntp: speed up XHDR Xref for rtin
2015-09-21 11:11 7% [PATCH 0/6] more NNTP server updates Eric Wong
@ 2015-09-21 11:11 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-09-21 11:11 UTC (permalink / raw)
To: meta
We could also start displaying Xref in XOVER as rtin seems to
prefer it. Anyways this is nearly 100 times faster now and
requires no DB changes.
---
lib/PublicInbox/NNTP.pm | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 79f2c2f..d5eb497 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -371,7 +371,7 @@ found:
if ($set_headers) {
$s->header_set('Newsgroups', $ng->{name});
$s->header_set('Lines', $s->body =~ tr!\n!\n!);
- $s->header_set('Xref', "$ng->{domain} $ng->{name}:$n");
+ $s->header_set('Xref', xref($ng, $n));
# must be last
if ($set_headers == 2) {
@@ -562,6 +562,35 @@ sub xhdr_message_id ($$) { # optimize XHDR Message-ID [range] for slrnpull.
}
}
+sub xref ($$) {
+ my ($ng, $n) = @_;
+ "$ng->{domain} $ng->{name}:$n"
+}
+
+sub xhdr_xref ($$) { # optimize XHDR Xref [range] for rtin
+ my ($self, $range) = @_;
+
+ my $ng = $self->{ng};
+ my $mm = $ng->mm;
+ if (defined $range && $range =~ /\A<(.+)>\z/) { # Message-ID
+ my $n = $mm->num_for($range);
+ more($self, '221 Header follows');
+ more($self, "<$range> ".xref($ng, $n)) if defined $n;
+ '.';
+ } else { # numeric range
+ $range = $self->{article} unless defined $range;
+ my $r = get_range($self, $range);
+ return $r unless ref $r;
+ my ($beg, $end) = @$r;
+ more($self, '221 Header follows');
+ $self->long_response($beg, $end, sub {
+ my ($i) = @_;
+ my $mid = $mm->mid_for($$i);
+ more($self, "$$i ".xref($ng, $$i)) if defined $mid;
+ });
+ }
+}
+
sub header_obj_for {
my ($srch, $mid) = @_;
eval {
@@ -612,6 +641,8 @@ sub cmd_xhdr ($$;$) {
my $sub = lc $header;
if ($sub eq 'message-id') {
xhdr_message_id($self, $range);
+ } elsif ($sub eq 'xref') {
+ xhdr_xref($self, $range);
} elsif ($sub =~ /\A(subject|references|date)\z/ && $ng->search) {
xhdr_searchmsg($self, $sub, $range);
} else {
--
EW
^ permalink raw reply related [relevance 6%]
* [PATCH 0/6] more NNTP server updates
@ 2015-09-21 11:11 7% Eric Wong
2015-09-21 11:11 6% ` [PATCH 2/6] nntp: speed up XHDR Xref for rtin Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2015-09-21 11:11 UTC (permalink / raw)
To: meta
Always finding new bugs. The XHDR Xref performance improvement
is pretty huge, and the XOVER speedup is noticeable as well.
We will begin to implement RFC 3977, AFAIK the latest NNTP RFC.
Eric Wong (6):
msgmap: minor cleanup to move constant declaration
nntp: speed up XHDR Xref for rtin
nntp: speed up xover slightly
t/nntpd.t: improve test runnability
remove bytes:: for length checks
nntp: proper UTF-8 support (hopefully?)
lib/PublicInbox/Filter.pm | 2 +-
lib/PublicInbox/GitCatFile.pm | 5 +++--
lib/PublicInbox/Msgmap.pm | 2 +-
lib/PublicInbox/NNTP.pm | 47 ++++++++++++++++++++++++++++++++++++-------
public-inbox-nntpd | 4 ++--
t/nntpd.t | 3 ++-
6 files changed, 49 insertions(+), 14 deletions(-)
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-09-21 11:11 7% [PATCH 0/6] more NNTP server updates Eric Wong
2015-09-21 11:11 6% ` [PATCH 2/6] nntp: speed up XHDR Xref for rtin Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).