]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: clamp internal worker processes to 4
authorEric Wong <e@80x24.org>
Sun, 19 Sep 2021 12:50:26 +0000 (12:50 +0000)
committerEric Wong <e@80x24.org>
Sun, 19 Sep 2021 19:52:48 +0000 (19:52 +0000)
"All" my CPUs is only 4, but it's probably ridiculous for
somebody with a 16-core system to have 16 processes for
accessing SQLite DBs.

We do the same thing in Pmdir for parallel Maildir access
(and V2Writable).

lib/PublicInbox/LeiImportKw.pm
lib/PublicInbox/LeiNoteEvent.pm

index 2863d17f829e7f86e964253b6dc00af4d1bf88b2..379101c2dae8c5525242263ba986a295fd66fc3d 100644 (file)
@@ -11,7 +11,9 @@ use parent qw(PublicInbox::IPC);
 sub new {
        my ($cls, $lei) = @_;
        my $self = bless { -wq_ident => 'lei import_kw worker' }, $cls;
-       my ($op_c, $ops) = $lei->workers_start($self, $self->detect_nproc);
+       my $j = $self->detect_nproc // 4;
+       $j = 4 if $j > 4;
+       my ($op_c, $ops) = $lei->workers_start($self, $j);
        $op_c->{ops} = $ops; # for PktOp->event_step
        $self->{lei_sock} = $lei->{sock};
        $lei->{ikw} = $self;
index 5f692e754b5d7782ffe439fcc04f81467925d743..a0591a094ea851125117e4b89719d5327d01dd42 100644 (file)
@@ -80,8 +80,9 @@ sub lei_note_event {
        my $self = $cfg->{-lei_note_event} //= do {
                my $wq = bless { lms => $lms }, __PACKAGE__;
                # MUAs such as mutt can trigger massive rename() storms so
-               # use all CPU power available:
+               # use some CPU, but don't overwhelm slower storage, either
                my $jobs = $wq->detect_nproc // 1;
+               $jobs = 4 if $jobs > 4; # same default as V2Writable
                my ($op_c, $ops) = $lei->workers_start($wq, $jobs);
                $lei->wait_wq_events($op_c, $ops);
                note_event_arm_done($lei);