parallel: Adjust length to read to make --block more predictable.

This commit is contained in:
Ole Tange 2015-07-19 00:17:42 +02:00
parent e4e88de3cb
commit cfc8501693
2 changed files with 9 additions and 4 deletions

View file

@ -226,6 +226,8 @@ New in this release:
* Due to widely spread distributions still using --tollef even after a year of being retired following a year of being obsolete, --tollef now gives an error unless used with --gnu. * Due to widely spread distributions still using --tollef even after a year of being retired following a year of being obsolete, --tollef now gives an error unless used with --gnu.
* Cookie 2013-08-18 was won by Mark Maimone, 1 year and 11 months after release.
* A parser for GNU Parallel --joblog files: https://github.com/harryjubb/joblog * A parser for GNU Parallel --joblog files: https://github.com/harryjubb/joblog
* <<Har angiveligt submittet ny version - afventer opdatering>> GNU Parallel was used (unfortunately without citation) in: MUGBAS: a species free gene-based programme suite for post-GWAS analysis http://www.ncbi.nlm.nih.gov/pubmed/25765345 * <<Har angiveligt submittet ny version - afventer opdatering>> GNU Parallel was used (unfortunately without citation) in: MUGBAS: a species free gene-based programme suite for post-GWAS analysis http://www.ncbi.nlm.nih.gov/pubmed/25765345

View file

@ -318,7 +318,11 @@ sub spreadstdin {
my $header = find_header(\$buf,$in); my $header = find_header(\$buf,$in);
while(1) { while(1) {
my $anything_written = 0; my $anything_written = 0;
if(not read($in,substr($buf,length $buf,0),$blocksize)) { my $buflen = length $buf;
my $readsize = ($buflen < $blocksize) ? $blocksize-$buflen : $blocksize;
# If $buf < $blocksize, append so it is $blocksize long after reading.
# Otherwise append a full $blocksize
if(not read($in,substr($buf,$buflen,0),$readsize)) {
# End-of-file # End-of-file
$chunk_number != 1 and last; $chunk_number != 1 and last;
# Force the while-loop once if everything was read by header reading # Force the while-loop once if everything was read by header reading
@ -472,7 +476,6 @@ sub nindex {
# the position where the Nth copy is found # the position where the Nth copy is found
my ($buf_ref, $str, $n) = @_; my ($buf_ref, $str, $n) = @_;
my $i = 0; my $i = 0;
my $two_gb = 2**31-1;
for(1..$n) { for(1..$n) {
$i = index64($buf_ref,$str,$i+1); $i = index64($buf_ref,$str,$i+1);
if($i == -1) { last } if($i == -1) { last }
@ -6144,7 +6147,7 @@ sub non_block_write {
} else { } else {
# successfully wrote everything # successfully wrote everything
my $a = ""; my $a = "";
$self->set_stdin_buffer(\$a,\$a,"",""); $self->set_stdin_buffer(\$a,\$a,0,"","");
$something_written = $rv; $something_written = $rv;
} }
} }
@ -6189,7 +6192,7 @@ sub set_starttime {
sub runtime { sub runtime {
# Returns: # Returns:
# Run time in seconds # Run time in seconds with 3 decimals
my $self = shift; my $self = shift;
return sprintf("%.3f",int(($self->endtime() - $self->starttime())*1000)/1000); return sprintf("%.3f",int(($self->endtime() - $self->starttime())*1000)/1000);
} }