-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Mitigate #2924 #3076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mitigate #2924 #3076
Conversation
To make the stack shorter we implement foldRightBN with a foldLeftBN which allocates only half of the closures. By doing so we need to eagerly reverse the list which is in most cases small or empty.
test performance please |
performance test scheduled: 1 job(s) in queue. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/3076 to see the changes. Benchmarks is based on merge(s) with master |
case x :: xs1 => fold(xs1, op(x, acc)) | ||
case Nil => acc | ||
} | ||
fold(xs, acc) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
final def foldLeftBN[U](acc: => U)(op: (=> U, T) => U): U = {
...
case x :: xs1 => fold(xs1, op(acc, x))
That's what I meant by "accumulator is the first arg of the closure"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is right, but if I do that the op
must be put in another closure to reverse the parameter order.
I will make fold
an inner method of foldRightBN
and avoid this altogether.
test performance please |
performance test scheduled: 1 job(s) in queue. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/3076 to see the changes. Benchmarks is based on merge(s) with master |
While executing
|
LGTM |
@allanrenucci I was going to write on my review that we may need an extra test case. :-) Yesterday, we discussed with @nicolasstucki, that maybe an extra test would be needed to stress test this, but if it unblocks the CI then it is ok. |
@biboudis This does not solve the core issue but mitigates it. @nicolasstucki will try to solve the core issue. We can include the test case in the next PR. I merged this one to unblock some CI builds. |
👍 👍 |
To make the stack shorter we implement foldRightBN with
a foldLeftBN which allocates only half of the closures.
By doing so we need to eagerly reverse the list which is
in most cases small or empty.