How can I run GNU parallel in record per job, with 1 process per core
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
What I'm really trying to do is run X number of jobs, with X amount in parallel for testing an API race condition.
I've come up with this
echo 1..10 | xargs -n1 | parallel -m 'echo ""';
which prints
7 8 9
10
4 5 6
1 2 3
but what I really want to see is (note order doesn't actually matter).
1
2
3
4
5
6
7
8
9
10
and those would be processed in parallel 4 at a time (or whatever number of cpus/cores, I have, e.g. --jobs 4
). For a total of 10 separate executions.
I tried this
echo 1..10 | xargs -n1 | parallel --semaphore --block 3 -m 'echo -n " ";
but it only ever seems to print once. bonus points if your solution doesn't need xargs which seems like a hack around the idea that the default record separator is a newline, but I haven't been able to get a space to work like I want either.
10
is a reasonably small number, but lets say it's much larger, 1000
echo 1..1000 | xargs -n1 | parallel -j1000
prints
parallel: Warning: Only enough file handles to run 60 jobs in parallel.
parallel: Warning: Running 'parallel -j0 -N 60 --pipe parallel -j0' or
parallel: Warning: raising 'ulimit -n' or 'nofile' in /etc/security/limits.conf
parallel: Warning: or /proc/sys/fs/file-max may help.
I don't actually want 1000 processes, I want 4 processes at a time, each process should process 1 record, thus by the time I'm done it will have executed 1000 times.
gnu parallelism gnu-parallel
add a comment |Â
up vote
2
down vote
favorite
What I'm really trying to do is run X number of jobs, with X amount in parallel for testing an API race condition.
I've come up with this
echo 1..10 | xargs -n1 | parallel -m 'echo ""';
which prints
7 8 9
10
4 5 6
1 2 3
but what I really want to see is (note order doesn't actually matter).
1
2
3
4
5
6
7
8
9
10
and those would be processed in parallel 4 at a time (or whatever number of cpus/cores, I have, e.g. --jobs 4
). For a total of 10 separate executions.
I tried this
echo 1..10 | xargs -n1 | parallel --semaphore --block 3 -m 'echo -n " ";
but it only ever seems to print once. bonus points if your solution doesn't need xargs which seems like a hack around the idea that the default record separator is a newline, but I haven't been able to get a space to work like I want either.
10
is a reasonably small number, but lets say it's much larger, 1000
echo 1..1000 | xargs -n1 | parallel -j1000
prints
parallel: Warning: Only enough file handles to run 60 jobs in parallel.
parallel: Warning: Running 'parallel -j0 -N 60 --pipe parallel -j0' or
parallel: Warning: raising 'ulimit -n' or 'nofile' in /etc/security/limits.conf
parallel: Warning: or /proc/sys/fs/file-max may help.
I don't actually want 1000 processes, I want 4 processes at a time, each process should process 1 record, thus by the time I'm done it will have executed 1000 times.
gnu parallelism gnu-parallel
I'm getting the expected result withecho 1..10 | xargs -n1 | parallel -m 'echo ""';
. The output is1 2 3 4 5n 6 7 8 9 10
(n
- linebreak in real). Works fine (GNU parallel 20141022
)
â RomanPerekhrest
Oct 27 '17 at 20:24
@Roman that newline says it only executed twice, I should actually have 10 separate executions
â xenoterracide
Oct 27 '17 at 20:26
10 separate executions is 10 jobs, as you know
â RomanPerekhrest
Oct 27 '17 at 20:27
@RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
â xenoterracide
Oct 27 '17 at 20:29
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
What I'm really trying to do is run X number of jobs, with X amount in parallel for testing an API race condition.
I've come up with this
echo 1..10 | xargs -n1 | parallel -m 'echo ""';
which prints
7 8 9
10
4 5 6
1 2 3
but what I really want to see is (note order doesn't actually matter).
1
2
3
4
5
6
7
8
9
10
and those would be processed in parallel 4 at a time (or whatever number of cpus/cores, I have, e.g. --jobs 4
). For a total of 10 separate executions.
I tried this
echo 1..10 | xargs -n1 | parallel --semaphore --block 3 -m 'echo -n " ";
but it only ever seems to print once. bonus points if your solution doesn't need xargs which seems like a hack around the idea that the default record separator is a newline, but I haven't been able to get a space to work like I want either.
10
is a reasonably small number, but lets say it's much larger, 1000
echo 1..1000 | xargs -n1 | parallel -j1000
prints
parallel: Warning: Only enough file handles to run 60 jobs in parallel.
parallel: Warning: Running 'parallel -j0 -N 60 --pipe parallel -j0' or
parallel: Warning: raising 'ulimit -n' or 'nofile' in /etc/security/limits.conf
parallel: Warning: or /proc/sys/fs/file-max may help.
I don't actually want 1000 processes, I want 4 processes at a time, each process should process 1 record, thus by the time I'm done it will have executed 1000 times.
gnu parallelism gnu-parallel
What I'm really trying to do is run X number of jobs, with X amount in parallel for testing an API race condition.
I've come up with this
echo 1..10 | xargs -n1 | parallel -m 'echo ""';
which prints
7 8 9
10
4 5 6
1 2 3
but what I really want to see is (note order doesn't actually matter).
1
2
3
4
5
6
7
8
9
10
and those would be processed in parallel 4 at a time (or whatever number of cpus/cores, I have, e.g. --jobs 4
). For a total of 10 separate executions.
I tried this
echo 1..10 | xargs -n1 | parallel --semaphore --block 3 -m 'echo -n " ";
but it only ever seems to print once. bonus points if your solution doesn't need xargs which seems like a hack around the idea that the default record separator is a newline, but I haven't been able to get a space to work like I want either.
10
is a reasonably small number, but lets say it's much larger, 1000
echo 1..1000 | xargs -n1 | parallel -j1000
prints
parallel: Warning: Only enough file handles to run 60 jobs in parallel.
parallel: Warning: Running 'parallel -j0 -N 60 --pipe parallel -j0' or
parallel: Warning: raising 'ulimit -n' or 'nofile' in /etc/security/limits.conf
parallel: Warning: or /proc/sys/fs/file-max may help.
I don't actually want 1000 processes, I want 4 processes at a time, each process should process 1 record, thus by the time I'm done it will have executed 1000 times.
gnu parallelism gnu-parallel
edited Oct 27 '17 at 20:41
asked Oct 27 '17 at 20:20
xenoterracide
24.6k51156218
24.6k51156218
I'm getting the expected result withecho 1..10 | xargs -n1 | parallel -m 'echo ""';
. The output is1 2 3 4 5n 6 7 8 9 10
(n
- linebreak in real). Works fine (GNU parallel 20141022
)
â RomanPerekhrest
Oct 27 '17 at 20:24
@Roman that newline says it only executed twice, I should actually have 10 separate executions
â xenoterracide
Oct 27 '17 at 20:26
10 separate executions is 10 jobs, as you know
â RomanPerekhrest
Oct 27 '17 at 20:27
@RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
â xenoterracide
Oct 27 '17 at 20:29
add a comment |Â
I'm getting the expected result withecho 1..10 | xargs -n1 | parallel -m 'echo ""';
. The output is1 2 3 4 5n 6 7 8 9 10
(n
- linebreak in real). Works fine (GNU parallel 20141022
)
â RomanPerekhrest
Oct 27 '17 at 20:24
@Roman that newline says it only executed twice, I should actually have 10 separate executions
â xenoterracide
Oct 27 '17 at 20:26
10 separate executions is 10 jobs, as you know
â RomanPerekhrest
Oct 27 '17 at 20:27
@RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
â xenoterracide
Oct 27 '17 at 20:29
I'm getting the expected result with
echo 1..10 | xargs -n1 | parallel -m 'echo ""';
. The output is 1 2 3 4 5n 6 7 8 9 10
(n
- linebreak in real). Works fine (GNU parallel 20141022
)â RomanPerekhrest
Oct 27 '17 at 20:24
I'm getting the expected result with
echo 1..10 | xargs -n1 | parallel -m 'echo ""';
. The output is 1 2 3 4 5n 6 7 8 9 10
(n
- linebreak in real). Works fine (GNU parallel 20141022
)â RomanPerekhrest
Oct 27 '17 at 20:24
@Roman that newline says it only executed twice, I should actually have 10 separate executions
â xenoterracide
Oct 27 '17 at 20:26
@Roman that newline says it only executed twice, I should actually have 10 separate executions
â xenoterracide
Oct 27 '17 at 20:26
10 separate executions is 10 jobs, as you know
â RomanPerekhrest
Oct 27 '17 at 20:27
10 separate executions is 10 jobs, as you know
â RomanPerekhrest
Oct 27 '17 at 20:27
@RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
â xenoterracide
Oct 27 '17 at 20:29
@RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
â xenoterracide
Oct 27 '17 at 20:29
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
I want 4 processes at a time, each process should process 1 record
parallel -j4 -k --no-notice 'echo ""' ::: 1..10
-j4
- number of jobslots. Run up to 4 jobs in parallel-k
- keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes:::
- arguments
The output:
1
2
3
4
5
6
7
8
9
10
Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong:parallel "echo ''" ::: '$'
â Ole Tange
Oct 29 '17 at 23:04
add a comment |Â
up vote
1
down vote
seq 10 | parallel -j4 echo
Or if you have 4 cores:
seq 10 | parallel echo
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
I want 4 processes at a time, each process should process 1 record
parallel -j4 -k --no-notice 'echo ""' ::: 1..10
-j4
- number of jobslots. Run up to 4 jobs in parallel-k
- keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes:::
- arguments
The output:
1
2
3
4
5
6
7
8
9
10
Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong:parallel "echo ''" ::: '$'
â Ole Tange
Oct 29 '17 at 23:04
add a comment |Â
up vote
4
down vote
accepted
I want 4 processes at a time, each process should process 1 record
parallel -j4 -k --no-notice 'echo ""' ::: 1..10
-j4
- number of jobslots. Run up to 4 jobs in parallel-k
- keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes:::
- arguments
The output:
1
2
3
4
5
6
7
8
9
10
Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong:parallel "echo ''" ::: '$'
â Ole Tange
Oct 29 '17 at 23:04
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
I want 4 processes at a time, each process should process 1 record
parallel -j4 -k --no-notice 'echo ""' ::: 1..10
-j4
- number of jobslots. Run up to 4 jobs in parallel-k
- keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes:::
- arguments
The output:
1
2
3
4
5
6
7
8
9
10
I want 4 processes at a time, each process should process 1 record
parallel -j4 -k --no-notice 'echo ""' ::: 1..10
-j4
- number of jobslots. Run up to 4 jobs in parallel-k
- keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes:::
- arguments
The output:
1
2
3
4
5
6
7
8
9
10
edited Oct 28 '17 at 8:54
answered Oct 27 '17 at 21:15
RomanPerekhrest
22.5k12145
22.5k12145
Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong:parallel "echo ''" ::: '$'
â Ole Tange
Oct 29 '17 at 23:04
add a comment |Â
Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong:parallel "echo ''" ::: '$'
â Ole Tange
Oct 29 '17 at 23:04
Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong:
parallel "echo ''" ::: '$'
â Ole Tange
Oct 29 '17 at 23:04
Contrary to shell variables GNU Parallel replacement strings should not be quoted. In most cases (like here) it does no harm, but try this as an example of where it goes wrong:
parallel "echo ''" ::: '$'
â Ole Tange
Oct 29 '17 at 23:04
add a comment |Â
up vote
1
down vote
seq 10 | parallel -j4 echo
Or if you have 4 cores:
seq 10 | parallel echo
add a comment |Â
up vote
1
down vote
seq 10 | parallel -j4 echo
Or if you have 4 cores:
seq 10 | parallel echo
add a comment |Â
up vote
1
down vote
up vote
1
down vote
seq 10 | parallel -j4 echo
Or if you have 4 cores:
seq 10 | parallel echo
seq 10 | parallel -j4 echo
Or if you have 4 cores:
seq 10 | parallel echo
answered Oct 28 '17 at 18:57
Ole Tange
11.4k1344102
11.4k1344102
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f400958%2fhow-can-i-run-gnu-parallel-in-record-per-job-with-1-process-per-core%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
I'm getting the expected result with
echo 1..10 | xargs -n1 | parallel -m 'echo ""';
. The output is1 2 3 4 5n 6 7 8 9 10
(n
- linebreak in real). Works fine (GNU parallel 20141022
)â RomanPerekhrest
Oct 27 '17 at 20:24
@Roman that newline says it only executed twice, I should actually have 10 separate executions
â xenoterracide
Oct 27 '17 at 20:26
10 separate executions is 10 jobs, as you know
â RomanPerekhrest
Oct 27 '17 at 20:27
@RomanPerekhrest yes, but I only want to have 4 jobs running at a time, 4 processes, 10 records, 10 command executions.
â xenoterracide
Oct 27 '17 at 20:29