Skip to content

Commit

Permalink
[backend] support memory per job constraint
Browse files Browse the repository at this point in the history
To increase the memory need per used job on the worker. This can be
potentionally racy, because parallel builds may happened on different
times so the need of memory might differ depending on build speed.
  • Loading branch information
adrianschroeter committed Aug 13, 2020
1 parent 3834fae commit ec73240
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/api/api/constraints.rng
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@
<ref name="size-unit"/>
</element>
</optional>
<optional>
<element name="memoryperjob">
<ref name="size-unit"/>
</element>
</optional>
<optional>
<element name="physicalmemory">
<ref name="size-unit"/>
Expand Down
1 change: 1 addition & 0 deletions src/backend/BSDispatcher/Constraints.pm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +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'}->{'physicalmemory'} && getmbsize($constraints->{'hardware'}->{'physicalmemory'}) > $memory;
if ($constraints->{'hardware'}->{'cpu'}) {
return 0 unless $worker->{'hardware'}->{'cpu'};
Expand Down
1 change: 1 addition & 0 deletions src/backend/BSXML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,7 @@ our @constraint = (
'jobs',
[ 'disk' => $size ],
[ 'memory' => $size ],
[ 'memoryperjob' => $size ],
[ 'physicalmemory' => $size ],
]
);
Expand Down
4 changes: 4 additions & 0 deletions src/backend/testdata/test_dispatcher
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ td sandbox24 true "kernel" i586 medium sandbox_secure enforce_kvm
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

echo

if [ -n "$FAILS" ]; then
Expand Down

0 comments on commit ec73240

Please sign in to comment.