add multi-reserve support, improve load balancing by not reusing connections in benchmark

This commit is contained in:
Christian Grothoff 2018-08-11 02:48:49 +02:00
parent 9162b28b0a
commit 2637c1b682
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -122,10 +122,15 @@ static struct GNUNET_TIME_Relative duration;
static unsigned int result;
/**
* How many coins we want to create.
* How many coins we want to create per client and reserve.
*/
static unsigned int howmany_coins = 1;
/**
* How many reserves we want to create per client.
*/
static unsigned int howmany_reserves = 1;
/**
* How many clients we want to create.
*/
@ -324,8 +329,8 @@ run (void *cls,
struct TALER_Amount withdraw_fee;
char *withdraw_fee_str;
struct TALER_TESTING_Command all_commands
[1 + /* Withdraw block */
howmany_coins + /* All units */
[howmany_reserves * (1 + /* Withdraw block */
howmany_coins) + /* All units */
1 /* End CMD */];
ALLOCATE_AMOUNTS
@ -348,33 +353,49 @@ run (void *cls,
TALER_amount_add (&total_reserve_amount,
&total_reserve_amount,
&withdraw_fee);
for (unsigned int j = 0; j < howmany_reserves; j++)
{
char *create_reserve_label;
GNUNET_asprintf (&create_reserve_label,
"create-reserve-%u",
j);
{
struct TALER_TESTING_Command make_reserve[] = {
CMD_TRANSFER_TO_EXCHANGE
("create-reserve",
(create_reserve_label,
TALER_amount_to_string (&total_reserve_amount)),
TALER_TESTING_cmd_end ()
};
char *batch_label;
all_commands[0] = TALER_TESTING_cmd_batch ("make-reserve",
GNUNET_asprintf (&batch_label,
"batch-start-%u",
j);
all_commands[j * (howmany_coins + 1)]
= TALER_TESTING_cmd_batch (batch_label,
make_reserve);
}
for (unsigned int i = 0; i < howmany_coins; i++)
{
char *withdraw_label;
char *order_enc;
struct TALER_TESTING_Command unit[UNITY_SIZE];
char *unit_label;
GNUNET_asprintf (&withdraw_label,
"withdraw-%u",
i);
"withdraw-%u-%u",
i,
j);
GNUNET_asprintf (&order_enc,
"{\"nonce\": %u}",
i);
"{\"nonce\": %llu}",
i + (howmany_coins * j));
unit[0] =
TALER_TESTING_cmd_withdraw_with_retry
(TALER_TESTING_cmd_withdraw_amount
(withdraw_label,
is->exchange,
"create-reserve",
create_reserve_label,
AMOUNT_5,
MHD_HTTP_OK));
unit[1] = TALER_TESTING_cmd_deposit
@ -396,13 +417,13 @@ run (void *cls,
char *reveal_label;
GNUNET_asprintf (&melt_label,
"refresh-melt-%u",
i);
"refresh-melt-%u-%u",
i,
j);
GNUNET_asprintf (&reveal_label,
"refresh-reveal-%u",
i);
"refresh-reveal-%u-%u",
i,
j);
unit[2] = TALER_TESTING_cmd_refresh_melt
(melt_label,
is->exchange,
@ -424,10 +445,17 @@ run (void *cls,
else
unit[2] = TALER_TESTING_cmd_end ();
all_commands[1 + i] = TALER_TESTING_cmd_batch ("unit",
GNUNET_asprintf (&unit_label,
"unit-%u-%u",
i,
j);
all_commands[j * (howmany_coins + 1) + (1 + i)]
= TALER_TESTING_cmd_batch (unit_label,
unit);
}
all_commands[1 + howmany_coins] = TALER_TESTING_cmd_end ();
}
all_commands[howmany_reserves * (1 + howmany_coins)]
= TALER_TESTING_cmd_end ();
TALER_TESTING_run2 (is,
all_commands,
GNUNET_TIME_UNIT_FOREVER_REL); /* no timeout */
@ -529,6 +557,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
"taler-exchange-httpd",
"-c", config_file,
"-i",
"-C",
NULL);
if (NULL == exchanged)
{
@ -674,13 +703,18 @@ main (int argc,
GNUNET_GETOPT_option_uint ('n',
"coins-number",
"CN",
"How many coins we should instantiate",
"How many coins we should instantiate per reserve",
&howmany_coins),
GNUNET_GETOPT_option_uint ('p',
"parallelism",
"NPROCS",
"How many client processes we should run",
&howmany_clients),
GNUNET_GETOPT_option_uint ('r',
"reserves",
"NRESERVES",
"How many reserves per client we should create",
&howmany_reserves),
GNUNET_GETOPT_option_string ('l',
"logfile",
"LF",
@ -785,10 +819,11 @@ main (int argc,
if (GNUNET_OK == result)
{
fprintf (stdout,
"Executed (W=%u, D=%u, R~=%5.2f) * P=%u, operations in %s\n",
"Executed (Withdraw=%u, Deposit=%u, Refresh~=%5.2f) * Reserve=%u * Parallel=%u, operations in %s\n",
howmany_coins,
howmany_coins,
(float) howmany_coins * REFRESH_PROBABILITY,
howmany_reserves,
howmany_clients,
GNUNET_STRINGS_relative_time_to_string
(duration,
@ -797,8 +832,16 @@ main (int argc,
"(approximately %s/coin)\n",
GNUNET_STRINGS_relative_time_to_string
(GNUNET_TIME_relative_divide (duration,
howmany_coins * howmany_clients),
(unsigned long long) howmany_coins *
howmany_reserves *
howmany_clients),
GNUNET_YES));
fprintf (stdout,
"RAW: %04u %04u %04u %16llu\n",
howmany_coins,
howmany_reserves,
howmany_clients,
(unsigned long long) duration.rel_value_us);
}
return (GNUNET_OK == result) ? 0 : result;
}