diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-08-11 11:29:45 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-08-11 11:29:45 +0200 |
commit | a1f289512eac8596bff88bbffc69c5a271324120 (patch) | |
tree | 78def1dcf1f9339d07c1825174aa405add872bca | |
parent | 96c2fb8e107451c6e26e37c55f0dcbf91cfefd28 (diff) |
make wirewatch batch size adaptive to transaction success/failure
-rw-r--r-- | src/benchmark/exchange_benchmark_home/.config/taler/account-2.json | 4 | ||||
-rw-r--r-- | src/exchange/taler-exchange-wirewatch.c | 21 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json b/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json index 43d46e3cf..b56d7c9cc 100644 --- a/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json +++ b/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json @@ -1,5 +1,5 @@ { "url": "payto://x-taler-bank/localhost:8082/2", - "salt": "B1902XWPRPR4K8MTNPQVRG3ZB7FV8967VTKAGPQ3XTJJEM46BHB7XDSQHRXB3287BCYQACHS59WY7QJQ7A7GMM981AGG1E32EHGB72R", - "master_sig": "NMNK7RQVXCH73MDQXQYRWP206VFNHAPV3CX8FPFZKFC3NGFD3ZVX6AK7F55TTADR2YNN3TB5TTZDS23MCBDC028DCXP44SFG4P3T22G" + "salt": "RJG7PDRM3YFFQ9YXHE5034R2HF9X68PQKC2W0CQWV4BQ50RYQT339GWN33601S53C3GGG35DG9C6479H4PGMZ9SVJ7A22RK99S4BN78", + "master_sig": "H9GKSPFDQVCP8NBW0X4ZMWEFHZGZNTWZETWRTMYK3831HYTDKWR7R5KY2YJ7XW6HNZ27Q9NXW2DGJWJ016WBK01AKWA6MRNFVPQ6G2G" }
\ No newline at end of file diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c index bfdf0529a..9f58b2890 100644 --- a/src/exchange/taler-exchange-wirewatch.c +++ b/src/exchange/taler-exchange-wirewatch.c @@ -166,6 +166,16 @@ static int test_mode; static int reset_mode; /** + * How many transactions do we retrieve per batch? + */ +static unsigned int batch_size = 1024; + +/** + * How many transactions did we see in the current batch? + */ +static unsigned int current_batch_size; + +/** * Next task to run, if any. */ static struct GNUNET_SCHEDULER_Task *task; @@ -407,6 +417,9 @@ history_cb (void *cls, /* do we need to rollback explicitly on commit failure!? */ db_plugin->rollback (db_plugin->cls, session); + /* reduce transaction size to reduce rollback probability */ + if (2 > current_batch_size) + current_batch_size /= 2; /* try again */ GNUNET_assert (NULL == task); task = GNUNET_SCHEDULER_add_now (&find_transfers, @@ -421,6 +434,10 @@ history_cb (void *cls, last_row_off_size = latest_row_off_size; latest_row_off = NULL; latest_row_off_size = 0; + + /* if successful at limit, try increasing transaction batch size (AIMD) */ + if (current_batch_size == batch_size) + batch_size++; } GNUNET_break (0 <= qs); if ( (GNUNET_YES == delay) && @@ -489,6 +506,7 @@ history_cb (void *cls, "Adding wire transfer over %s with subject `%s'\n", TALER_amount2s (&details->amount), TALER_B2S (&details->wtid)); + current_batch_size++; /* Wire transfer identifier == reserve public key */ GNUNET_assert (sizeof (reserve_pub) == sizeof (details->wtid)); memcpy (&reserve_pub, @@ -603,12 +621,13 @@ find_transfers (void *cls) ( (NULL != last_row_off) && (0 != last_row_off_size) ) ); delay = GNUNET_YES; + current_batch_size = 0; hh = wa_pos->wire_plugin->get_history (wa_pos->wire_plugin->cls, wa_pos->section_name, TALER_BANK_DIRECTION_CREDIT, last_row_off, last_row_off_size, - 1024, + batch_size, &history_cb, session); if (NULL == hh) |