-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a stack safety stress test for Eval. (#1888)
* Add a stack safety stress test for Eval. The basic idea is to create very deep chains of operations to try to expose any stack problems. We know that for things like map/flatMap Eval seems to work, so let's just randomly construct deeply-nested Eval expressions to see what happens. This test exposed a weakness with .memoize which is fixed. As part of this commit, I noticed that our Arbitrary[Eval[A]] instances were somewhat weak, so I upgraded them. * Reduce depth to get Travis passing. * Better memoization support for flatMap. This fix was proposed by @johnynek and fixes a bug I introduced with how memoization was handled during flatMap evaluation. Our old implementation did memoize intermediate values correctly (which meant that three different evals mapped from the same source shared a memoized value). However, it was not stack-safe. My fix introduced stack-safety but broke this intermediate memoization. The new approach uses a new node (Eval.Memoize) which can be mutably-updated (much like Later). It's confirmed to be stack-safe and to handle intermediate values correctly. While it was unlikely that anyone was doing enough intermediate memoization to cause actual stack overflows, it's nice to know that this is now impossible. * Rename Compute to FlatMap and Call to Defer.
- Loading branch information
Showing
3 changed files
with
213 additions
and
59 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
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
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