From: Eric Wong Date: Sat, 15 Feb 2025 11:10:04 +0000 (+0000) Subject: favor run_wait() over CORE::system() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0004c6c88571364766302102c26e7d623d923e85;p=thirdparty%2Fpublic-inbox.git favor run_wait() over CORE::system() run_wait() can use vfork(2) which saves memory in large processes, such as public-inbox-extindex when dealing with giant messages. While vfork is unlikely to matter for real-world uses of public-inbox-edit, PublicInbox::Spawn is a sunk cost treewide our `make check-run' test target avoids spawning new Perl processes for most things in script/*, so there can be a small savings for testing. --- diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm index d1a16c84f..7cf600c1f 100644 --- a/lib/PublicInbox/ExtSearchIdx.pm +++ b/lib/PublicInbox/ExtSearchIdx.pm @@ -24,7 +24,7 @@ use File::Glob qw(bsd_glob GLOB_NOSORT); use PublicInbox::SQLiteUtil; use PublicInbox::Isearch; use PublicInbox::MultiGit; -use PublicInbox::Spawn (); +use PublicInbox::Spawn qw(run_wait); use PublicInbox::Search; use PublicInbox::SearchIdx qw(prepare_stack is_ancestor is_bad_blob update_checkpoint); @@ -1266,8 +1266,9 @@ sub idx_init { # similar to V2Writable if ($git_midx && ($opt->{'multi-pack-index'} // 1)) { my $cmd = $self->git->cmd('multi-pack-index'); push @$cmd, '--no-progress' if ($opt->{quiet}//0) > 1; + push @$cmd, 'write'; my $lk = $self->lock_for_scope; - system(@$cmd, 'write'); + run_wait $cmd; # ignore errors, fairly new command, may not exist } $self->parallel_init($self->{indexlevel}); diff --git a/script/public-inbox-edit b/script/public-inbox-edit index 88115d7cc..c76579e4b 100755 --- a/script/public-inbox-edit +++ b/script/public-inbox-edit @@ -15,6 +15,7 @@ PublicInbox::Admin::check_require('-index'); use PublicInbox::Eml; use PublicInbox::InboxWritable qw(eml_from_path); use PublicInbox::Import; +use PublicInbox::Spawn qw(run_wait); my $help = <<'EOF'; usage: public-inbox-edit -m MESSAGE-ID [--all] [INBOX_DIRS] @@ -159,7 +160,7 @@ foreach my $to_edit (values %$found) { # run the editor, respecting spaces/quote retry_edit: - if (system(qw(sh -c), $editor.' "$@"', $editor, $edit_fn)) { + if (run_wait [qw(sh -c), $editor.' "$@"', $editor, $edit_fn]) { if (!(-t STDIN) && !$opt->{force}) { die "E: $editor failed: $?\n"; }