[Proxying][NFC] Move deferred cleanup logic to em_task_queue - #18851
Merged
Conversation
We previously had a scheme to defer freeing of `em_proyxing_queue`s until there were no more outstanding references to their `em_task_queues` sitting in message queues. Since the notification messages only ever contain references to `em_task_queue`s and not the `em_proxying_queue`s, move the deferred cleanup logic to the `em_task_queue` layer from the `em_proxying_queue` layer. This slightly simplifies the code and is a cleaner separation of concerns. This is NFC as far as users are concerned, and the code is moved with only two changes to internal behavior. First, we now use a trylock when culling zombies to avoid blocking when multiple threads are creating `em_task_queue`s at the same time. Second, we now enqueue zombie queues at the tail of the zombie list instead of the head because FIFO behavior seems fairer. The test for the zombie culling behavior is necessarily less precise now because it the objects with deferred cleanup are no longer directly user-visible. The test still does its job, though.
This was referenced Feb 25, 2023
Member
Author
|
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
This was referenced Feb 25, 2023
sbc100
reviewed
Feb 28, 2023
| break; | ||
| } | ||
| } | ||
| frees++; |
Collaborator
There was a problem hiding this comment.
Does hit not risk counting other misc allocations? (I guess if it ever does this test will just start failing or flaking)..
Member
Author
There was a problem hiding this comment.
Yeah, right now this doesn't seem to be a problem, but I could imagine that this test would start flaking in the future. At some point we might want to remove it entirely in favor of a test that builds and tests the internal em_task_queue implementation directly.
sbc100
approved these changes
Feb 28, 2023
impact-maker
pushed a commit
to impact-maker/emscripten
that referenced
this pull request
Mar 17, 2023
…ipten-core#18851) We previously had a scheme to defer freeing of `em_proyxing_queue`s until there were no more outstanding references to their `em_task_queues` sitting in message queues. Since the notification messages only ever contain references to `em_task_queue`s and not the `em_proxying_queue`s, move the deferred cleanup logic to the `em_task_queue` layer from the `em_proxying_queue` layer. This slightly simplifies the code and is a cleaner separation of concerns. This is NFC as far as users are concerned, and the code is moved with only two changes to internal behavior. First, we now use a trylock when culling zombies to avoid blocking when multiple threads are creating `em_task_queue`s at the same time. Second, we now enqueue zombie queues at the tail of the zombie list instead of the head because FIFO behavior seems fairer. The test for the zombie culling behavior is necessarily less precise now because it the objects with deferred cleanup are no longer directly user-visible. The test still does its job, though.
impact-maker
pushed a commit
to impact-maker/emscripten
that referenced
this pull request
Mar 17, 2023
…ipten-core#18851) We previously had a scheme to defer freeing of `em_proyxing_queue`s until there were no more outstanding references to their `em_task_queues` sitting in message queues. Since the notification messages only ever contain references to `em_task_queue`s and not the `em_proxying_queue`s, move the deferred cleanup logic to the `em_task_queue` layer from the `em_proxying_queue` layer. This slightly simplifies the code and is a cleaner separation of concerns. This is NFC as far as users are concerned, and the code is moved with only two changes to internal behavior. First, we now use a trylock when culling zombies to avoid blocking when multiple threads are creating `em_task_queue`s at the same time. Second, we now enqueue zombie queues at the tail of the zombie list instead of the head because FIFO behavior seems fairer. The test for the zombie culling behavior is necessarily less precise now because it the objects with deferred cleanup are no longer directly user-visible. The test still does its job, though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

We previously had a scheme to defer freeing of
em_proyxing_queues until therewere no more outstanding references to their
em_task_queuessitting inmessage queues. Since the notification messages only ever contain references to
em_task_queues and not theem_proxying_queues, move the deferred cleanuplogic to the
em_task_queuelayer from theem_proxying_queuelayer. Thisslightly simplifies the code and is a cleaner separation of concerns.
This is NFC as far as users are concerned, and the code is moved with only two
changes to internal behavior. First, we now use a trylock when culling zombies
to avoid blocking when multiple threads are creating
em_task_queues at thesame time. Second, we now enqueue zombie queues at the tail of the zombie list
instead of the head because FIFO behavior seems fairer.
The test for the zombie culling behavior is necessarily less precise now because
it the objects with deferred cleanup are no longer directly user-visible. The
test still does its job, though.