sqlite: set SQLITE_THREADSAFE flag as multithreaded#63645
Conversation
Signed-off-by: geeksilva97 <edigleyssonsilva@gmail.com>
|
Review requested:
|
|
We do backup operations off-thread, is this not going to be an issue?
|
That's correct. We would need to redefine it. Either opening a new connection or making it work in the main thread. Both with advantages and drawbacks. I will fill an issue so we can discuss more about it. So far I'm inclined to think that the gains on more use features (get, all, and such) pays off. But I might be missing something. |
We should consider setting SQLITE_THREADSAFE as multithreaded.
node:sqlitecurrently runs on serialized mode. with that we pay some price on mutex acquiring/releasing. But the nature of Node allows code to work safely without these locks.a tiny sample taken from node::sqlite::StatementExecutionHelper::ColumnToValue call
By setting threading mode to multithreaded we have less overhead over serialized. I compiled and benchmarked (on a 14-core Apple M4).
Node.js Benchmark comparison
Running the better-sqlite benchmark we also see the gap reduction.
better-sqliteitself has threading mode as multithreaded.