Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
perf(electron): reduce default node resource maximums
Browse files Browse the repository at this point in the history
  • Loading branch information
devinus committed Aug 27, 2018
1 parent e773ac3 commit eaf30f0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ember-electron/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ const path = require('path');

const spdy = require('spdy');
const cors = require('cors');
const nanoid = require('nanoid');
const helmet = require('helmet');
const cpFile = require('cp-file');
const connect = require('connect');
const getPort = require('get-port');
const makeDir = require('make-dir');
const username = require('username');
const waitPort = require('wait-port');
const nanoid = require('nanoid/async');
const httpProxy = require('http-proxy');
const selfsigned = require('selfsigned');
const crossSpawn = require('cross-spawn');
Expand All @@ -34,6 +34,7 @@ const fs = Promise.promisifyAll(require('graceful-fs'), {

const electron = require('electron');
const log = require('electron-log');
const { is } = require('electron-util');

const { app } = electron;

Expand Down Expand Up @@ -153,7 +154,7 @@ const startDaemon = async () => {
// https://github.com/cryptocode/notes/wiki/RPC-TLS
config.rpc.secure = {
enable: true,
verbose_logging: true,
verbose_logging: is.development,
server_cert_path: serverCertPath,
server_key_path: serverKeyPath,
server_key_passphrase: '',
Expand All @@ -163,14 +164,16 @@ const startDaemon = async () => {
}

const host = config.rpc.address;
const port = await getPort({ host, port: config.rpc.port });
const peeringPort = await getPort({ host, port: config.node.peering_port });
const port = await getPort({ host, port: [config.rpc.port] });
const peeringPort = await getPort({ host, port: [config.node.peering_port] });
config.rpc.port = port;
config.node.peering_port = peeringPort;

const cpuCount = os.cpus().length;
config.node.io_threads = cpuCount;
config.node.work_threads = cpuCount;
config.node.io_threads = Math.max(4, Math.ceil(cpuCount / 2));
config.node.work_threads = Math.min(4, config.node.io_threads);
config.node.bootstrap_connections = Math.max(4, config.node.io_threads);
config.node.bootstrap_connections_max = Math.min(64, config.node.bootstrap_connections * 4);

const { version: configVersion } = config;
log.info(`Writing node configuration version ${configVersion}:`, configPath);
Expand Down Expand Up @@ -253,7 +256,7 @@ const startDaemon = async () => {
const issuer = 'https://rpc.nanowalletcompany.com/';
const audience = 'https://desktop.nanowalletcompany.com/';
const subject = await username();
const jwtid = nanoid(32);
const jwtid = await nanoid(32);
const jwtOptions = {
issuer,
audience,
Expand Down

0 comments on commit eaf30f0

Please sign in to comment.