user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] extindex: support --jobs/-j properly on creation for shard count
Date: Sun, 25 Jul 2021 12:44:23 +0000	[thread overview]
Message-ID: <20210725124423.1648-1-e@80x24.org> (raw)

This wasn't wired up properly, but Xapian appears to suffer from
I/O amplification problems as DB shards get larger:

  https://lists.xapian.org/pipermail/xapian-discuss/2019-February/009727.html
  <23640.32170.703368.841021@y.dockes.com>

Of course, we shouldn't have too many shards, either; because
performance problems with too many shards was the entire reason
extindex was created:

  https://lists.xapian.org/pipermail/xapian-discuss/2020-August/009823.html
  <20200826064728.GA32239@dcvr>
---
 lib/PublicInbox/ExtSearchIdx.pm |  3 ++-
 t/extsearch.t                   | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm
index 357312b8..ad56c0d5 100644
--- a/lib/PublicInbox/ExtSearchIdx.pm
+++ b/lib/PublicInbox/ExtSearchIdx.pm
@@ -52,7 +52,8 @@ sub new {
 		parallel => 1,
 		lock_path => "$dir/ei.lock",
 	}, __PACKAGE__;
-	$self->{shards} = $self->count_shards || nproc_shards($opt->{creat});
+	$self->{shards} = $self->count_shards ||
+		nproc_shards({ nproc => $opt->{jobs} });
 	my $oidx = PublicInbox::OverIdx->new("$self->{xpfx}/over.sqlite3");
 	$self->{-no_fsync} = $oidx->{-no_fsync} = 1 if !$opt->{fsync};
 	$self->{oidx} = $oidx;
diff --git a/t/extsearch.t b/t/extsearch.t
index 46a6f2ec..1f62e80c 100644
--- a/t/extsearch.t
+++ b/t/extsearch.t
@@ -411,4 +411,15 @@ if ('dedupe + dry-run') {
 		'--dry-run alone fails');
 }
 
+for my $j (1, 3, 6) {
+	my $o = { 2 => \(my $err = '') };
+	my $d = "$home/extindex-j$j";
+	ok(run_script(['-extindex', "-j$j", '--all', $d], undef, $o),
+		"init with -j$j");
+	my $max = $j - 2;
+	$max = 0 if $max < 0;
+	my @dirs = glob("$d/ei*/?");
+	like($dirs[-1], qr!/ei[0-9]+/$max\z!, '-j works');
+}
+
 done_testing;

                 reply	other threads:[~2021-07-25 12:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210725124423.1648-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).