Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit be4b0d7

Browse files
author
Mark Hahnenberg
committed
[client-app] Add benchmark mode
Summary: There are some settings that apply to dev and prod modes that we don't want to use while benchmarking. E.g. the folder where we store messages, whether we generate long stack traces in our bluebird promises, etc. This diff adds a benchmark mode so that we can change these settings to something that works better for benchmarking. Test Plan: Run locally, verify it works Reviewers: evan, juan, spang Reviewed By: juan, spang Differential Revision: https://phab.nylas.com/D4374
1 parent c808438 commit be4b0d7

File tree

9 files changed

+35
-13
lines changed

9 files changed

+35
-13
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"start": "npm run client",
4646
"test": "npm run test-client && npm run test-cloud",
4747
"client": "packages/client-app/node_modules/.bin/electron packages/client-app --enable-logging --dev",
48+
"benchmark": "packages/client-app/node_modules/.bin/electron packages/client-app --enable-logging --dev --benchmark",
4849
"test-client": "packages/client-app/node_modules/.bin/electron packages/client-app --enable-logging --test",
4950
"test-client-window": "packages/client-app/node_modules/.bin/electron packages/client-app --enable-logging --test=window",
5051
"test-client-junit": "",

packages/client-app/src/browser/application.es6

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let clipboard = null;
2828
//
2929
export default class Application extends EventEmitter {
3030
async start(options) {
31-
const {resourcePath, configDirPath, version, devMode, specMode, safeMode} = options;
31+
const {resourcePath, configDirPath, version, devMode, specMode, benchmarkMode, safeMode} = options;
3232

3333
// Initialize GlobalTimer and start timing app boot time
3434
this.timer = new GlobalTimer()
@@ -39,6 +39,7 @@ export default class Application extends EventEmitter {
3939
this.configDirPath = configDirPath;
4040
this.version = version;
4141
this.devMode = devMode;
42+
this.benchmarkMode = benchmarkMode;
4243
this.specMode = specMode;
4344
this.safeMode = safeMode;
4445

@@ -72,6 +73,7 @@ export default class Application extends EventEmitter {
7273
configDirPath: this.configDirPath,
7374
config: this.config,
7475
devMode: this.devMode,
76+
benchmarkMode: this.benchmarkMode,
7577
specMode: this.specMode,
7678
safeMode: this.safeMode,
7779
initializeInBackground: initializeInBackground,

packages/client-app/src/browser/main.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const setupConfigDir = (args) => {
2323
if (args.specMode) {
2424
defaultDirName = ".nylas-spec";
2525
}
26+
if (args.benchmarkMode) {
27+
defaultDirName = ".nylas-bench";
28+
}
2629
let configDirPath = path.join(app.getPath('home'), defaultDirName);
2730

2831
if (args.configDirPath) {
@@ -46,6 +49,7 @@ const setupErrorLogger = (args = {}) => {
4649
const errorLogger = new ErrorLogger({
4750
inSpecMode: args.specMode,
4851
inDevMode: args.devMode,
52+
inBenchmarkMode: args.benchmarkMode,
4953
resourcePath: args.resourcePath,
5054
});
5155
process.on('uncaughtException', errorLogger.reportError);
@@ -58,6 +62,7 @@ const declareOptions = (argv) => {
5862
const options = optimist(argv);
5963
options.usage("Nylas Mail v" + (app.getVersion()) + "\n\nUsage: nylas-mail [options]\n\nRun Nylas Mail: The open source extensible email client\n\n`nylas-mail --dev` to start the client in dev mode.\n\n`n1 --test` to run unit tests.");
6064
options.alias('d', 'dev').boolean('d').describe('d', 'Run in development mode.');
65+
options.alias('b', 'benchmark').boolean('b').describe('b', 'Run in benchmark mode.');
6166
options.alias('t', 'test').boolean('t').describe('t', 'Run the specified specs and exit with error code on failures.');
6267
options.boolean('safe').describe('safe', 'Do not load packages from ~/.nylas-mail/packages or ~/.nylas/dev/packages.');
6368
options.alias('h', 'help').boolean('h').describe('h', 'Print this usage message.');
@@ -83,7 +88,8 @@ const parseCommandLine = (argv) => {
8388
process.stdout.write(version + "\n");
8489
process.exit(0);
8590
}
86-
const devMode = args['dev'] || args['test'];
91+
const devMode = args['dev'] || args['test'] || args['benchmark'];
92+
const benchmarkMode = args['benchmark'];
8793
const logFile = args['log-file'];
8894
const specMode = args['test'];
8995
const jUnitXmlPath = args['junit-xml'];
@@ -131,6 +137,7 @@ const parseCommandLine = (argv) => {
131137
background,
132138
logFile,
133139
specMode,
140+
benchmarkMode,
134141
jUnitXmlPath,
135142
safeMode,
136143
configDirPath,

packages/client-app/src/browser/nylas-window.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class NylasWindow
2828
pathToOpen,
2929
@isSpec,
3030
@devMode,
31+
@benchmarkMode,
3132
@windowKey,
3233
@safeMode,
3334
@neverClose,
@@ -83,6 +84,7 @@ class NylasWindow
8384
loadSettings.appVersion = app.getVersion()
8485
loadSettings.resourcePath = @resourcePath
8586
loadSettings.devMode ?= false
87+
loadSettings.benchmarkMode ?= false
8688
loadSettings.safeMode ?= false
8789
loadSettings.mainWindow ?= @mainWindow
8890
loadSettings.windowType ?= "default"

packages/client-app/src/browser/window-manager.es6

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ const ONBOARDING_WINDOW = "onboarding"
1010

1111
export default class WindowManager {
1212

13-
constructor({devMode, safeMode, specMode, resourcePath, configDirPath, initializeInBackground, config}) {
13+
constructor({devMode, benchmarkMode, safeMode, specMode, resourcePath, configDirPath, initializeInBackground, config}) {
1414
this.initializeInBackground = initializeInBackground;
1515
this._windows = {};
1616

1717
const onCreatedHotWindow = (win) => {
1818
this._registerWindow(win);
1919
this._didCreateNewWindow(win);
2020
}
21-
this.windowLauncher = new WindowLauncher({devMode, safeMode, specMode, resourcePath, configDirPath, config, onCreatedHotWindow});
21+
this.windowLauncher = new WindowLauncher({devMode, benchmarkMode, safeMode, specMode, resourcePath, configDirPath, config, onCreatedHotWindow});
2222
}
2323

2424
get(windowKey) {
@@ -227,6 +227,7 @@ export default class WindowManager {
227227
hidden: true,
228228
isSpec: true,
229229
devMode: true,
230+
benchmarkMode: false,
230231
toolbar: false,
231232
}
232233

packages/client-app/src/nylas-env.es6

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export default class NylasEnvConstructor {
174174
const ActionBridge = require('./flux/action-bridge').default;
175175
const MenuManager = require('./menu-manager').default;
176176

177-
const {devMode, safeMode, resourcePath, configDirPath, windowType} = this.getLoadSettings();
177+
const {devMode, benchmarkMode, safeMode, resourcePath, configDirPath, windowType} = this.getLoadSettings();
178178

179179
document.body.classList.add(`platform-${process.platform}`);
180180
document.body.classList.add(`window-type-${windowType}`);
@@ -209,7 +209,7 @@ export default class NylasEnvConstructor {
209209
const specMode = this.inSpecMode();
210210

211211
this.commands = new CommandRegistry();
212-
this.packages = new PackageManager({devMode, configDirPath, resourcePath, safeMode, specMode});
212+
this.packages = new PackageManager({devMode, benchmarkMode, configDirPath, resourcePath, safeMode, specMode});
213213
this.styles = new StyleManager();
214214
document.head.appendChild(new StylesElement());
215215
this.themes = new ThemeManager({packageManager: this.packages, configDirPath, resourcePath, safeMode});
@@ -296,7 +296,7 @@ export default class NylasEnvConstructor {
296296
return this.reportError(error);
297297
});
298298

299-
if (this.inSpecMode() || this.inDevMode()) {
299+
if (this.inSpecMode() || (this.inDevMode() && !this.inBenchmarkMode())) {
300300
return Promise.config({longStackTraces: true});
301301
}
302302
return null;
@@ -449,6 +449,10 @@ export default class NylasEnvConstructor {
449449
return this.getLoadSettings().devMode;
450450
}
451451

452+
inBenchmarkMode() {
453+
return this.getLoadSettings().benchmarkMode;
454+
}
455+
452456
// Public: Is the current window in safe mode?
453457
inSafeMode() {
454458
return this.getLoadSettings().safeMode;

packages/client-sync/src/local-sync-worker/sync-worker.es6

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ class SyncWorker {
263263
onConnected: async ([listenerConn], onDone) => {
264264
this._mailListenerIMAPConn = listenerConn;
265265
this._mailListenerIMAPConn._db = this._db;
266+
this._mailListenerIMAPConnDisposer = onDone
267+
268+
// We don't want to listen for new mail while benchmarking initial
269+
// sync b/c receiving new mail can significantly increase the variance
270+
// in our measurements.
271+
if (NylasEnv.inBenchmarkMode()) {
272+
return true;
273+
}
266274

267275
this._mailListenerIMAPConn.on('mail', () => {
268276
this._onInboxUpdates(`You've got mail`);
@@ -275,9 +283,6 @@ class SyncWorker {
275283
if (this._shouldIgnoreInboxFlagUpdates) { return; }
276284
this._onInboxUpdates(`There are flag updates on the inbox`);
277285
})
278-
279-
this._mailListenerIMAPConnDisposer = onDone
280-
// Return true to keep connection open
281286
return true
282287
},
283288
})

scripts/benchmark-initial-sync.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ then
2222
fi
2323
2424
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25-
NYLAS_DIR="$HOME/.nylas-dev"
25+
NYLAS_DIR="$HOME/.nylas-bench"
2626
EDGEHILL_DB="$NYLAS_DIR/edgehill.db"
2727
TIME_LIMIT=120
2828
ITERS=5
@@ -31,7 +31,7 @@ for i in `seq 1 $ITERS`
3131
do
3232
bash $CWD/drop-data-except-accounts.sh > /dev/null
3333
34-
(npm start &> /dev/null &)
34+
(npm run benchmark &> /dev/null &)
3535
3636
sleep $TIME_LIMIT
3737

scripts/drop-data-except-accounts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6-
NYLAS_DIR="$HOME/.nylas-dev"
6+
NYLAS_DIR="$HOME/.nylas-bench"
77
TRUNCATE_TABLES="
88
Account
99
AccountPluginMetadata

0 commit comments

Comments
 (0)