https://kotlinlang.org logo
#arrow-contributors
Title
# arrow-contributors
p

PhBastiani

01/30/2020, 12:22 PM
Hi, I prepared a PR with additional tests for the Free package; and, I added a new benchmarking project for the trampoline part... Interesting: for calculations of the Fibonacci sequence, there is approximately 30% difference between the Trampoline/Eval approaches.
👏 1
Note : I will push this PR as soon as one of my proxies will be available 😡
p

pakoito

01/30/2020, 1:41 PM
30% improvement? wow!
p

PhBastiani

01/30/2020, 1:46 PM
30% in favour of Eval... I only added some additional tests.
j

Jannis

01/30/2020, 1:50 PM
Does your benchmark rerun the computation with the same
Eval
multiple times? Because
Eval
memoizes results in some cases
I actually use that quite heavily in my prettyprinter because the same lazy structure gets traversed over and over again
p

PhBastiani

01/30/2020, 1:59 PM
yep, you're right... I think that jmh reuses the same resource
j

Jannis

01/30/2020, 2:03 PM
You can set an isolation level per invocation afaik
p

PhBastiani

01/30/2020, 2:14 PM
I used Scope.Thread as isolation... I think that I can play with the Setup annotation... I will check again
r

raulraja

01/31/2020, 7:19 PM
We need to investigate what we can do at a compiler plugin level to support trampolining automatically without building up data structures
j

Jannis

01/31/2020, 8:07 PM
This leads into control flow analysis and predicting stack depth, which is really hard. Unless you trampoline everything, which may or may not hurt performance, but that's worth testing.
I think looking at the leanest structure possible is important. And between
AndThen
,
Eval
,
Trampoline
and
IO
I think that may be
AndThen
because it fuses function calls.
AndThen
however will still cause overflows if it is invoked at depth.
Eval
and
Trampoline
both trampoline everything and thus don't need this.
IO
is usually invoked at the edge and hence can fuse function calls freely because of that.
@PhBastiani can you try
AndThen
in your tests as well? Would be interested in the outcome ^^
3 Views