Do BrowserDB transactions on a background thread #532
Closed
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.
The SwiftData code runs all transaction synchronously on a background thread to avoid concurrency issues. I build it this way originally so that callers could decide for themselves if they wanted to run on a background thread. None of ours are running on background threads though AFAIK (I think remote tabs and clients is)? This moves all BrowserDB (i.e. places) access to a new background one. That should mean that sync don't block the UI (not verified?) and it DOES mean that tapping the urlbar reacts much more quickly with a large data set (but still shows you no data until the cursor has loaded).
There's a lot of possible places to put this threading. We could also do things like allowing BrowserDB to take a queue when its created, which would let us share a queue with other DBs. Curious what others think.