-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Simplify task queues locking mechanism #16477
Conversation
We now have one mutex guarding all accesses to the underlying task heaps. This simplifies the more granular but bug prone mechanism of having striped locks. This also re-enables GPUThreadMerger tests that are currently disabled due to their flaky nature.
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.
Can you elaborate on the hypothesis as to why this simplification leads to less flakiness? Also, a brief mention of the perf consequences of this change (essentially a global lock around all task queues) would be good. Overall, the simplification looks good and makes the code easier to reason about. So I am in favor of this change just for that reason. Also, replacing the operator[]
with at
is much needed.
Also, please link with flutter/flutter#49007.
@chinmaygarde i've updated the description elaborating my hypothesis. Let me know what you think. |
* c932214 Ensure fields of Rect and OffsetBase classes are optimized as non-null. (flutter/engine#16465) * 5c70356 Simplify task queues locking mechanism (flutter/engine#16477) * d589dde Fix text range logic for a11y (flutter/engine#16496) * 1a4f4e3 Fix unused import in Android embedder (flutter/engine#16494) * 964ae10 Disable ShellTest.WaitForFirstFrameTimeout on Fuchsia (flutter/engine#16495) * 6158f03 Roll src/third_party/skia 87e3bef6f82f..9f3eef796f63 (7 commits) (flutter/engine#16493)
We now have one mutex guarding all accesses to the underlying task heaps. This simplifies the more granular but bug prone mechanism of having striped locks. This also re-enables GPUThreadMerger tests that are currently disabled due to their flaky nature. The scenario that gets fixed by this change is as follows: 1. Thread-1: We lock `queue_meta_mutex_` and grab locks on `queue_1` and release the meta mutex. 2. Thread-1: We add an Observer on `queues` object. 3. Thread-2: We lock `queue_meta_mutex_` and grab locks on `queue_2`. 4. Thread-2: We try to dispose all the pending tasks on `queue_2` which calls `erase` on `queues`. The above situation is not thread safe without having 1 lock. Note: This increases the contention on one lock and could potentially be bad for perf. We are explicitly making this trade-off towards reducing the complexity. Fixes: flutter/flutter#49007
This reverts commit 3dba8e9.
We now have one mutex guarding all accesses to
the underlying task heaps. This simplifies the more granular
but bug prone mechanism of having striped locks.
This also re-enables GPUThreadMerger tests that are currently
disabled due to their flaky nature. The scenario that gets fixed by this
change is as follows:
queue_meta_mutex_
and grab locks onqueue_1
and release the meta mutex.queues
object.queue_meta_mutex_
and grab locks onqueue_2
.queue_2
which callserase
onqueues
.The above situation is not thread safe without having 1 lock.
Note: This increases the contention on one lock and could potentially be bad for perf. We are
explicitly making this trade-off towards reducing the complexity.
Fixes: flutter/flutter#49007