Skip to content

Commit

Permalink
Use full paths to dx command
Browse files Browse the repository at this point in the history
Switch to vfork/exec from system to avoid doubling memory reservation for dx command
Reserve buffer of memory for OS when scheduling jobs
  • Loading branch information
skoren committed May 25, 2018
1 parent 2ff48f3 commit 6f3c375
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
20 changes: 17 additions & 3 deletions src/AS_UTL/objectStore.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "splitToWords.H"

#include <libgen.h>
#include <sys/wait.h>


static
Expand Down Expand Up @@ -235,12 +236,25 @@ fetchFromObjectStore(char *requested) {
fprintf(stderr, "fetchFromObjectStore()-- found path '%s'\n", path);

char *cmd = new char [FILENAME_MAX+1];

snprintf(cmd, FILENAME_MAX, "%s download --output \"%s\" \"%s:%s/%s\"", dx, requested, pr, ns, path);
snprintf(cmd, FILENAME_MAX, "%s:%s/%s", pr, ns, path);
char *args[8] = {"dx", "download", "--overwrite", "--no-progress", "--output", "", "", (char*)0};
args[5] = requested;
args[6] = cmd;

fprintf(stderr, "fetchFromObjectStore()-- executing '%s'\n", cmd);

int32 err = system(cmd);
int32 err;
int32 pid = vfork();
if ( pid == -1)
fprintf(stderr, "vfork failed with error '%s'.\n", strerror(errno));

if ( pid == 0 ) {
execve(dx, args, environ);
fprintf(stderr, "execve failed with error '%s'.\n", strerror(errno));
_exit(-1);
}
waitpid(-1, (int*)&err, 0);
err = WEXITSTATUS(err);

if (err == 127)
fprintf(stderr, "Failed to execute '%s'.\n", cmd), exit(1);
Expand Down
5 changes: 3 additions & 2 deletions src/dx-canu/src/canu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ main() {

if [ ! -s ${output_prefix}.contigs.fasta ]; then
# save the command without the inputs
echo "canu executiveMemory=8 executiveThreads=2 objectStore=DNANEXUS objectStoreClient=dx objectStoreNameSpace=$output_path objectStoreProject=$DX_PROJECT_CONTEXT_ID -d . -p ${output_prefix} genomeSize=${genome_size} $parameters" > canu.sh
dx_command=`which dx`
echo "canu executiveMemory=8 executiveThreads=2 objectStore=DNANEXUS objectStoreClient=$dx_command objectStoreNameSpace=$output_path objectStoreProject=$DX_PROJECT_CONTEXT_ID -d . -p ${output_prefix} genomeSize=${genome_size} $parameters" > canu.sh
# bash is set to quit in the app on any error (including file doesn't exist) so we only run rm on success of describe, otherwise nothing
exists=`dx describe --name $DX_PROJECT_CONTEXT_ID:$output_path/canu.sh || true`
if [[ -e canu.sh && x$exists != x ]] ; then
Expand All @@ -107,6 +108,6 @@ main() {
dx upload --wait --parents --path $DX_PROJECT_CONTEXT_ID:$output_path/canu.sh canu.sh

# run the canu command
canu executiveMemory=8 executiveThreads=2 objectStore=DNANEXUS objectStoreClient=dx objectStoreNameSpace=$output_path objectStoreProject=$DX_PROJECT_CONTEXT_ID -d . -p ${output_prefix} genomeSize=${genome_size} $parameters ${input_type} ${input_files_name[@]}
canu executiveMemory=8 executiveThreads=2 objectStore=DNANEXUS objectStoreClient=$dx_command objectStoreNameSpace=$output_path objectStoreProject=$DX_PROJECT_CONTEXT_ID -d . -p ${output_prefix} genomeSize=${genome_size} $parameters ${input_type} ${input_files_name[@]}
fi
}
2 changes: 1 addition & 1 deletion src/pipelines/canu/Grid_DNANexus.pm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ sub buildAvailableNodeList() {
my @v = split '\|', $_;

my $cpus = $v[$cpuIdx];
my $mem = $v[$memIdx];
my $mem = $v[$memIdx] * 0.85; # the machines don't have swap so save some space for OS overhead
my $name = $v[$nameIdx];

$mem = int($mem);
Expand Down

0 comments on commit 6f3c375

Please sign in to comment.