-
Notifications
You must be signed in to change notification settings - Fork 230
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
Fix for #2954 and alternative way to give values to memoized function #2955
Conversation
Would it make things any simpler if |
yeah that's another option, I've been thinking about it. I see nothing wrong with it (in fact, I'm experimenting with something like this for mode-dependent functions like
I don't know what others' opinions are... |
Like I said on Zulip, I wish I also pointed out that one problem of the |
I don't understand your comment on |
Sorry, I got confused. I meant this non-garbage collected hash table in values := new MutableHashTable;
How do you propose debugging the situation that I described above? It's pretty much impossible to use search/grep/regex to find this. If you have a suggestion you should add that to the documentation as well. |
maybe I don't understand how garbage collecting works in M2. in the stupid example
why wouldn't |
The trouble is that the memoized function is itself almost never removed. Suppose you have a memoized function |
OK, there are cases when |
incidentally I notice two strategies for accessing the closure of a function: either using |
Also I would like to hear others' thoughts on @d-torrance 's suggestion to introduce say |
I've been thinking about the pros and cons of |
There are no non-garbage-collected places. |
What happens if you run this code? f = memoize(n -> koszul vars(QQ[x_1..x_5]))
scan(10000, f) The output is null, but the rings, modules, and complexes, are not garbage collected. |
Here's a more realistic example: mbasis = memoize basis
hilb = (n, d) -> numcols mbasis(d, QQ(monoid[vars(1..n)]))
apply(100, hilb_5) You can watch To be clear, |
You're not wrong, but like in my example above, this is too easy to abuse if it were used in Core. My preferred solution for this would be having an extra f = memoize(n -> (...))
ctx = new MutableHashTable
f(10, Context => ctx) In fact, the context object can be the parent ring, so that when the ring goes out of scope (and hence also the module), so does the cached data. |
for the record, this whole discussion is not directly related to the PR, which does not change the way |
Agreed. I'm not objecting to this PR. I do like the added features, and would use them personally.
The specific reason I prefer avoiding using the M2/M2/Macaulay2/m2/pushforward.m2 Lines 138 to 139 in 86d6c70
I think @mikestillman also mentioned that it's really difficult to debug issues with this kind of caching, so I'm curious if you have ideals for how to improve debugging tools. |
I do want to think about this debugging issue some more. |
Could you rebase on top of |
what's the exact rebase command that's needed? so I don't spend too much time on this... |
BTW the only reason I'm doing all these pulls, as you probably guessed, is that the build keeps failing for reasons that are most likely unrelated to the PR itself. |
thanks, done. and now I'm really confused, thought the builds had always failed... |
initialValues
from thecodeHelper
since they appear in the list of symbols anyway.