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-ASN: 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 0DC9A1F9E5 for ; Sun, 25 Jul 2021 00:43:33 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/4] extsearchidx: favor binary comparison in common case Date: Sun, 25 Jul 2021 00:43:29 +0000 Message-Id: <20210725004332.23896-2-e@80x24.org> In-Reply-To: <20210725004332.23896-1-e@80x24.org> References: <20210725004332.23896-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We'll use 20-byte SHA-1 comparisons instead of 40-byte hex representations for a minor reduction in memory traffic. --- lib/PublicInbox/ExtSearchIdx.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm index 51dbf54f..fb1f511e 100644 --- a/lib/PublicInbox/ExtSearchIdx.pm +++ b/lib/PublicInbox/ExtSearchIdx.pm @@ -784,16 +784,16 @@ ORDER BY docid,xnum ASC LIMIT 10000 $fetching = $min = $docid; my $smsg = $ibx->over->get_art($xnum); - my $oidhex = unpack('H*', $oidbin); my $err; if (!$smsg) { $err = 'stale'; - } elsif ($smsg->{blob} ne $oidhex) { + } elsif (pack('H*', $smsg->{blob}) ne $oidbin) { $err = "mismatch (!= $smsg->{blob})"; } else { next; # likely, all good } # current_info already has eidx_key + my $oidhex = unpack('H*', $oidbin); warn "$xnum:$oidhex (#$docid): $err\n"; my $del = $self->{oidx}->dbh->prepare_cached(<<''); DELETE FROM xref3 WHERE ibx_id = ? AND xnum = ? AND oidbin = ?