-
-
Notifications
You must be signed in to change notification settings - Fork 16
What's the cache for? #2
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
Comments
You hit the nail on the head. If we do something like I've generally not expected that functors would need to be all that fast (though they certainly could all be inlined away, if not for this caching bit). Is there a particular need or were you just curious? It may be possible to optimise it away in some cases. We could get rid of this behaviour entirely; there are much better ways to get weight sharing and we're moving to a more functional worldview anyway, so enforcing that the above example gets viewed as a tree wouldn't be all that bad. |
I think I agree that it's unlikely to be a bottleneck in my code either at the minute. There are some slightly niche Bayesian numerics applications that I've had my eye on for a while where this overhead might become significant, but they're a way down the line. Again, this was more out of curiosity. Might be nice to add some comments / developer docs explaining this. |
Resolved by #4 |
Uh oh!
There was an error while loading. Please reload this page.
I was very pleased to discover that this is a thing that's been carved out from Flux, but was slightly surprised by the following performance:
Digging down a little,
functor
seems to be performant:👍
Similarly,
isleaf
seems to be fine:👍
So there's something else going on in
fmap
andfmap1
that I assume has something to do with theIdDict
that's being used. So, I would be interested to know a) what the need for the cache is (it's kind of un-obvious to me) and b) whether there's a way to get rid of all of this overhead as it seems kind of unnecessary in this simple case?edit: I realised while out on a walk that it's probably something to do with diamonds in the dependency graph for any particular data structure. Is this the case?
The text was updated successfully, but these errors were encountered: