gnu-parallel

Understanding GNU Parallel --nonall and --onall options and their behavior with --delay


I'm trying to understand the behavior of the --nonall and --onall options in GNU Parallel, and how they interact with the --delay option. I've encountered a few cases where the behavior is not as expected, and I'd appreciate some clarification.

  1. --nonall vs --onall When I run the following commands with --jobs 1:
parallel --nonall --jobs 1 echo "1" ::: a a a
parallel --onall --jobs 1 echo "1" ::: a a a

the result is the same. So what is the difference?

  1. --delay with --nonall: When I run the following command:

parallel --nonall --jobs 1 --delay 5s echo "1" ::: a a a

There doesn't seem to be any delay between the execution of the command for each input. However, when I use --onall instead of --nonall, the delay is applied as expected.

parallel --onall --jobs 1 --delay 5s echo "1" ::: a a a

Could you please explain why the --delay option appears to have no effect when used with --nonall, but works as expected with --onall?


Solution

  • You are going into territory that is not well tested. Thus you discover some suprising behaviour that might be considers bugs.

    First of all: --(n)onall make no sense running locally. They only deal with servers (--sshlogin/-S):

    # "echo 1" is run on all servers
    $ parallel -S server1,server2 --nonall echo 1
    1
    1
    
    # "echo 1 a" "echo 1 b" "echo 1 c" are run on all servers
    $ parallel -S server1,server2 --onall echo 1 ::: a b c
    1 a
    1 b
    1 c
    1 a
    1 b
    1 c
    

    It is true that --nonall also reacts to arguments on the command line:

    $ parallel -S server1,server2 --nonall echo 1 ::: a b c
    1 a
    1 b
    1 c
    1 a
    1 b
    1 c
    

    You can either consider this a bug or that you are using it in an undefined way: The arguments should be ignored.

    If you give the arguments on standard input (stdin) the input is indeed ignored by --nonall:

    # Standard input (stdin) is ignored
    $ (echo a;echo b;echo c) | parallel -S server1,server2 --nonall echo 1
    1
    1
    # Standard input (stdin) is used
    $ (echo a;echo b;echo c) | parallel -S server1,server2 --onall echo 1
    1 a
    1 b
    1 c
    1 a
    1 b
    1 c
    

    Currently --delay is ignored.

    You would feel free to post on the mailing list what you think --delay should do when combined with --(n)onall. If you do that, please also address how the behaviour of --sshdelay should differ.