-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add dev docs on caching parent objects #3619
Conversation
I just discovered some notes on caching at https://nemocas.github.io/AbstractAlgebra.jl/dev/ring_interface/#Parent-object-caches -- perhaps some of that should also be included or referenced here (and/or perhaps the text there should be updated). I'll wait to hear what @fieker thinks. |
For interactive use, it is often simply convenient: e.g. taking the characteristic | ||
polynomials of two matrices and multiplying them, without worrying about specifying | ||
the parent rings of the polynomials. |
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.
Funnily enough, exactly this example doesn't work because caching is deliberately turned off:
julia> M = QQ[1 0; 0 1];
julia> charpoly(M)*charpoly(M)
ERROR: Incompatible polynomial rings in polynomial operation
[...]
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.
Ouch! Thank you very much for fact checking this.
That makes me question the point of entire caching thing even more sigh.
So, does anyone then have a not completely unconvincing example for a situation where a cached parent helps a "naive" user?
Caching parents also has downsides. E.g. all those cached objects take up memory which | ||
in some cases can add up to significant amounts. |
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.
Tommy also mentioned issues with parallelization/thread safety as a (possible) downside to me.
(And I don't really understand how the memory could fill up if we use these WeakValueDict
s? But that's more for my curiosity.)
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.
Unfortunately not all our caches actually use WeakValueDict
. We introduced it much later and e.g. Hecke still uses Dict and IdDict caches quite a bit (I just grepped for get_cached!
to find examples for caches and then checked their definitions). Might be a good idea for somebody to clean that up.
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.
I hope that I got all caching dictionaries which weren't WeakValueDict
s in Nemocas/Nemo.jl#1724 and thofma/Hecke.jl#1460.
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.
This matches what I was told over the past years. It's good to have a 'reference' now.
Maybe add |
|
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.
it moves into the right direction.
61a7732
to
693c0e6
Compare
Following the discussions last Friday and again this Wednesday, where Claus explained the caching rules as they were so far; I've now tried to codify them here, for future reference or revision. In particular, what I describe here is not meant to be something new, but reflect what was the policy *so far*. [skip ci] Co-authored-by: Johannes Schmitt <jschmitt@posteo.eu> Co-authored-by: Lars Göttgens <lars.goettgens@gmail.com> Co-authored-by: Tommy Hofmann <thofma@gmail.com>
693c0e6
to
cb338d4
Compare
Thanks @thofma I've added your nice example. BTW I find it quite disheartening that I get this on my M1 MacBook the first time I execute
|
Following the discussions last Friday and again this Wednesday, where Claus explained the caching rules as they were so far; I've now tried to codify them here, for future reference or revision. In particular, what I describe here is not meant to be something new, but reflect what was the policy so far.
I am sure I forgot stuff or maybe even misrepresented something, so please let the feedback flow in.
Resolves #3616