Skip to content

Commit

Permalink
feat: allow setting of dbsize from swingset-runner command line
Browse files Browse the repository at this point in the history
  • Loading branch information
FUDCo committed Jun 9, 2021
1 parent b613501 commit f56df1e
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions packages/swingset-runner/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ FLAGS may be:
--lmdb - runs using LMDB as the data store (default)
--memdb - runs using the non-persistent in-memory data store
--dbdir DIR - specify where the data store should go (default BASEDIR)
--dbsize SIZE - set the LMDB size limit to SIZE megabytes (default 2GB)
--blockmode - run in block mode (checkpoint every BLOCKSIZE blocks)
--blocksize N - set BLOCKSIZE to N cranks (default 200)
--logtimes - log block execution time stats while running
Expand Down Expand Up @@ -182,6 +183,7 @@ export async function main() {
let configPath = null;
let statsFile = null;
let dbDir = null;
let dbSize = 0;
let initOnly = false;
let loopbox = false;

Expand Down Expand Up @@ -254,6 +256,9 @@ export async function main() {
case '--dbdir':
dbDir = argv.shift();
break;
case '--dbsize':
dbSize = Number(argv.shift());
break;
case '--raw':
rawMode = true;
doDumps = true;
Expand Down Expand Up @@ -351,23 +356,34 @@ export async function main() {
if (launchIndirectly) {
config = generateIndirectConfig(config);
}
if (!dbDir) {
dbDir = basedir;
}

let swingStore;
const kernelStateDBDir = path.join(dbDir, 'swingset-kernel-state');
switch (dbMode) {
case '--memdb':
if (dbDir) {
fail('--dbdir only valid with --lmdb');
}
if (dbSize) {
fail('--dbsize only valid with --lmdb');
}
swingStore = initSimpleSwingStore();
break;
case '--lmdb':
case '--lmdb': {
if (!dbDir) {
dbDir = basedir;
}
const kernelStateDBDir = path.join(dbDir, 'swingset-kernel-state');
const dbOptions = {};
if (dbSize) {
dbOptions.mapSize = dbSize * 1024 * 1024;
}
if (forceReset) {
swingStore = initLMDBSwingStore(kernelStateDBDir);
swingStore = initLMDBSwingStore(kernelStateDBDir, dbOptions);
} else {
swingStore = openLMDBSwingStore(kernelStateDBDir);
swingStore = openLMDBSwingStore(kernelStateDBDir, dbOptions);
}
break;
}
default:
fail(`invalid database mode ${dbMode}`, true);
}
Expand Down

0 comments on commit f56df1e

Please sign in to comment.