From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8CFE51F935 for ; Sun, 5 Jul 2020 23:28:13 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 30/43] view: update /$INBOX/$MSGID/T/ to be async Date: Sun, 5 Jul 2020 23:27:46 +0000 Message-Id: <20200705232759.3161-31-e@yhbt.net> In-Reply-To: <20200705232759.3161-1-e@yhbt.net> References: <20200705232759.3161-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Another 10% or so speedup in a frequently-hit endpoint. --- lib/PublicInbox/View.pm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 117257a64..16a0fcdfb 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -459,23 +459,26 @@ sub thread_html { # flat display: lazy load the full message from smsg $ctx->{msgs} = $msgs; $ctx->{-html_tip} = '
';
-	PublicInbox::WwwStream::response($ctx, 200, \&thread_html_i);
+	PublicInbox::WwwStream::aresponse($ctx, 200, \&thread_html_i);
 }
 
 sub thread_html_i { # PublicInbox::WwwStream::getline callback
-	my ($ctx) = @_;
-	my $msgs = $ctx->{msgs} or return;
-	while (my $smsg = shift @$msgs) {
-		my $eml = $ctx->{-inbox}->smsg_eml($smsg) or next;
+	my ($ctx, $eml) = @_;
+	if ($eml) {
+		my $smsg = $ctx->{smsg};
 		if (exists $ctx->{-html_tip}) {
 			$ctx->{-title_html} = ascii_html($smsg->{subject});
-			return $ctx->html_top .
-				eml_entry($ctx, $smsg, $eml, scalar @$msgs);
+			$ctx->zmore($ctx->html_top);
+		}
+		return eml_entry($ctx, $smsg, $eml, scalar @{$ctx->{msgs}});
+	} else {
+		while (my $smsg = shift @{$ctx->{msgs}}) {
+			return $smsg if exists($smsg->{blob});
 		}
-		return eml_entry($ctx, $smsg, $eml, scalar @$msgs);
+		my $skel = delete($ctx->{skel}) or return; # all done
+		$ctx->zmore($$skel);
+		undef;
 	}
-	my ($skel) = delete @$ctx{qw(skel msgs)};
-	$$skel;
 }
 
 sub multipart_text_as_html {