Skip to content

Instantly share code, notes, and snippets.

@arthurp
Last active December 14, 2018 04:18
Show Gist options
  • Save arthurp/85482e7768df3717bc2847f0f10e6f39 to your computer and use it in GitHub Desktop.
Save arthurp/85482e7768df3717bc2847f0f10e6f39 to your computer and use it in GitHub Desktop.
Orc Issue #223 status
function opts {
(cat <<EOF
porc:eta-spawn-reduce
porc:try-catch-elim
porc:try-finally-elim
porc:tail-spawn-elim
porc:inline-spawn
EOF
) | sort
}
function select_lines() {
N=$1
cmd="$(python3 -c "for i in range(10): print(str(i+1) + 'p;' if $N & (2**i) != 0 else '', end='')")"
sed -n "$cmd"
}
ORC_ARGS=""
function run() {
N=$(cat /tmp/number || echo 0)
echo $[ $N+1 ] > /tmp/number
OUT="$HOME/tmp/out-$N"
mkdir $OUT
echo "Starting into $OUT"
BOOTCP="-Xbootclasspath:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/resources.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/rt.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/jsse.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/jce.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/charsets.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/jfr.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/jvmci-services.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/boot/graaljs-scriptengine.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/boot/graal-sdk.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/boot/graal-sdk.src.zip:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/truffle/truffle-api.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/jvmci/graal.jar:/home/amp/LocalInstalls/eclipse/plugins/org.scala-lang.scala-library_2.12.3.v20170725-052526-VFINAL-6ac6da8.jar:/home/amp/LocalInstalls/eclipse/plugins/org.scala-lang.scala-reflect_2.12.3.v20170725-052526-VFINAL-6ac6da8.jar"
CP="-classpath /home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/resources.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/rt.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/jsse.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/jce.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/charsets.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/jfr.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/jvmci-services.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/boot/graaljs-scriptengine.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/boot/graal-sdk.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/boot/graal-sdk.src.zip:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/truffle/truffle-api.jar:/home/amp/graalvm/graalvm-ee-1.0.0-rc7/jre/lib/jvmci/graal.jar:/home/amp/LocalInstalls/eclipse/plugins/org.scala-lang.scala-library_2.12.3.v20170725-052526-VFINAL-6ac6da8.jar:/home/amp/LocalInstalls/eclipse/plugins/org.scala-lang.scala-reflect_2.12.3.v20170725-052526-VFINAL-6ac6da8.jar:/home/amp/shared/orc/OrcScala/lib/scala-parser-combinators_2.12-1.0.6.jar:/home/amp/shared/orc/OrcScala/lib/scala-xml_2.12-1.0.6.jar:/home/amp/shared/orc/OrcScala/lib/swivel_2.12-0.0.2.jar:/home/amp/shared/orc/OrcScala/build/classes:/home/amp/shared/orc/PorcE/build/classes:/home/amp/shared/orc/OrcTests/build:/home/amp/shared/orc/OrcSites/build/classes"
taskset -c 1 /home/amp/graalvm/graalvm-ee-1.0.0-rc7/bin/java \
-XX:-UseJVMCIClassLoader -Xmx2G -Xss8M \
-Djava.util.logging.config.file=config/logging.properties -Dorc.config.dirs=config \
-Dorc.SimpleWorkStealingScheduler.overrideWorkers=2 \
-Dorc.ast.generateUniqueVariableNames=true \
-Dorc.executionlog.dir=$OUT -Dfile.encoding=UTF-8 $BOOTCP $CP \
orc.Main --backend=porc-distrib -O 3 --echo-ir 0x1000 --noprelude --java-stack-trace \
$ORC_ARGS \
/home/amp/shared/orc/OrcTests/test_data/functional_valid/porce-opt3-hang.orc > $OUT/log 2>&1 &
P=$!
sleep 2
tail -f $OUT/log | while read L; do
# echo $L
case "$L" in
DOrcLeaderExecution:)
kill $P
echo "Failure ${PREFIX}fail-$N"
mv $OUT "$HOME/tmp/${PREFIX}fail-$N"
return 1
;;
*Closed*)
echo "Success ${PREFIX}success-$N"
mv $OUT "$HOME/tmp/${PREFIX}success-$N"
return 0
;;
esac
done
}
function measure() {
SUCCESSES=0
for i in $(seq $TRIES); do
run && SUCCESSES=$[$SUCCESSES+1]
echo "$SUCCESSES / $i ($(python3 -c "print($SUCCESSES / $i * 100)")%)"
done
}
COMBINATIONS=$((2**$(opts | wc --lines)))
TRIES=6
echo Attempting $COMBINATIONS
for i in $(seq 0 $(($COMBINATIONS - 1))); do
opts | select_lines $i | sed 's/porc://' | paste -s -d" "
OPTS=$((
opts | select_lines $i | sed 's/$/=true/'
opts | select_lines $((~$i)) | sed 's/$/=false/'
) | sort | paste -s -d,
)
ORC_ARGS="--opt-opt $OPTS"
PREFIX="$i"
echo $OPTS > "$HOME/tmp/${PREFIX}.opts"
measure
done
{- "-O 3" bug input. Hangs at "-O 3", but runs at "-O 2" and below.
- Works with "--backend=porc" but not "--backend=porc-distrib".
- Hangs even with "--follower-count=0", i.e. no intercepted calls,
- no terminator proxies, only 1 distrib counter, no msg sends.
-}
import site Ift = "orc.lib.builtin.Ift"
import site Iff = "orc.lib.builtin.Iff"
import site (+) = "orc.lib.math.Add"
import site (-) = "orc.lib.math.Sub"
import site (0-) = "orc.lib.math.UMinus"
import site (*) = "orc.lib.math.Mult"
import site (/) = "orc.lib.math.Div"
import site (<:) = "orc.lib.comp.Less"
import site (<=) = "orc.lib.comp.Leq"
import site (:>) = "orc.lib.comp.Greater"
import site (>=) = "orc.lib.comp.Greq"
import site (=) = "orc.lib.builtin.Eq"
import site Print = "orc.lib.str.Print"
import site Random = "orc.lib.util.Random"
import site URandom = "orc.lib.util.URandom"
import site Channel = "orc.lib.state.Channel"
import site Sequentialize__ = "orc.compile.orctimizer.Sequentialize"
def max(x,y) = if x :> y then x else y
def forBy(low, high, step) = step >>
max((high - low) / step / 1024, 2) * step >seqSize> (
def parPhase(low, high) = low >> high >> (
val diff = high - low
if diff <= 0 then
stop
else if diff <= seqSize then
seqPhase(low, high)
else
low + (diff / 2 / step) * step >split>
( parPhase(low, split) | parPhase(split, high) )
)
def seqPhase(low, high) = Sequentialize__() >> low >> high >> (
if low >= high then stop
else ( low | low+step >x> seqPhase(x, high) )
)
low >> high >> parPhase(low, high)
)
def for(low, high) = forBy(low, high, 1)
def upto(high) = for(0, high)
def collect(p) =
val b = Channel()
p() >x> b.put(x) >> stop
; b.getAll()
-- These are just two JRE classes picked at random
import class Collections = "java.util.Collections"
import class Date = "java.util.Date"
def randomEdges(head, randomWeight) =
collect({
Print("Starting collect\n") >>
upto(1200) >vn> (
Ift(URandom() <: 1.0) >> Date(head, vn, randomWeight())
)
}) >r> Print("randomEdges publishing\n") >> r
def randomGraph'(vn) =
if vn <: 1 then
Collections.nCopies(vn, randomEdges(vn, { Random(40) + 1 })) >>
randomGraph'(vn + 1)
else
signal
randomGraph'(0) --| Prompt("Press Enter to kill") |}
{-
OUTPUT:
Starting collect
[hangs]
-}
-- Core i7 3720QM (2.6Ghz)
{- "-O 3" bug input. Hangs at "-O 3", but runs at "-O 2" and below.
- Works with "--backend=porc" but not "--backend=porc-distrib".
- Hangs even with "--follower-count=0", i.e. no intercepted calls,
- no terminator proxies, only 1 distrib counter, no msg sends.
-}
import site Ift = "orc.lib.builtin.Ift"
import site Iff = "orc.lib.builtin.Iff"
import site (+) = "orc.lib.math.Add"
import site (-) = "orc.lib.math.Sub"
import site (0-) = "orc.lib.math.UMinus"
import site (*) = "orc.lib.math.Mult"
import site (/) = "orc.lib.math.Div"
import site (<:) = "orc.lib.comp.Less"
import site (<=) = "orc.lib.comp.Leq"
import site (:>) = "orc.lib.comp.Greater"
import site (>=) = "orc.lib.comp.Greq"
import site (=) = "orc.lib.builtin.Eq"
import site Print = "orc.lib.str.Print"
import site Random = "orc.lib.util.Random"
import site URandom = "orc.lib.util.URandom"
import site Channel = "orc.lib.state.Channel"
import site Sequentialize__ = "orc.compile.orctimizer.Sequentialize"
def forBy(low, high, step) = Sequentialize__() >> (
if low >= high then stop
else ( low | forBy(low+step, high, step) ))
def collect(p) =
val b = Channel()
Sequentialize__() >> p() >x> b.put(x) >> stop
; b.getAll()
-- These are just two JRE classes picked at random
import class Collections = "java.util.Collections"
import class Date = "java.util.Date"
def randomEdges(head, randomWeight) =
collect({
Sequentialize__() >>
Print("Starting collect\n") >>
forBy(0, 6, 1) >vn> (
Ift(URandom() <: 1.0) >> Date(head, vn, randomWeight())
)
}) >r> Print("randomEdges publishing\n") >> r
{-
Collections.nCopies(0, randomEdges(0, { Random(40) + 1 })) |
upto(1)
-}
def randomGraph'(vn) =
if vn <: 1 then
--Sequentialize__() >>
Collections.nCopies(vn, randomEdges(vn, { Random(40) + 1 })) >>
randomGraph'(vn + 1)
else
signal
randomGraph'(0) --| Prompt("Press Enter to kill") |}
{-
OUTPUT:
Starting collect
[hangs]
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment