From fb23bab6fe38f2e8d71ca51d8210b403d2514e3a Mon Sep 17 00:00:00 2001 From: Boss Marco Date: Tue, 26 Oct 2021 10:50:01 +0200 Subject: [PATCH 1/9] update bench1 config --- packages/taler-wallet-cli/src/bench1.ts | 33 +++++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts index 4a2651f36..1d836365d 100644 --- a/packages/taler-wallet-cli/src/bench1.ts +++ b/packages/taler-wallet-cli/src/bench1.ts @@ -48,10 +48,13 @@ export async function runBench1(configJson: any): Promise { await wallet.client.call(WalletApiOperation.InitWallet, {}); const numIter = b1conf.iterations ?? 1; + const numDeposits = b1conf.deposits ?? 5; + + const withdrawAmount = (numDeposits + 1) * 10; for (let i = 0; i < numIter; i++) { await wallet.client.call(WalletApiOperation.WithdrawFakebank, { - amount: "TESTKUDOS:10", + amount: b1conf.currency + ":" + string(withdrawAmount), bank: b1conf.bank, exchange: b1conf.exchange, }); @@ -60,14 +63,16 @@ export async function runBench1(configJson: any): Promise { stopWhenDone: true, }); - await wallet.client.call(WalletApiOperation.CreateDepositGroup, { - amount: "TESTKUDOS:5", - depositPaytoUri: "payto://x-taler-bank/localhost/foo", - }); + for (let i = 0; i < numDeposits; i++) { + await wallet.client.call(WalletApiOperation.CreateDepositGroup, { + amount: b1conf.currency + ":10", + depositPaytoUri: b1conf.payto, + }); - await wallet.runTaskLoop({ - stopWhenDone: true, - }); + await wallet.runTaskLoop({ + stopWhenDone: true, + }); + } } wallet.stop(); @@ -82,6 +87,11 @@ interface Bench1Config { */ bank: string; + /** + * Payto url for deposits. + */ + payto: string; + /** * Base URL of the exchange. */ @@ -92,6 +102,10 @@ interface Bench1Config { * Defaults to 1. */ iterations?: number; + + currency: string; + + deposits?: number; } /** @@ -100,6 +114,9 @@ interface Bench1Config { const codecForBench1Config = () => buildCodecForObject() .property("bank", codecForString()) + .property("payto", codecForString()) .property("exchange", codecForString()) .property("iterations", codecOptional(codecForNumber())) + .property("deposits", codecOptional(codecForNumber())) + .property("currency", codecForString()) .build("Bench1Config"); From 4b05ba002ca07eb5722d9f4c5ef7383b48cc752e Mon Sep 17 00:00:00 2001 From: Boss Marco Date: Tue, 26 Oct 2021 11:04:02 +0200 Subject: [PATCH 2/9] remove string() --- packages/taler-wallet-cli/src/bench1.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts index 1d836365d..55558a284 100644 --- a/packages/taler-wallet-cli/src/bench1.ts +++ b/packages/taler-wallet-cli/src/bench1.ts @@ -54,7 +54,7 @@ export async function runBench1(configJson: any): Promise { for (let i = 0; i < numIter; i++) { await wallet.client.call(WalletApiOperation.WithdrawFakebank, { - amount: b1conf.currency + ":" + string(withdrawAmount), + amount: b1conf.currency + ":" + withdrawAmount, bank: b1conf.bank, exchange: b1conf.exchange, }); From dce86113b1c1863435e2970e1cf2f03f377ab5f4 Mon Sep 17 00:00:00 2001 From: Boss Marco Date: Wed, 27 Oct 2021 15:56:28 +0200 Subject: [PATCH 3/9] disable throttling for bench1 --- packages/taler-wallet-cli/src/bench1.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts index 55558a284..6a1e0d915 100644 --- a/packages/taler-wallet-cli/src/bench1.ts +++ b/packages/taler-wallet-cli/src/bench1.ts @@ -40,6 +40,7 @@ export async function runBench1(configJson: any): Promise { const b1conf = codecForBench1Config().decode(configJson); const myHttpLib = new NodeHttpLib(); + myHttpLib.setThrottling(false); const wallet = await getDefaultNodeWallet({ // No persistent DB storage. persistentStoragePath: undefined, From 8d9386ac008e9d095867433bfc789d09bd93414d Mon Sep 17 00:00:00 2001 From: Boss Marco Date: Wed, 3 Nov 2021 16:20:55 +0100 Subject: [PATCH 4/9] start a new wallet for each iteration --- packages/taler-wallet-cli/src/bench1.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts index 6a1e0d915..448dc913d 100644 --- a/packages/taler-wallet-cli/src/bench1.ts +++ b/packages/taler-wallet-cli/src/bench1.ts @@ -41,12 +41,6 @@ export async function runBench1(configJson: any): Promise { const myHttpLib = new NodeHttpLib(); myHttpLib.setThrottling(false); - const wallet = await getDefaultNodeWallet({ - // No persistent DB storage. - persistentStoragePath: undefined, - httpLib: myHttpLib, - }); - await wallet.client.call(WalletApiOperation.InitWallet, {}); const numIter = b1conf.iterations ?? 1; const numDeposits = b1conf.deposits ?? 5; @@ -54,6 +48,17 @@ export async function runBench1(configJson: any): Promise { const withdrawAmount = (numDeposits + 1) * 10; for (let i = 0; i < numIter; i++) { + + // Create a new wallet in each iteration + // otherwise the TPS go down + // my assumption is that the in-memory db file gets too large + const wallet = await getDefaultNodeWallet({ + // No persistent DB storage. + persistentStoragePath: undefined, + httpLib: myHttpLib, + }); + await wallet.client.call(WalletApiOperation.InitWallet, {}); + await wallet.client.call(WalletApiOperation.WithdrawFakebank, { amount: b1conf.currency + ":" + withdrawAmount, bank: b1conf.bank, @@ -74,9 +79,9 @@ export async function runBench1(configJson: any): Promise { stopWhenDone: true, }); } - } - wallet.stop(); + wallet.stop(); + } } /** From 42cf0c445c2c1da04fa9c9e1a6151108fce975f7 Mon Sep 17 00:00:00 2001 From: Boss Marco Date: Sun, 7 Nov 2021 11:47:50 +0100 Subject: [PATCH 5/9] added timestamps to logs --- packages/taler-wallet-cli/src/bench1.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts index 3d4561097..025d2c97e 100644 --- a/packages/taler-wallet-cli/src/bench1.ts +++ b/packages/taler-wallet-cli/src/bench1.ts @@ -51,7 +51,7 @@ export async function runBench1(configJson: any): Promise { const withdrawAmount = (numDeposits + 1) * 10; - logger.info(`Starting Benchmark with ${numIter} Iterations`); + logger.info(`Starting Benchmark iterations=${numIter} deposits=${numDeposits}`); for (let i = 0; i < numIter; i++) { // Create a new wallet in each iteration @@ -63,8 +63,9 @@ export async function runBench1(configJson: any): Promise { httpLib: myHttpLib, }); await wallet.client.call(WalletApiOperation.InitWallet, {}); - - logger.info(`Starting withdrawal of ${withdrawAmount} ${b1conf.currency}`); + + logger.trace(`Starting withdrawal amount=${withdrawAmount}`); + console.time('withdraw'); await wallet.client.call(WalletApiOperation.WithdrawFakebank, { amount: b1conf.currency + ":" + withdrawAmount, @@ -76,11 +77,13 @@ export async function runBench1(configJson: any): Promise { stopWhenDone: true, }); - logger.info(`Finished withdrawal`); + logger.info(`Finished withdrawal amount=${withdrawAmount} time=${console.time('withdraw')}`); for (let i = 0; i < numDeposits; i++) { - logger.info(`Starting deposit of 10 ${b1conf.currency}`); + logger.trace(`Starting deposit amount=10`); + console.time('deposit') + await wallet.client.call(WalletApiOperation.CreateDepositGroup, { amount: b1conf.currency + ":10", depositPaytoUri: b1conf.payto, @@ -89,7 +92,8 @@ export async function runBench1(configJson: any): Promise { await wallet.runTaskLoop({ stopWhenDone: true, }); - logger.info(`Deposit succesful`); + + logger.info(`Finished deposit amount=10 time=${console.time('deposit')}`); } wallet.stop(); From 8dadd89edbb22ccb698b27cfdbd6fd0bb886be72 Mon Sep 17 00:00:00 2001 From: Boss Marco Date: Tue, 9 Nov 2021 10:58:30 +0100 Subject: [PATCH 6/9] timeEnd --- packages/taler-wallet-cli/src/bench1.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts index 025d2c97e..3050d8a42 100644 --- a/packages/taler-wallet-cli/src/bench1.ts +++ b/packages/taler-wallet-cli/src/bench1.ts @@ -77,7 +77,7 @@ export async function runBench1(configJson: any): Promise { stopWhenDone: true, }); - logger.info(`Finished withdrawal amount=${withdrawAmount} time=${console.time('withdraw')}`); + logger.info(`Finished withdrawal amount=${withdrawAmount} time=${console.timeEnd('withdraw')}`); for (let i = 0; i < numDeposits; i++) { @@ -93,7 +93,7 @@ export async function runBench1(configJson: any): Promise { stopWhenDone: true, }); - logger.info(`Finished deposit amount=10 time=${console.time('deposit')}`); + logger.info(`Finished deposit amount=10 time=${console.timeEnd('deposit')}`); } wallet.stop(); From 612275df613e1c0af15d062c387b9d2f14ccc2fc Mon Sep 17 00:00:00 2001 From: Boss Marco Date: Wed, 10 Nov 2021 15:14:55 +0100 Subject: [PATCH 7/9] update time calculation --- packages/taler-wallet-cli/src/bench1.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts index 3050d8a42..0e2f94f9f 100644 --- a/packages/taler-wallet-cli/src/bench1.ts +++ b/packages/taler-wallet-cli/src/bench1.ts @@ -65,7 +65,7 @@ export async function runBench1(configJson: any): Promise { await wallet.client.call(WalletApiOperation.InitWallet, {}); logger.trace(`Starting withdrawal amount=${withdrawAmount}`); - console.time('withdraw'); + let start = Date.now(); await wallet.client.call(WalletApiOperation.WithdrawFakebank, { amount: b1conf.currency + ":" + withdrawAmount, @@ -77,12 +77,12 @@ export async function runBench1(configJson: any): Promise { stopWhenDone: true, }); - logger.info(`Finished withdrawal amount=${withdrawAmount} time=${console.timeEnd('withdraw')}`); + logger.info(`Finished withdrawal amount=${withdrawAmount} time=${Date.now() - start}`); for (let i = 0; i < numDeposits; i++) { logger.trace(`Starting deposit amount=10`); - console.time('deposit') + start = Date.now() await wallet.client.call(WalletApiOperation.CreateDepositGroup, { amount: b1conf.currency + ":10", @@ -93,7 +93,7 @@ export async function runBench1(configJson: any): Promise { stopWhenDone: true, }); - logger.info(`Finished deposit amount=10 time=${console.timeEnd('deposit')}`); + logger.info(`Finished deposit amount=10 time=${Date.now() - start}`); } wallet.stop(); From ba198eab4a368b3a8dc2992e17e2b88ad377e287 Mon Sep 17 00:00:00 2001 From: Boss Marco Date: Fri, 12 Nov 2021 17:28:11 +0100 Subject: [PATCH 8/9] purge wallet after a specified amount of iterations --- packages/taler-wallet-cli/src/bench1.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts index 0e2f94f9f..f0db9761a 100644 --- a/packages/taler-wallet-cli/src/bench1.ts +++ b/packages/taler-wallet-cli/src/bench1.ts @@ -28,6 +28,7 @@ import { getDefaultNodeWallet, NodeHttpLib, WalletApiOperation, + Wallet, } from "@gnu-taler/taler-wallet-core"; /** @@ -48,20 +49,25 @@ export async function runBench1(configJson: any): Promise { const numIter = b1conf.iterations ?? 1; const numDeposits = b1conf.deposits ?? 5; + const restartWallet = b1conf.restartAfter ?? 20; const withdrawAmount = (numDeposits + 1) * 10; logger.info(`Starting Benchmark iterations=${numIter} deposits=${numDeposits}`); + let wallet = {} as Wallet; + for (let i = 0; i < numIter; i++) { // Create a new wallet in each iteration // otherwise the TPS go down // my assumption is that the in-memory db file gets too large - const wallet = await getDefaultNodeWallet({ - // No persistent DB storage. - persistentStoragePath: undefined, - httpLib: myHttpLib, - }); + if (i % restartWallet == 0) { + wallet = await getDefaultNodeWallet({ + // No persistent DB storage. + persistentStoragePath: undefined, + httpLib: myHttpLib, + }); + } await wallet.client.call(WalletApiOperation.InitWallet, {}); logger.trace(`Starting withdrawal amount=${withdrawAmount}`); @@ -128,6 +134,12 @@ interface Bench1Config { currency: string; deposits?: number; + + /** + * How any iterations run until the wallet db gets purged + * Defaults to 20. + */ + restartAfter?: number; } /** @@ -141,4 +153,5 @@ const codecForBench1Config = () => .property("iterations", codecOptional(codecForNumber())) .property("deposits", codecOptional(codecForNumber())) .property("currency", codecForString()) + .property("restartAfter", codecOptional(codecForNumber())) .build("Bench1Config"); From f8c0242f5306cccd52b0f9432b5acbb63fa38e08 Mon Sep 17 00:00:00 2001 From: Boss Marco Date: Sun, 14 Nov 2021 12:57:21 +0100 Subject: [PATCH 9/9] fix wallet.stop --- packages/taler-wallet-cli/src/bench1.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/taler-wallet-cli/src/bench1.ts b/packages/taler-wallet-cli/src/bench1.ts index f0db9761a..30ef8732f 100644 --- a/packages/taler-wallet-cli/src/bench1.ts +++ b/packages/taler-wallet-cli/src/bench1.ts @@ -62,13 +62,16 @@ export async function runBench1(configJson: any): Promise { // otherwise the TPS go down // my assumption is that the in-memory db file gets too large if (i % restartWallet == 0) { + if (Object.keys(wallet).length !== 0) { + wallet.stop(); + } wallet = await getDefaultNodeWallet({ // No persistent DB storage. persistentStoragePath: undefined, httpLib: myHttpLib, }); + await wallet.client.call(WalletApiOperation.InitWallet, {}); } - await wallet.client.call(WalletApiOperation.InitWallet, {}); logger.trace(`Starting withdrawal amount=${withdrawAmount}`); let start = Date.now(); @@ -101,8 +104,6 @@ export async function runBench1(configJson: any): Promise { logger.info(`Finished deposit amount=10 time=${Date.now() - start}`); } - - wallet.stop(); } }