From ac2cbae7af54527299dbfe927716ebc3c7ec89de Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 9 Jun 2021 07:47:49 +0000 Subject: lei tag: parallelize Maildir access Since Maildir isn't guaranteed to have any sort of order, we can parallelize inputs, here. On a 4-core system, this reduced one of my tag invocations from 5.5 to 1.4s. --- lib/PublicInbox/LeiImport.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/LeiImport.pm') diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm index cddd5619..e3cb69ca 100644 --- a/lib/PublicInbox/LeiImport.pm +++ b/lib/PublicInbox/LeiImport.pm @@ -35,13 +35,13 @@ sub pmdir_cb { # called via wq_io_do from LeiPmdir->each_mdir_fn die "BUG: $f was not from a Maildir?\n"; my $kw = PublicInbox::MdirReader::flags2kw($fl); substr($folder, 0, 0) = 'maildir:'; # add prefix - my $lms = $self->{-lms_ro}; + my $lse = $self->{lse} //= $self->{lei}->{sto}->search; + my $lms = $self->{-lms_ro} //= $lse->lms; # may be 0 or undef my $oidbin = $lms ? $lms->name_oidbin($folder, $bn) : undef; - my @docids = defined($oidbin) ? - $self->{over}->oidbin_exists($oidbin) : (); + my @docids = defined($oidbin) ? $lse->over->oidbin_exists($oidbin) : (); my $vmd = $self->{-import_kw} ? { kw => $kw } : undef; if (scalar @docids) { - $self->{lse}->kw_changed(undef, $kw, \@docids) or return; + $lse->kw_changed(undef, $kw, \@docids) or return; } if (my $eml = eml_from_path($f)) { $vmd->{sync_info} = [ $folder, \$bn ] if $self->{-mail_sync}; -- cgit v1.2.3-24-ge0c7