Improved threading performance on non-SQLite clients

refs https://github.com/TryGhost/Ghost/pull/12431

- child_process are more expensive to run comparing to worker_threads (ref. https://wanago.io/2019/05/20/node-js-typescript-14-performance-hooks/)
- limiting child process only to sqlite backed instances allows high load servers running with MySQL (most usecases) to continue using worker_threads
This commit is contained in:
Naz 2020-11-30 13:27:40 +13:00
parent a29ac2691a
commit eb52cb06bb

View File

@ -1,3 +1,5 @@
const config = require('../shared/config');
/**
* If we enable bluebird debug logs we see a huge memory usage.
* You can reproduce by removing this line and import a big database export into Ghost.
@ -9,7 +11,10 @@ process.env.BLUEBIRD_DEBUG = 0;
* Force bthreads to use child_process backend until a worker_thread-compatible version of sqlite3 is published
* https://github.com/mapbox/node-sqlite3/issues/1386
*/
process.env.BTHREADS_BACKEND = 'child_process';
const isSQLite = config.get('database:client') === 'sqlite3';
if (isSQLite) {
process.env.BTHREADS_BACKEND = 'child_process';
}
const moment = require('moment-timezone');