Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/shell-bisector'
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |