diff options
author | Eric Wong <e@80x24.org> | 2020-11-07 10:56:53 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-11-08 10:18:16 +0000 |
commit | 4a657851d09fbc4aae3238c510ae7a1ed303fd5a (patch) | |
tree | b201ee065ce74852dc1520f74a7aa1a604cb3150 /lib/PublicInbox/SearchIdxShard.pm | |
parent | ba071011a2bfa70f4ab8df87d186e33971ef85e1 (diff) | |
download | public-inbox-4a657851d09fbc4aae3238c510ae7a1ed303fd5a.tar.gz |
searchidxshard: reduce syscalls when writing ->eidx_key
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.
Diffstat (limited to 'lib/PublicInbox/SearchIdxShard.pm')
-rw-r--r-- | lib/PublicInbox/SearchIdxShard.pm | 7 |
1 files 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 { |