Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use PocketIC in drun #4555

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions test/drun-wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env bash

CONFIG=$(realpath $(dirname $0)/drun.json5)

#
# This script wraps drun to
#
Expand All @@ -23,32 +21,26 @@ fi

export LANG=C.UTF-8

# this could be used to delay drun to make it more deterministic, but
# it doesn't work reliably and slows down the test significantly.
# so until DFN-1269 fixes this properly, let's just not run
# affected tests on drun (only ic-ref-run).
EXTRA_BATCHES=1

# on darwin, I have seen
# thread 'MR Batch Processor' has overflowed its stack
# and this helps (default is 2MB)
export RUST_MIN_STACK=$((10*1024*1024))

# drun creates canisters with this ID:
ID=rwlgt-iiaaa-aaaaa-aaaaa-cai
ID=lxzze-o7777-77777-aaaaa-cai

if [ "${1: -5}" = ".drun" ]
then
# work around different IDs in ic-ref-run and drun
( echo "create"
LANG=C perl -npe 's,\$ID,'$ID',g' $1
) | drun -c "$CONFIG" --extra-batches $EXTRA_BATCHES /dev/stdin
) | drun --cycles-used-file /dev/fd/222 /dev/stdin
else
( echo "create"
echo "install $ID $1 0x"
if [ -n "$2" ]
then
LANG=C perl -ne 'print "$1 '$ID' $2\n" if m,^//CALL (ingress|query) (.*),;print "upgrade '$ID' '"$1"' 0x\n" if m,^//CALL upgrade,; ' $2
fi
) | drun -c "$CONFIG" --extra-batches $EXTRA_BATCHES /dev/stdin
) | drun --cycles-used-file /dev/fd/222 /dev/stdin
fi
6 changes: 0 additions & 6 deletions test/drun.json5

This file was deleted.

2 changes: 1 addition & 1 deletion test/profile-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ for file in perf/*.mo; do
wasm-profiler-instrument --ic-system-api -i "_profile_build/$base.wasm" -o "_profile_build/$base.instrumented.wasm"

# qr.mo takes far too long with profiling instrumentation, so limit runtime
timeout 20s ./drun-wrapper.sh "_profile_build/$base.instrumented.wasm" "$file" |&
timeout 20s ./drun-wrapper.sh "_profile_build/$base.instrumented.wasm" "$file" 222>/dev/null |&
wasm-profiler-postproc flamegraph "_profile_build/$base.instrumented.wasm" \
> "_profile_build/$base.flamegraph"

Expand Down
9 changes: 5 additions & 4 deletions test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -395,20 +395,21 @@ do
if [ $DTESTS = yes ]
then
if [ $HAVE_drun = yes ]; then
run_if wasm drun-run $WRAP_drun $out/$base.wasm $mangled
run_if wasm drun-run $WRAP_drun $out/$base.wasm $mangled 222>/dev/null
fi
if [ $HAVE_ic_ref_run = yes ]; then
run_if ref.wasm ic-ref-run $WRAP_ic_ref_run $out/$base.ref.wasm $mangled
fi
elif [ $PERF = yes ]
then
if [ $HAVE_drun = yes ]; then
run_if wasm drun-run $WRAP_drun $out/$base.wasm $mangled 222> $out/$base.metrics
run_if wasm drun-run $WRAP_drun $out/$base.wasm $mangled 222>$out/$base.metrics
if [ -e $out/$base.metrics -a -n "$PERF_OUT" ]
then
LANG=C perl -ne "print \"gas/$base;\$1\n\" if /^scheduler_(?:cycles|instructions)_consumed_per_round_sum (\\d+)\$/" $out/$base.metrics >> $PERF_OUT;
CYCLES_USED="$(awk -F':' '{sum+=$2;} END {print sum;}' $out/$base.metrics)";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line depends on awk being available as a dependency.

echo "gas/$base;$CYCLES_USED" >> $PERF_OUT;
fi
run_if opt.wasm drun-run-opt $WRAP_drun $out/$base.opt.wasm $mangled
run_if opt.wasm drun-run-opt $WRAP_drun $out/$base.opt.wasm $mangled 222>/dev/null
fi
else
run_if wasm wasm-run wasmtime run $WASMTIME_OPTIONS $out/$base.wasm
Expand Down
Loading