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