Have ConnectionThread use a background event target instead of its own thread
Categories
(Core :: Storage: localStorage & sessionStorage, task, P3)
Tracking
()
People
(Reporter: KrisWright, Unassigned)
References
(Blocks 1 open bug)
Details
Instead of creating its own thread[1], LocalStorage could create a background task queue [2] to dispatch async work.
I'm not sure how much the order matters to dispatch in this work since I haven't looked especially closely at it, but the only way to expose some IsOnCurrentThread() to ConnectionThread [3] right now is to use an event target anyway.
[1] https://searchfox.org/mozilla-central/rev/a92ed79b0bc746159fc31af1586adbfa9e45e264/dom/localstorage/ActorsParent.cpp#4721
[2] https://searchfox.org/mozilla-central/rev/a92ed79b0bc746159fc31af1586adbfa9e45e264/xpcom/threads/nsThreadUtils.h#1762
[3] https://searchfox.org/mozilla-central/rev/a92ed79b0bc746159fc31af1586adbfa9e45e264/dom/localstorage/ActorsParent.cpp#4729
Comment 1•5 years ago
|
||
We open storage connections on this thread (SQLite) and we need to close them on the same thread. We also need to flush data to disk before the thread dies. Not sure if that's possible with background task queue.
Andrew, I haven't thought about this much (it's rather low priority), but do you happen to have an opinion on this ?
Comment 2•5 years ago
|
||
We should do this (use NS_CreateBackgroundTaskQueue). We just need to fix mozStorage bug 1121282 which is about changing Connection::threadOpenedOn to stop explicitly being about nsIThread and instead be about nsISerialEventTarget. (The bug was filed before we had nsISerialEventTarget, so it just mentions nsIEventTarget, but I think nsISerialEventTarget is an appropriate constraint.)
We can definitely review patches for this in a timely fashion if this effort also has engineers ready to help with the fixes!
Comment 3•5 years ago
|
||
There's one thing which is quite useful currently. When we analyze crash stats, for example a shutdown hang, we can currently go directly to "LS Thread" and check how the stack looks like.
Updated•3 years ago
|
Description
•