bionic
bionic copied to clipboard
Uncached values should be recomputed each time they're used
Currently, when an entity has both persistence and memoization disabled, we store its value in memory for the duration the Flow.get() call (as documented here). I think we should change this behavior: instead of storing it in memory, we should recompute the value each time it's used.
I believe the current behavior was chosen because it was easier to implement. However, it seems more intuitive to me that if memoization is disabled, then we don't store the value in memory any longer than necessary. This also matches the intuition of data scientists I've spoken with. (If you're at Square, you can search Slack for the string "it sounds like everyone here would prefer to have it recompute".) Finally, it's slightly confusing that turning off persistence will change the amount of memoization.
This would be a breaking change. Although I doubt many users depend on the current behavior, we should make sure to check in with users before finalizing the change.
This PR has a concrete example. In this test case, x is non-memoized and non-persisted and is used by two other entities (x_squared and y_x_cubed). With the current behavior, we store its value in memory until the get call is finished, so x is only computed once per call. After this change, x would be computed twice.