-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Mono] Implement eager finalization of WeakReference #76173
Conversation
d156eb3
to
ebaf490
Compare
I'm not sure I understand what is happening here. What does making finalization eager actually mean for WeakRefs? What is the behavior supposed to be? |
WeakReference types are finalizable types. Weak references could be used in big quantities and that can have bad effects on finalization queue. The eager approach also has some reliability advantages. Since eager finalization happens when managed threads are stopped, there is no chance of getting into races between finalization and concurrent use of the weak references from other threads. CoreCLR had eager finalization of weak references for a long time. NativeAOT has added that recently - #75436 Another advantage is that if Mono implements eager finalization, it would be able to use the shared implementation of |
Thanks @VSadov for explaining it better than I would 👍 |
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.
lgtm. although i'm not sure we should put weakreference into mono_defaults
This change could further be improved by avoiding a useless object allocation. In |
@BrzVlad As I understand the suggestion, we need to move the specialcasing of weak references a bit earlier - from Is this the idea? |
@VSadov Yes, that is correct |
Thanks for taking care of the last feedback, @VSadov! |
I assume the change addresses the suggestions and once |
As of this commit, I'm now seeing failures when running the libs.tests suite on s390x (Mono-based runtime):
Any suggestions what this could be, or how to further debug? |
I remember seeing this assertion locally but I didn't get to investigate it. I'll see if I can repro this week |
@uweigand Do you have any details about which test is failing? |
It varies, I've seen multiple different tests failing. One that seems to fail most of the time is |
Also interesting is that for some unknown reason, I'm not seeing any of these failures in the CI here: |
I can reproduce, will take a look later |
Thanks a lot! |
…otnet#76173)"" This reverts commit f8f013e.
Yes, this has fixed the test suite on s390x. Thanks! |
No description provided.