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,86 +353,109 @@ 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);
struct TALER_TESTING_Command make_reserve[] = { for (unsigned int j = 0; j < howmany_reserves; j++)
CMD_TRANSFER_TO_EXCHANGE
("create-reserve",
TALER_amount_to_string (&total_reserve_amount)),
TALER_TESTING_cmd_end ()
};
all_commands[0] = TALER_TESTING_cmd_batch ("make-reserve",
make_reserve);
for (unsigned int i = 0; i < howmany_coins; i++)
{ {
char *withdraw_label; char *create_reserve_label;
char *order_enc;
struct TALER_TESTING_Command unit[UNITY_SIZE];
GNUNET_asprintf (&withdraw_label, GNUNET_asprintf (&create_reserve_label,
"withdraw-%u", "create-reserve-%u",
i); j);
GNUNET_asprintf (&order_enc, {
"{\"nonce\": %u}", struct TALER_TESTING_Command make_reserve[] = {
i); CMD_TRANSFER_TO_EXCHANGE
unit[0] = (create_reserve_label,
TALER_TESTING_cmd_withdraw_with_retry TALER_amount_to_string (&total_reserve_amount)),
(TALER_TESTING_cmd_withdraw_amount TALER_TESTING_cmd_end ()
(withdraw_label, };
is->exchange, char *batch_label;
"create-reserve",
AMOUNT_5, GNUNET_asprintf (&batch_label,
MHD_HTTP_OK)); "batch-start-%u",
unit[1] = TALER_TESTING_cmd_deposit j);
("deposit", all_commands[j * (howmany_coins + 1)]
is->exchange, = TALER_TESTING_cmd_batch (batch_label,
withdraw_label, make_reserve);
0, /* Index of the one withdrawn coin in the traits. */ }
TALER_TESTING_make_wire_details 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-%u",
i,
j);
GNUNET_asprintf (&order_enc,
"{\"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_label,
AMOUNT_5,
MHD_HTTP_OK));
unit[1] = TALER_TESTING_cmd_deposit
("deposit",
is->exchange,
withdraw_label,
0, /* Index of the one withdrawn coin in the traits. */
TALER_TESTING_make_wire_details
(USER_ACCOUNT_NUMBER, (USER_ACCOUNT_NUMBER,
exchange_bank_account.hostname), exchange_bank_account.hostname),
order_enc, order_enc,
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
AMOUNT_1, AMOUNT_1,
MHD_HTTP_OK);
if (eval_probability (REFRESH_PROBABILITY))
{
char *melt_label;
char *reveal_label;
GNUNET_asprintf (&melt_label,
"refresh-melt-%u",
i);
GNUNET_asprintf (&reveal_label,
"refresh-reveal-%u",
i);
unit[2] = TALER_TESTING_cmd_refresh_melt
(melt_label,
is->exchange,
AMOUNT_4,
withdraw_label,
MHD_HTTP_OK); MHD_HTTP_OK);
unit[3] = TALER_TESTING_cmd_refresh_reveal
(reveal_label, if (eval_probability (REFRESH_PROBABILITY))
is->exchange, {
melt_label, char *melt_label;
MHD_HTTP_OK); char *reveal_label;
unit[4] = TALER_TESTING_cmd_refresh_link
("refresh-link", GNUNET_asprintf (&melt_label,
is->exchange, "refresh-melt-%u-%u",
reveal_label, i,
MHD_HTTP_OK); j);
unit[5] = TALER_TESTING_cmd_end (); GNUNET_asprintf (&reveal_label,
"refresh-reveal-%u-%u",
i,
j);
unit[2] = TALER_TESTING_cmd_refresh_melt
(melt_label,
is->exchange,
AMOUNT_4,
withdraw_label,
MHD_HTTP_OK);
unit[3] = TALER_TESTING_cmd_refresh_reveal
(reveal_label,
is->exchange,
melt_label,
MHD_HTTP_OK);
unit[4] = TALER_TESTING_cmd_refresh_link
("refresh-link",
is->exchange,
reveal_label,
MHD_HTTP_OK);
unit[5] = TALER_TESTING_cmd_end ();
}
else
unit[2] = TALER_TESTING_cmd_end ();
GNUNET_asprintf (&unit_label,
"unit-%u-%u",
i,
j);
all_commands[j * (howmany_coins + 1) + (1 + i)]
= TALER_TESTING_cmd_batch (unit_label,
unit);
} }
else
unit[2] = TALER_TESTING_cmd_end ();
all_commands[1 + i] = TALER_TESTING_cmd_batch ("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;
} }