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
bad memory leak with exponentiation #4639
Comments
comment:1
This is indeed a grave bug. Cheers, Michael |
comment:2
Hmm, Burcin and I have been looking at code he has been writing and there seems to be a caching issue with the coercion system. Now, I don't want to outright blame coercion here without any hard evidence, but the timing (3.0.2 to now) suggests that it could be involved here. So let's add robertwb to the CC and see if he can come up with anything. I will collect some evidence and hopefully someone else will take over. Cheers, Michael |
comment:3
Burcin about his code, not the problem reported here:
|
comment:4
Here is my leak:
|
comment:5
This ticket might also cause #4631. Cheers, Michael |
comment:7
Here's the bug:
|
comment:8
Hi Robert, do you want me to valgrind here or are you already on top of this? Cheers, Michael |
comment:9
I think I can dig further, this is just as far as I got last night. It's probably a caching, not malloc, issue. |
Attachment: 4639-coerce-leak.patch.gz this fixes the leak in coerce, not in exponentiation |
comment:10
Better caching for homsets fixes the leak for coercion. |
comment:13
The patch RobertWB posted does pass doctesting. Cheers, Michael |
comment:14
#4683 might be a dupe of this ticket. Cheers, Michael |
comment:15
I've read the patch and give it a positive review. But the patch doesn't resolve the ticket, as Robert points out. So after applying the patch, I guess you have to open a new ticket? Or??? Anyway -- don't just randomly close this ticket after applying the patch... |
comment:16
I have deleted the patch and moved it to its own ticket at #4740 since it does not fix the original problem reported. Cheers, Michael |
comment:17
An interesting test point:
Now this leaks
But this doesn't
The only difference here is Python vs. Cython (leaking in the Python case). |
comment:18
And running
It feels like something is getting cached in an exception. |
comment:19
I am almost sure the above is what's going wrong, and it gets invoked by call. guppy gives a total of 40420 bytes on these runs... and nothing new after repeated runs (despite get_memory_usage going up and up). However, the memory still goes up. Mabshoff, could you valgrind this and see if anything suspicious comes up? Perhaps up the loop to 100000, or diff the run from Python with that from Cython, to make it more clear where the error is... |
comment:20
Will do. Any news on the pickle failure for #4740? Cheers, Michael |
comment:21
This is a Cython error, not a coercion error. When something is returned from within a try block, it appears the (cached) exception is not released.
Now |
comment:22
Install cython-0.10.3.spkg at http://sage.math.washington.edu/home/robertwb/cython/ , which contains a fix to http://trac.cython.org/cython_trac/ticket/162 and I think is the underlying cause here (and probably elsewhere). |
comment:23
The new Cython.spkg reduces the leak significantly:
With:
But unfortunately it doesn't fix it completely:
Consequently I will split the Cython.spkg from this ticket. Cheers, Michael |
comment:24
For the record: The cython.spkg upgrade to 0.10.3 is #4798. Cheers, Michael |
comment:25
This is the bug that will never die... I'll keep looking at that last case. |
comment:26
If there ever was a blocker for 3.2.2 :) Cheers, Michael |
comment:27
Another data point. I took the example from #4683 (Michael, it was argued that #4683 is a duplicate).
Therefore it seems to me that the problem is not exponentiation but a failure in deallocation. |
comment:28
Attachment: 4639-parent-memleak.patch.gz I believe I have located and resolved the issue. After tracing through all kinds of coercion and homset code, and reading tons of Cython code looking for memory leaks, it turns out that this was caused by all Parents ever created being cached due to old debugging code. (Wow, wish I'd looked there first! :) Some old, unnecessary code has been removed from the generic |
comment:29
Nice! I am testing away at the moment :) Cheers, Michael |
comment:30
This does indeed fix the issue for me:
Doctesting now ... Cheers, Michael |
comment:31
Positive review for 4639-parent-memleak.patch - w00t Cheers, Michael |
comment:32
Merged in Sage 3.2.2.rc1 |
I think that the following example speaks for itself. (This was on an x86, 32 bit, running Ubuntu.)
Also, I believe that these examples had no problems in sage 3.0.2.
CC: @robertwb
Component: basic arithmetic
Issue created by migration from https://trac.sagemath.org/ticket/4639
The text was updated successfully, but these errors were encountered: