Repository navigation
Change DataInfo._parent to a weakref - #6277
Conversation
|
This looks OK, though I'm still a bit confused by this; I thought simple reference cycles like col <-> info were found easily. Is it the column that is the problem, or the table? |
|
@mhvk - the problem does not appear for just an isolated Column, only when it is within a Table. I am with you in not fully understanding this, but the fix clearly works... |
|
I'm trying to investigate a bit more. Just wondering where the |
|
I think I found it: it seems |
|
Actually, what I found only ensures that Am still wondering if it wouldn't be possible to do without the |
You need to store the instance somewhere (for other methods to use) in a way that is uniquely associated with the instance. There are other strategies, e.g. in a dict that is hashed by |
4c3c677 to
5d23a81
Compare
|
Rebased. |
|
I think you really only need to store |
|
@mhvk - it would be good to get this (or an alternate) merged today, the plan is to cut the RC tomorrow (morning in Europe). Any thoughts? |
|
Oops didn't see your alternate PR earlier. Will look. |
|
I've tried my alternative further and I think it ends up being rather fragile; indeed, I'll close it as I think it is not going in the right way, and I don't have time to experiment further. |
|
Hmm, I'm getting less happy with my version now too... Originally I thought it was just for something that requires the parent. It isn't obvious that this would be a common thing to do, but still it is a bit annoying. |
|
Yes, that is annoying... Maybe, we need something in between the two approaches, where |
|
p.s. But just to be sure: I think this is still an improvement over being able to run out of memory with relatively trivial table operations! |
5d23a81 to
433e080
Compare
|
Well I have improved this version somewhat, so there is no internal API change (made Maybe that's enough for now and we can always come back to it. We can rightly say that the lost parent situation is a bug and fix later. And I just didn't want to use the technically-correct term "dead" parent here. It's just lost... |
mhvk
left a comment
There was a problem hiding this comment.
I like your addition - this way the API change is minimized, and we can also more easily change it to another procedure if we can find something better. So, 👍 on merging this.
|
I've added the |
Add test of lost parent exception. Reviving astropy#6277 that was merged but then reverted.
Reviving #6277 that was merged but then reverted
|
Will this be backported to 2.x? I think this is the cause of astropy/halotools#917 What troubles me is the memory management is not deterministic without this patch. Here is the output of objgraph in a loop that overwrites a table repeatedly: And a portion of the reference graph that shows the problem: |
|
@rainwoodman , this was milestoned for 2.0.0, so technically it should already be in 2.x. |
|
I commented on the wrong ticket. I meant the reinstating of the patch -- I suppose this was never reverted in 2.x then? Indeed it wasn't. Sorry for the noise. |
|
Indeed, #7448 hasn't been backported yet, but planned to be included in 2.0.8. @astrofrog @eteq - shall we just create an "invalid" or similar milestone that reverted PRs like this and #6342 can go into? |
Reviving #6277 that was merged but then reverted
Reviving #6277 that was merged but then reverted
|
@rainwoodman - I'm sorry, the decision was at the end to not include this in the LTS branch given the API change. |
|
@rainwoodman - to add a bit more here: is there a specific reason this was important for the LTS vs 3.0.x/master? Here we're in the awkward position of it being both a bug and an API change required... which we try to avoid wherever possible on LTS'. but if there's a specific compelling reason/use case for it to go back to the LTS that could be reconsidered for 2.0.9 ... |
|
There doesn't seem to be any API breakage by looking at this patch. There is a _parent attribute before and after the change. Only in already undefined situations, accessing _parent attribute may fail after this change. Also, _parent is private anyways. |
|
The API break is quite obscure, but previously |
|
Look like there is no easy fix then. Is this also a problem in astropy3? Looks like this DataInfo is a blend of two interfaces -- storing the attributes and deriving properties of the column. The derived property interface requires a reference from info to parent. The storing interface requires a refrence from parent to info. If they are split then there is no longer a need for cyclic reference. The storing interface could have been merged into the column itself or as something fancier, but it doesn't need to know the parent. The interface for derived properties can be done by always creating a new instance from the parent object upon access, as it doesn't involve storing anything the creation is fast enough -- one can still provide access to the stored attributes here to maintain compatibility, I think. |
Add test of lost parent exception. Reviving astropy#6277 that was merged but then reverted.

Fixes #6276
Validation testing was to do the following and confirm that memory did not blow up:
Also did the following (from #6253 (comment)) and confirmed no memory leak: