-
Notifications
You must be signed in to change notification settings - Fork 25k
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
ActionListener#notifyOnce should release delegate on completion #92452
ActionListener#notifyOnce should release delegate on completion #92452
Conversation
There's no need to keep hold of the delegate after completing it, and in some cases this might hold on to excessive heap. With this commit we drop the reference to the delegate when it's complete. Closes elastic#92451
Pinging @elastic/es-core-infra (Team:Core/Infra) |
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.
Good find!
One thing we could have is a test that checks the delegate is unassigned after it's called, by using a weak reference. But that might be a bit too much for this. Up to you.
Yeah that'd be nice, but I think it would mean we have to force a GC? I tried, but I didn't manage to get it to work anyway. |
@elasticmachine please run elasticsearch-ci/part-3 |
Like elastic#92452 but for `RunOnce`.
Like elastic#92452 and elastic#92507 but for `Releasables#releaseOnce`: there's no need to keep hold of the wrapped releasable after closing it, and in some cases this might hold on to excessive heap. With this commit we drop the reference to the delegate when it's complete.
Like #92452 but for `RunOnce`.
Like elastic#92452 but for `RunOnce`.
We recently adjusted `RunOnce`, `Releasables#releaseOnce` and `ActionListener#notifyOnce` so that once they have fired they drop the now-unnecessary reference to the delegate. This commit introduces tests to verify that this reference does genuinely become unreachable (i.e. available for garbage collection) as expected. It also fixes a bug in `ActionListener#notifyOnce` which caused us to unexpectedly retain a reference to the delegate 🤦 Relates elastic#92452 Relates elastic#92507 Relates elastic#92537
We recently adjusted `RunOnce`, `Releasables#releaseOnce` and `ActionListener#notifyOnce` so that once they have fired they drop the now-unnecessary reference to the delegate. This commit introduces tests to verify that this reference does genuinely become unreachable (i.e. available for garbage collection) as expected. It also fixes a bug in `ActionListener#notifyOnce` which caused us to unexpectedly retain a reference to the delegate 🤦 Relates elastic#92452 Relates elastic#92507 Relates elastic#92537
I suspect this might be because this commit had a subtle bug 🤦 - see #92928 |
We recently adjusted `RunOnce`, `Releasables#releaseOnce` and `ActionListener#notifyOnce` so that once they have fired they drop the now-unnecessary reference to the delegate. This commit introduces tests to verify that this reference does genuinely become unreachable (i.e. available for garbage collection) as expected. It also fixes a bug in `ActionListener#notifyOnce` which caused us to unexpectedly retain a reference to the delegate 🤦 Relates #92452 Relates #92507 Relates #92537
Recent improvements to the primitives for writing async code (particularly elastic#92452 and elastic#92620) mean that we can enormously simplify `TransportNodesAction`. In particular, we can avoid accumulating an intermediate array of responses for later processing in favour of just accumulating the successes and failures into their final separate lists. We also no longer need to use a separate `NodesResponseTracker` to discard responses on cancellation.
Recent improvements to the primitives for writing async code (particularly #92452 and #92620) mean that we can enormously simplify `TransportNodesAction`. In particular, we can avoid accumulating an intermediate array of responses for later processing in favour of just accumulating the successes and failures into their final separate lists. We also no longer need to use a separate `NodesResponseTracker` to discard responses on cancellation.
Similarly to elastic#92987, recent improvements to the primitives for writing async code (particularly elastic#92452 and elastic#92620) mean that we can enormously simplify `TransportBroadcastByNodeAction`. In particular, we can avoid accumulating an intermediate array of responses for later processing in favour of just accumulating the successes and failures into their final separate lists. We also no longer need to use a separate `NodesResponseTracker` to discard responses on cancellation. Finally, we can now discard shard-level responses more promptly on cancellation.
Similarly to #92987, recent improvements to the primitives for writing async code (particularly #92452 and #92620) mean that we can enormously simplify `TransportBroadcastByNodeAction`. In particular, we can avoid accumulating an intermediate array of responses for later processing in favour of just accumulating the successes and failures into their final separate lists. We also no longer need to use a separate `NodesResponseTracker` to discard responses on cancellation. Finally, we can now discard shard-level responses more promptly on cancellation.
There's no need to keep hold of the delegate after completing it, and in some cases this might hold on to excessive heap. With this commit we drop the reference to the delegate when it's complete.
Closes #92451