Skip to content

Commit

Permalink
[backend] fix memoryperjob dispatch constraints handling
Browse files Browse the repository at this point in the history
and improve testcase for it
  • Loading branch information
adrianschroeter committed Aug 20, 2020
1 parent b050a3d commit f5bb6d3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/backend/BSDispatcher/Constraints.pm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ sub oracle {
my $memory = ($worker->{'hardware'}->{'memory'} || 0);
my $swap = ($worker->{'hardware'}->{'swap'} || 0);
return 0 if $constraints->{'hardware'}->{'memory'} && getmbsize($constraints->{'hardware'}->{'memory'}) > ( $memory + $swap );
return 0 if $constraints->{'hardware'}->{'memoryperjob'} && getmbsize($constraints->{'hardware'}->{'memoryperjob'} * ($worker->{'hardware'}->{'jobs'} || 1)) > ( $memory + $swap );
return 0 if $constraints->{'hardware'}->{'memoryperjob'} && getmbsize($constraints->{'hardware'}->{'memoryperjob'}) * ($worker->{'hardware'}->{'jobs'} || 1) > ( $memory + $swap );
return 0 if $constraints->{'hardware'}->{'physicalmemory'} && getmbsize($constraints->{'hardware'}->{'physicalmemory'}) > $memory;
if ($constraints->{'hardware'}->{'cpu'}) {
return 0 unless $worker->{'hardware'}->{'cpu'};
Expand Down
8 changes: 8 additions & 0 deletions src/backend/testdata/constraint/tensorflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<constraints>
<hardware>
<memoryperjob>
<size unit="M">700</size>
</memoryperjob>
</hardware>
</constraints>

6 changes: 4 additions & 2 deletions src/backend/testdata/test_dispatcher
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ td sandbox25 true "kernel" i586 large sandbox enforce_kvm
td sandbox26 true "kernel" i586 large sandbox_secure enforce_kvm

# combined constraints for sandbox
td perjob21 false "chromium" i586 small kernel
td perjob22 true "chromium" i586 large kernel
td perjob21 false "chromium" i586 small tensorflow
td perjob22 true "chromium" i586 medium tensorflow
td perjob23 false "chromium" i586 large tensorflow


echo

Expand Down
1 change: 1 addition & 0 deletions src/backend/testdata/workerinfo/large
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</cpu>
<nativeonly/>
<processors>32</processors>
<jobs>100</jobs>
<memory>6400</memory>
<swap>51200</swap>
<disk>204800</disk>
Expand Down
1 change: 1 addition & 0 deletions src/backend/testdata/workerinfo/medium
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<flag>sse</flag>
</cpu>
<processors>2</processors>
<jobs>2</jobs>
<memory>512</memory>
<swap>1024</swap>
<disk>4096</disk>
Expand Down

0 comments on commit f5bb6d3

Please sign in to comment.