diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-18 09:13:08 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-18 09:14:12 +0000 |
commit | b47de2471c0ed4f6edabf26b435d40559e71692b (patch) | |
tree | fefaa28b9e90d1c8c75b0cc8d79e9512e4997f0c /lib/PublicInbox/V2Writable.pm | |
parent | 0961df2523044bf32270909f4983349eccad0153 (diff) | |
download | public-inbox-b47de2471c0ed4f6edabf26b435d40559e71692b.tar.gz |
git fast-import and the main V2Writable process combined takes about one CPU, so avoid having too many Xapian partitions which cause unnecessary I/O contention.
Diffstat (limited to 'lib/PublicInbox/V2Writable.pm')
-rw-r--r-- | lib/PublicInbox/V2Writable.pm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 1cc4b005..66f8a8a3 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -22,8 +22,11 @@ use IO::Handle; my $PACKING_FACTOR = 0.4; # assume 2 cores if GNU nproc(1) is not available -sub nproc () { - int($ENV{NPROC} || `nproc 2>/dev/null` || 2); +sub nproc_parts () { + my $n = int($ENV{NPROC} || `nproc 2>/dev/null` || 2); + # subtract for the main process and git-fast-import + $n -= 1; + $n < 1 ? 1 : $n; } sub count_partitions ($) { @@ -73,7 +76,7 @@ sub new { rotate_bytes => int((1024 * 1024 * 1024) / $PACKING_FACTOR), last_commit => [], # git repo -> commit }; - $self->{partitions} = count_partitions($self) || nproc(); + $self->{partitions} = count_partitions($self) || nproc_parts(); bless $self, $class; } |