-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fixup deadlock when hammering futures of a certain type #88
Conversation
f657971
to
67eb94d
Compare
Thank you for the fix, it does work on our branch and the deadlock is gone now. Though the fact that 100ms is the threshhold it starts working at makes me worry a little bit that we've just worked around the call? Does the extra poll need to be applied each time, or is it the first time that matters the most (I thought the uniffi task was saying that it was related to setup + poll being too close to each other? |
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.
Approve as a viable workaround, though I'd love to better understand the 'why' if possible.
My understanding is that the poll is protected by a mutex. A call to the poll on the Rust side:
Before this change, the
The fix makes the work done in This analysis might suggest that we could be reliably reproduced by setting up a situation where the What I can't explain, if the above is true, but can hazard a guess at:
At this point, it's worth pointing out:
@zzorba Would you be able to change the 100 to 1 or zero, and try it out within React Native? What still confuses me: if the above is true—
Eyeballing uniffi's |
422bd95
to
d0b5904
Compare
d0b5904
to
86a80c1
Compare
The continuation callback needed to be called and done by the time next poll happened. Tests for this are in #89 . It is to load the same image 2, 4, 8, 16, 32, 64, 128, 256, 512, 512 times. Things I tried:
I think am ready to declare victory on this now. In the end, I think only faf0f89 is needed here. There is almost no changes in I'm going to ask @zzorba for another review. |
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, confirmed the fix in the full app, its working great.
The change here is in `UniffiCallInvoker`, reverting the implementation of `invokeBlocking` back to the Promise based implementation introduced in PR #88. The deadlock rate for the test is now 0/50. Adding any more to the implementation (e.g. uncommenting the `console.log`) causes the same error as before, but it is completely deterministic: ```sh -- Going to 1024, now at: 264 -- Going to 1024, now at: 265 Assertion failed: (usedDbg_ && "Stats not submitted."), function ~CollectionStats, file HadesGC.cpp, line 259. ``` On my machine it _always_ stops after 265/1024. I am still unsure if this is a problem with production uniff-bindgen-react-native code, an artifact of the test-harness or something weirder. I'm going to suggest that this is addressed in a separate issue.
The change here is in `UniffiCallInvoker`, reverting the implementation of `invokeBlocking` back to the Promise based implementation introduced in PR #88. The deadlock rate for the test is now 0/50. Adding any more to the implementation (e.g. uncommenting the `console.log`) causes the same error as before, but it is completely deterministic: ```sh -- Going to 1024, now at: 264 -- Going to 1024, now at: 265 Assertion failed: (usedDbg_ && "Stats not submitted."), function ~CollectionStats, file HadesGC.cpp, line 259. ``` On my machine it _always_ stops after 265/1024. I am still unsure if this is a problem with production uniff-bindgen-react-native code, an artifact of the test-harness or something weirder. I'm going to suggest that this is addressed in a separate issue.
Fixes #157 Minimal test: 146cd39 The change here is in `UniffiCallInvoker`, reverting the implementation of `invokeBlocking` back to the Promise based implementation introduced in PR #88. The deadlock rate for the test is now 0/50. /cc @tayrevor Adding any more to the implementation (e.g. uncommenting the `console.log`) causes the same error as before, but it is completely deterministic: ```sh -- Going to 1024, now at: 264 -- Going to 1024, now at: 265 Assertion failed: (usedDbg_ && "Stats not submitted."), function ~CollectionStats, file HadesGC.cpp, line 259. ``` On my machine it _always_ stops after 265/1024. I am still unsure if this is a problem with production uniff-bindgen-react-native code, an artifact of the test-harness or something weirder. I'm going to suggest that this is addressed in a separate issue.
According to The Big O of Code Reviews, this is a O(n) change.
This PR moves the polling of futures to outside of the continuation callback; this has shown to be a source of deadlocks.
Unfortunately, the tests for this aren't likely to end up in this repo, since it relies on a fork of the matrix-sdk.
As said in the comment, I'm don't think this has fixed all possible deadlocks, but I'm hoping this has at least fixed the proximal problem.
Fixes #89