Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/shell-bisector'
Browse files Browse the repository at this point in the history
  • Loading branch information
cleverca22 committed Oct 13, 2021
2 parents eb37b3f + 55ab142 commit 3d9c644
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions membench-bisect
@@ -0,0 +1,42 @@
#!/bin/sh

set -xeu

precision=${1:-25000}
start_fail=${2:-6000000}
start_pass=${3:-16000000}

iteration=0
while true
do if test -f 'membench-last-fail.json'
then last_fail=$(jq '.memLimit' 'membench-last-fail.json')
else last_fail=$start_fail; fi

if test -f 'membench-last-pass.json'
then last_pass=$(jq '.memLimit' 'membench-last-pass.json')
else last_pass=$start_pass; fi

outcome_gap=$(($last_pass - $last_fail))
echo "membench: pass/fail outcome gap: $outcome_gap"
if test $outcome_gap -le $precision
then echo "membench: outcome gap below precision $precision, terminating"; exit 0
else echo "membench: outcome gap above precision $precision, next iteration"; fi

nextLimit=$((($last_fail + $last_pass) / 2))

echo "{ memLimit: $nextLimit }" > 'membench-limit.json'
time nix build '.#membench' -L --out-link 'membench-last'
# nix-store -r $(readlink ./result) --add-root 'membench-last' --indirect

lastResult=$(jq .failed 'result/refined.json')
if [ x$lastResult = xfalse ]
then outcome=pass
else outcome=fail; fi

cp -f 'membench-last/refined.json' 'membench-last-'$outcome'.json'
rm -f 'membench-last-'$outcome; mv 'membench-last' 'membench-last-'$outcome

echo "--------------------------------- iteration $iteration boundaries:"
jq . 'membench-last-fail.json'
jq . 'membench-last-pass.json'
done

0 comments on commit 3d9c644

Please sign in to comment.