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 1DFFD1FA17 for ; Sat, 7 Nov 2020 10:57:06 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 03/10] searchidxshard: reduce syscalls when writing ->eidx_key Date: Sat, 7 Nov 2020 10:56:53 +0000 Message-Id: <20201107105700.12586-4-e@80x24.org> In-Reply-To: <20201107105700.12586-1-e@80x24.org> References: <20201107105700.12586-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We use ->autoflush(1) on this pipe to ensure the shard workers see data immediately on print; so this means we have to do our own buffering for optional data. --- lib/PublicInbox/SearchIdxShard.pm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm index e194b7e0..9566d234 100644 --- a/lib/PublicInbox/SearchIdxShard.pm +++ b/lib/PublicInbox/SearchIdxShard.pm @@ -114,14 +114,11 @@ sub shard_worker_loop ($$$$$) { sub index_raw { my ($self, $msgref, $eml, $smsg, $ibx) = @_; if (my $w = $self->{w}) { - if ($ibx) { - print $w 'X=', $ibx->eidx_key, "\0" or die - "failed to write shard: $!\n"; - } + my @ekey = $ibx ? ('X='.$ibx->eidx_key."\0") : (); $msgref //= \($eml->as_string); $smsg->{raw_bytes} //= length($$msgref); # mid must be last, it can contain spaces (but not LF) - print $w join(' ', @$smsg{qw(raw_bytes bytes + print $w @ekey, join(' ', @$smsg{qw(raw_bytes bytes num blob ds ts tid mid)}), "\n", $$msgref or die "failed to write shard $!\n"; } else {