forked from cooperative-computing-lab/cctools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix auto mode (cooperative-computing-lab#3257)
* also update first allocation when using max mode * consolidate category_{bucketing,}_dynamic_task_* to category_task * round up to histogram bucket size for "classical modes" * add test * add factory to PATH * add worker to PATH * fix max -> min * set timeout on test * disable on mac because the monitor does not work there
- Loading branch information
Showing
8 changed files
with
176 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
. ../../dttools/test/test_runner_common.sh | ||
|
||
import_config_val CCTOOLS_PYTHON_TEST_EXEC | ||
import_config_val CCTOOLS_PYTHON_TEST_DIR | ||
import_config_val CCTOOLS_OPSYS | ||
|
||
export PYTHONPATH=$(pwd)/../src/bindings/${CCTOOLS_PYTHON_TEST_DIR}:$PYTHONPATH | ||
export PATH=$(pwd)/../../batch_job/src:$PATH | ||
export PATH=$(pwd)/../src/worker:$PATH | ||
|
||
STATUS_FILE=vine.status | ||
|
||
check_needed() | ||
{ | ||
[ -n "${CCTOOLS_PYTHON_TEST_EXEC}" ] || return 1 | ||
|
||
# disable on mac because the resource_monitor does not work there | ||
[ "${CCTOOLS_OPSYS}" = DARWIN ] && return 1 | ||
} | ||
|
||
prepare() | ||
{ | ||
rm -f $STATUS_FILE | ||
|
||
return 0 | ||
} | ||
|
||
run() | ||
{ | ||
(${CCTOOLS_PYTHON_TEST_EXEC} auto_modes.py; echo $? > $STATUS_FILE) & | ||
|
||
wait_for_file_creation $STATUS_FILE 30 | ||
|
||
# retrieve exit status | ||
status=$(cat $STATUS_FILE) | ||
if [ $status -ne 0 ] | ||
then | ||
# display log files in case of failure. | ||
logfile=$(latest_vine_debug_log) | ||
if [ -f ${logfile} ] | ||
then | ||
echo "manager log:" | ||
cat ${logfile} | ||
fi | ||
|
||
exit 1 | ||
fi | ||
|
||
exit 0 | ||
} | ||
|
||
clean() | ||
{ | ||
rm -f $STATUS_FILE | ||
rm -rf vine-run-info | ||
|
||
exit 0 | ||
} | ||
|
||
|
||
dispatch "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#! /usr/bin/env python | ||
|
||
import taskvine as vine | ||
import sys | ||
import time | ||
|
||
m = vine.Manager(port=0, ssl=True) | ||
m.enable_monitoring() | ||
|
||
m.tune("category-steady-n-tasks", 1) | ||
|
||
bucket_size = 250 | ||
worker = { | ||
"cores": 4, | ||
"memory": bucket_size * 4, | ||
"disk": bucket_size * 8 | ||
} | ||
|
||
factory = vine.Factory(manager=m) | ||
factory.max_workers = 1 | ||
factory.min_workers = 1 | ||
factory.cores = worker["cores"] | ||
factory.memory = worker["memory"] | ||
factory.disk = worker["disk"] | ||
|
||
modes = { | ||
"max": vine.VINE_ALLOCATION_MODE_MAX, | ||
"thr": vine.VINE_ALLOCATION_MODE_MAX_THROUGHPUT, | ||
"wst": vine.VINE_ALLOCATION_MODE_MIN_WASTE, | ||
} | ||
|
||
expected_proportions = { | ||
"max": 0.5, # half of the disk, so half of the resources | ||
"thr": 1/worker["cores"], | ||
"wst": 1/worker["cores"] | ||
} | ||
|
||
error_found = False | ||
|
||
last_returned_time = time.time() | ||
|
||
with factory: | ||
for (category, mode) in modes.items(): | ||
m.set_category_mode(category, mode) | ||
|
||
# first task needs little less than half of the disk, which should round up to half the disk | ||
t = vine.Task( | ||
f"dd count=0 bs={int(worker['disk']/2.5)}M seek=1 of=nulls") | ||
t.set_category(category) | ||
m.submit(t) | ||
|
||
for i in range(10): | ||
t = vine.Task("dd count=0 bs=1M seek=1 of=nulls") | ||
t.set_category(category) | ||
m.submit(t) | ||
|
||
print(f"\n{category}: ", end="") | ||
while not m.empty(): | ||
t = m.wait(5) | ||
if t: | ||
print(".", end="") | ||
last_returned_time = time.time() | ||
|
||
# if no task for 15s, something went wrong with the test | ||
if time.time() - last_returned_time > 15: | ||
print("\nno task finished recently") | ||
sys.exit(1) | ||
|
||
rs = "cores memory disk".split() | ||
mr = {r: getattr(t.resources_measured, r) for r in rs} | ||
ar = {r: getattr(t.resources_allocated, r) for r in rs} | ||
|
||
print("") | ||
for r in rs: | ||
sign = "=" | ||
expected = expected_proportions[category] * worker[r] | ||
if ar[r] != expected: | ||
error_found = True | ||
sign = "!" | ||
print(f"{r} measured {mr[r]}, allocated {ar[r]} {sign}= {expected}") | ||
|
||
sys.exit(error_found) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters