-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Make groupoids garbage collectable #12357
Comments
comment:1
I did not run the full test suite yet. It could be that some silly old doctests use the groupoids in a way they are not intended, such as |
comment:2
To my surprise, there were no nasty old doctests. Hence, |
comment:3
Concerning timings: Without the patch, the groupoid of P is stored in a dictionary, indexed by P. Hence, access to the cache is slow if Some data points:
But with the patch, it is stored as an attribute of P. Hence, it is slow if attribute access is slow. The point is that even slow attribute access is faster than slow hash, and slow attribute access is only little slower than fast hash:
Hence, I believe that the patch is not only fixing a memory leak, but has the potential to generate a speed-up. |
Changed keywords from none to groupoid cache Cernay2012 |
Work Issues: tests for None? |
comment:4
This is the simplest patch of the cache problems suite, and it does not depend on !#715, so I begin with this one. I'm a little bit confused by all those tests for None in your patch. Isn't the first one sufficient? More specifically, the second test "if S is not None" isn't superfluous ? And if it is not None, can G be None ? (I guess there is some cython voodoo involved here) To answer my own question, I guess it is none if S is not a Parent (as in your example with 1). Once you answer me back, I'll post a reviewer patch with some additional minor corrections. |
comment:5
Yes, the test "if S is not None" in line 103 seems redundant, as S being None would result in an error being raised in line 92. Concerning Cython voodoo: If S is not None and not of type Parent, then |
Changed work issues from tests for None? to none |
Reviewer patch |
comment:7
Attachment: trac12357_reviewer.patch.gz The reviewer patch looks fine to me. Thank you! |
comment:9
Moving this to sage-pending for now since it depends on two non-positively reviewed tickets. |
comment:10
There is a conflict with #11943.
Therefore, I suggest to rebase my patch with respect to #11943. |
Work Issues: rebase rel #11943 |
comment:20
Unfortunalely, this regularly (not always but quite often) gives Segmentation Faults in
This is with sage-5.1.beta4 + #12357 (beta4 is not yet released, but essentially finished). |
comment:22
Patchbot, apply trac12357_internal_strong_groupoid_cache.patch attachment: trac12357_reviewer.patch |
comment:23
I got one doctest error, which unfortunately shows that the patch does not solve the problem it was created for:
Hence, some garbage that was supposed to get collected did not become collected. And there also seems to be a timeout in
|
comment:24
In fact, the polynomial ring in the failing example does not become collected, even without creating its groupoid. I thought that this would have been fixed in one of the dependencies?
|
comment:25
Perhaps I should use a test that avoids polynomial rings, but uses a custom
What do you think? By the way, the timeout is no problem: I had closed my laptop during the tests. Hence, the tests were interrupted, but the time was running. |
comment:26
PS: In unpatched sage-5.6.rc0, one would obtain
And this is even without using a cache for P!! Hence, the tests does demonstrate that some leak was fixed. |
comment:27
Apart from changing the test, I'd like to change something more. Namely, it is stated that The main idea of storing the groupoid of P as an attribute of P is to avoid creating an external strong reference on the groupoid. But that would not be the case, when using a weak_cached_function for caching. Hence, it could actually be that #12215 already fixes what is attempted here! I'll test that. |
comment:28
Indeed. With just #12215 and #12313 on top of sage-5.6.rc0, one obtains:
Hence, I suggest to resolve this as a duplicate. Jean-Pierre, please change if you disagree. |
Changed reviewer from Jean-Pierre Flori to Simon King, Jean-Pierre Flori |
This comment has been minimized.
This comment has been minimized.
Changed author from Simon King to none |
Currently, the groupoid of an object P can not be garbage collected, even when deleting P.
Even worse: The persistence of
Groupoid(P)
also prevents P from being garbage collected.The attached patch aims at solving it: An external reference to either P or
Groupoid(P)
is enough to keep both alive. But without an external reference, both P andGroupoid(P)
become collectable.Example from the docs:
Superseded by #12313.
Depends on #715
Depends on #11521
Depends on #12313
Depends on #11943
CC: @nthiery @jpflori
Component: memleak
Keywords: groupoid cache Cernay2012
Reviewer: Simon King, Jean-Pierre Flori
Issue created by migration from https://trac.sagemath.org/ticket/12357
The text was updated successfully, but these errors were encountered: