-
Notifications
You must be signed in to change notification settings - Fork 4
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 runtime crash #4
Conversation
/cc @danderson |
0e6ea44
to
ce9b376
Compare
PTAL @josharian @danderson |
Fixes #2
ce9b376
to
bd0b7d5
Compare
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.
Based on my understanding of what the issue was previously, this fix LGTM.
Cool. Will submit. @josharian can school us if we're wrong. 😂 |
I've been pondering this intermittently. I don't understand the handling of refs. It's not actual refcounting. It seems to me e.g. that the finalizer could set refs = 1 before setting a new finalizer, which could speed up things considerably. Is a bool enough? |
Yeah, while writing docstrings explaining this interplay, I realized that this is not actually refcounting, but something akin to mark-and-sweep. As currently written, the weakref will need one GC cycle per call to Get before the interned value is actually deleted. So, it does still save memory, but the freeing schedule is unpredictable. I think Josh is right that in the "re-set finalizer" case, we can set refs=1 to speed things up. In that case, a dangling Value will get collected at most 3 GC cycles after its last reference was dropped. I'll send a patch for same alongside the docstrings explaining this. I welcome a bikeshed for a new name for |
Yeah, that's a good idea.
Empirically, yes. PR coming. |
Per discussion in go4org#4. Signed-off-by: David Anderson <dave@natulte.net>
Fixes #2