mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 05:57:54 +00:00
parallel: Speedup finding shell of (grand)*parent pid.
This commit is contained in:
parent
f8782f43a7
commit
7aa0394278
|
@ -222,7 +222,9 @@ Quote of the month:
|
||||||
|
|
||||||
New in this release:
|
New in this release:
|
||||||
|
|
||||||
* {= uq() =} will cause the replacement string to be unquoted. Example: parallel echo '{=uq()=}.jpg' ::: '*'
|
* {= uq; =} will cause the replacement string to be unquoted. Example: parallel echo '{=uq;=}.jpg' ::: '*'
|
||||||
|
|
||||||
|
* Speedup of startup by 40%: Find the parent shell differerently on GNU/Linux, cache information about the CPU and which setpgrp method to make GNU Parallel start 40% faster.
|
||||||
|
|
||||||
https://techieroop.com/how-to-run-multiple-bash-scripts-in-parallel/
|
https://techieroop.com/how-to-run-multiple-bash-scripts-in-parallel/
|
||||||
|
|
||||||
|
|
21
src/parallel
21
src/parallel
|
@ -5442,6 +5442,27 @@ sub which(@) {
|
||||||
"-zsh" => ["zsh", "sh"],
|
"-zsh" => ["zsh", "sh"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if($^O eq "linux") {
|
||||||
|
# Optimized for GNU/Linux
|
||||||
|
my $testpid = $pid;
|
||||||
|
my $shellpath;
|
||||||
|
while($testpid) {
|
||||||
|
if($shellpath = readlink "/proc/$testpid/exe") {
|
||||||
|
if($shellpath =~ m:/$shell$:o) {
|
||||||
|
::debug("init", "proc which ".$shellpath." => ");
|
||||||
|
return $shellpath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(open(my $fd, "<", "/proc/$testpid/stat")) {
|
||||||
|
my $line = <$fd>;
|
||||||
|
close $fd;
|
||||||
|
$testpid = (split /\s+/, $line)[3];
|
||||||
|
} else {
|
||||||
|
# Something is wrong: fall back to old method
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
# if -sh or -csh try readlink /proc/$$/exe
|
# if -sh or -csh try readlink /proc/$$/exe
|
||||||
my ($children_of_ref, $parent_of_ref, $name_of_ref) = pid_table();
|
my ($children_of_ref, $parent_of_ref, $name_of_ref) = pid_table();
|
||||||
my $shellpath;
|
my $shellpath;
|
||||||
|
|
Loading…
Reference in a new issue