printTime
"Mutate an IO.Ref 1000 times" 650 (n ->
repeat n do
r = IO.ref 0
repeat 1000 do Ref.write r (Ref.read r + 1))
Old:
Mutate an IO.Ref 1000 times
675.29µs
New
Mutate an IO.Ref 1000 times
659.252µs
So, a difference of 675.29µs - 659.252µs = 16.038µs, and (16.038µs / 1000 repetitions) / 2 calls = 8.019ns per foreign call
Implementation notes
Implements Ref.read/Ref.write as instructions. Can also do Ref.cas/Ref.readForCas if it seems worthwhile.
Interesting/controversial decisions
This seems like a pretty minor optimization, we need to be careful about doing too many of these as well because each one increases the code-size of our critical path.
Overview
Benchmark:
Old:
New
So, a difference of
675.29µs - 659.252µs = 16.038µs
, and(16.038µs / 1000 repetitions) / 2 calls = 8.019ns per foreign call
Implementation notes
Implements Ref.read/Ref.write as instructions. Can also do Ref.cas/Ref.readForCas if it seems worthwhile.
Interesting/controversial decisions
This seems like a pretty minor optimization, we need to be careful about doing too many of these as well because each one increases the code-size of our critical path.