News for hackers. Stuff that matters.
Re:Better-sqlite3: A faster Sqlite library for Node.js by masklinn on Monday March 19, 2018 @06:40AM (#16617393)
Yes. Unless the underlying reactor/scheduler is multithreaded but that's… uncommon, as async code tends not to consider thread-safety.

It certainly isn't the case for nodejs.

One could wonder whether that's an issue when IO are fairly short & strongly interspersed with code being run though, the overhead of switching tasks could be higher than the IO you're synchronising. I guess whether this is a good idea would strongly depend on how you're using sqlite (aka do you tend to make lots of very simple requests with small output or a smaller number of more complex ones).

Re:Better-sqlite3: A faster Sqlite library for Node.js by zbentley on Monday March 19, 2018 @09:39AM (#16618234)
> One could wonder whether that's an issue when IO are fairly short & strongly interspersed with code being run though

IMO one of the core observations made by Dahl and the other Node.js folks was that this is very very rarely the case in modern web applications. Most webapps either a) spend the vast majority of their time waiting on IO, b) have non-IO code very regularly interspersed with IO operations (making event-loop based interleaving based on IO boundaries more useful) or c) both.

As a result, Node.js was built with the single-thread/IO-bounded reactor model. I think that this, along with (and perhaps even more than) its choice of language syntax, drove the platform's adoption. It means that code doesn't need to think about thread safety, and that there is only one IO model: asynchronous by default (yes there are exceptions, but they're a minority). That lets users get a lot of scale for free, provided their workloads meet those criteria.