-
Notifications
You must be signed in to change notification settings - Fork 22k
Use weak references in descendants tracker #31442
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
Conversation
|
This isn't worth adding a dependency for. I thought the plan was to use WeakRef? |
|
The Using just I can also try to implement |
|
I'd like to try for something more like the array-of-weakref. As long as we're aware of threading concerns, we should be able to clean it out when adding new entries. That leaves a degenerate case where it doesn't shrink if no new descendants are being defined... but at that point the list isn't growing either. |
|
Sounds good enough, I will try that. |
21be478 to
84c057d
Compare
|
@matthewd I have updated the implementation to use Benchmarks:
Without the |
|
There is one case, where this will not work: In this example I think most people will not inherit an anonymous class from another anonymous class. |
be2813d to
b2d4118
Compare
|
Any update on this? |
|
Hello. I'm also interested in this fix since if I understand it well it allows you to safely use anonymous Is there anything I can help with? |
b2d4118 to
ea8f8ed
Compare
|
I have rebased this against master. @matthewd can you take a look at this? |
matthewd
left a comment
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.
Thanks for your patience, and sorry this fell off the radar 😔
If you can just make codeclimate happy (with our minimum ruby, do/rescue/end is now valid), I think it's good to ![]()
ea8f8ed to
8f7f9e4
Compare
|
@matthewd codeclimate should be happy now :) |
|
I think this is worth changelog entry as well. |
|
I think it is common to write changelog entry on your own. |
It allows anonymous subclasses to be garbage collected.
8f7f9e4 to
7432c92
Compare
|
I have updated the changelog, @matthewd can we merge this? |
|
Thanks again for persevering on this! (And for the poke, @simi) |
This PR will make descendants tracker use weak references
and weak map, so that unused subclasses (unused anonymous subclasses) can be garbage collected, for more details you can see #31395. /cc @matthewdIdeally we would need
WeekKeyMapandWeekSet/WeekArray, but the.refgem only providesWeekKeyMapFixes #31395.
Benchmark results:
According to this class creation would be 4.5x times slower and.descendantscalls would be 2.6x times slower. The performance could be improved by writingWeekSetand maybe improvingWeekKeyMap.Benchmark examples: