Skip to content
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

ConcurrentDatabaseConnection and its NSRecursiveLock #37

Open
andersio opened this issue Jan 18, 2021 · 1 comment
Open

ConcurrentDatabaseConnection and its NSRecursiveLock #37

andersio opened this issue Jan 18, 2021 · 1 comment

Comments

@andersio
Copy link
Contributor

andersio commented Jan 18, 2021

ConcurrentDatabaseConnection at the moment uses a NSRecursiveLock, which is kinda emulating the SQLite Serialized mode, i.e., open with flag SQLITE_OPEN_FULLMUTEX. Meanwhile, the SQLite3 distribution on Darwin platforms has long been defaulted to use the Multi-thread mode.

If a user is doing connection pooling, the connection should have already been exclusively bound to a thread, until the connection can truly be returned to the pool for reuse (e.g., all active statements are closed; no escaped reference). In this use case, the additional locking on every call would be:

  • quite defensive for a Multi-thread mode connection; and
  • unnecessary for a Serialized mode connection.

So it seems there are two opportunities of minor improvements:

@kpgalligan
Copy link
Contributor

I've been thinking about the concurrent connection for a while. I do think this will largely be on the back burner until the remainder of the discussions are driver updates and sqldelight are resolved. I have work happening on updating the current sqldelight driver's internals that include you connection pooling and some other optimizations that have been pending for a while, and we've started the discussion around the read lambda change, which along with some other potentially breaking changes, might go into a bigger release, but that needs some more chatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants