diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-30 01:20:45 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-30 01:21:10 +0000 |
commit | dfef0d2c34fbf21d665c40b5ad5069e9113c35c8 (patch) | |
tree | e43e0c822ee9ffb3ce122879447a754318f71d46 /lib/PublicInbox | |
parent | 66e91d22b9899aaf5baea05b5e1652a35472b966 (diff) | |
download | public-inbox-dfef0d2c34fbf21d665c40b5ad5069e9113c35c8.tar.gz |
This saves over 400ms on my system with the full LKML with over 2.8 million messages.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/Inbox.pm | 1 | ||||
-rw-r--r-- | lib/PublicInbox/View.pm | 20 |
2 files changed, 18 insertions, 3 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 265360d9..90ac9ebb 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -132,6 +132,7 @@ sub max_git_part { sub mm { my ($self) = @_; $self->{mm} ||= eval { + require PublicInbox::Msgmap; _cleanup_later($self); my $dir = $self->{mainrepo}; if (($self->{version} || 1) >= 2) { diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index ec043433..60fc1df1 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -1069,17 +1069,31 @@ sub index_nav { # callback for WwwStream sub index_topics { my ($ctx) = @_; my ($off) = (($ctx->{qp}->{o} || '0') =~ /(\d+)/); - my $opts = { offset => $off, limit => 200 }; + my $lim = 200; + my $opts = { offset => $off, limit => $lim }; $ctx->{order} = []; my $srch = $ctx->{srch}; - my $sres = $srch->query('', $opts); + + my $qs = ''; + # this complicated bit cuts loading time by over 400ms on my system: + if ($off == 0) { + my ($min, $max) = $ctx->{-inbox}->mm->minmax; + my $n = $max - $lim; + $n = $min if $n < $min; + for (; $qs eq '' && $n >= $min; --$n) { + my $smsg = $srch->lookup_article($n) or next; + $qs = POSIX::strftime('d:%Y%m%d..', gmtime($smsg->ts)); + } + } + + my $sres = $srch->query($qs, $opts); my $nr = scalar @{$sres->{msgs}}; if ($nr) { $sres = load_results($srch, $sres); walk_thread(thread_results($ctx, $sres), $ctx, *acc_topic); } - $ctx->{-next_o} = $off+ $nr; + $ctx->{-next_o} = $off + $nr; $ctx->{-cur_o} = $off; PublicInbox::WwwStream->response($ctx, dump_topics($ctx), *index_nav); } |