Skip to content

Commit

Permalink
Adding additional logging (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
rccarper authored Mar 1, 2021
1 parent 2cd5c53 commit 708eeeb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/aws/s3/s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum aws_s3_errors {
enum aws_s3_subject {
AWS_LS_S3_GENERAL = AWS_LOG_SUBJECT_BEGIN_RANGE(AWS_C_S3_PACKAGE_ID),
AWS_LS_S3_CLIENT,
AWS_LS_S3_CLIENT_STATS,
AWS_LS_S3_REQUEST,
AWS_LS_S3_META_REQUEST,
AWS_LS_S3_VIP,
Expand Down
4 changes: 4 additions & 0 deletions source/s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ static struct aws_error_info_list s_error_list = {
static struct aws_log_subject_info s_s3_log_subject_infos[] = {
DEFINE_LOG_SUBJECT_INFO(AWS_LS_S3_GENERAL, "S3General", "Subject for aws-c-s3 logging that defies categorization."),
DEFINE_LOG_SUBJECT_INFO(AWS_LS_S3_CLIENT, "S3Client", "Subject for aws-c-s3 logging from an aws_s3_client."),
DEFINE_LOG_SUBJECT_INFO(
AWS_LS_S3_CLIENT_STATS,
"S3ClientStats",
"Subject for aws-c-s3 logging for stats tracked by an aws_s3_client."),
DEFINE_LOG_SUBJECT_INFO(AWS_LS_S3_REQUEST, "S3Request", "Subject for aws-c-s3 logging from an aws_s3_request."),
DEFINE_LOG_SUBJECT_INFO(
AWS_LS_S3_META_REQUEST,
Expand Down
29 changes: 24 additions & 5 deletions source/s3_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct aws_s3_meta_request_work {
struct aws_s3_meta_request *meta_request;
};

static const bool s_log_client_stats = false;
static const enum aws_log_level s_log_level_client_stats = AWS_LL_INFO;

static const uint32_t s_s3_max_request_count_per_connection = 100;
Expand Down Expand Up @@ -1200,6 +1199,10 @@ static void s_s3_client_process_work_default(struct aws_s3_client *client) {
/*******************/
/* Step 1: Move everything into thread local memory. */
/*******************/
AWS_LOGF_DEBUG(
AWS_LS_S3_CLIENT,
"id=%p s_s3_client_process_work_default - Moving relevant synced_data into threaded_data.",
(void *)client);
aws_s3_client_lock_synced_data(client);

client_active = client->synced_data.active != 0;
Expand All @@ -1222,6 +1225,9 @@ static void s_s3_client_process_work_default(struct aws_s3_client *client) {
/*******************/
/* Step 2: Process any meta request work. */
/*******************/
AWS_LOGF_DEBUG(
AWS_LS_S3_CLIENT, "id=%p s_s3_client_process_work_default - Processing any new meta requests.", (void *)client);

while (!aws_linked_list_empty(&meta_request_work_list)) {
struct aws_linked_list_node *node = aws_linked_list_pop_back(&meta_request_work_list);
struct aws_s3_meta_request_work *meta_request_work =
Expand All @@ -1248,6 +1254,11 @@ static void s_s3_client_process_work_default(struct aws_s3_client *client) {
/* If we have an invalid endpoint, then finish up all of the meta requests. */
/* TODO once we have multiple bucket support, this will should only stop meta requests attached to bad endpoints. */
if (invalid_endpoint) {
AWS_LOGF_DEBUG(
AWS_LS_S3_CLIENT,
"id=%p s_s3_client_process_work_default - Updating meta requests with 'no-endpoint-connections' flag.",
(void *)client);

while (!aws_linked_list_empty(&client->threaded_data.meta_requests)) {
struct aws_linked_list_node *node = aws_linked_list_begin(&client->threaded_data.meta_requests);
struct aws_s3_meta_request *meta_request =
Expand All @@ -1273,14 +1284,22 @@ static void s_s3_client_process_work_default(struct aws_s3_client *client) {
/* We first assign requests to connections with the "conservative" flag. This will tell each meta request that
* connections can still potentially be shared between meta requests. (ie: an individual meta request shouldn't
* necessarily try to issue as many requests as it can, unless it's known that that won't impact performance.) */
AWS_LOGF_DEBUG(
AWS_LS_S3_CLIENT,
"id=%p s_s3_client_process_work_default - Updating meta requests and connections with 'conservative' flag.",
(void *)client);
s_s3_client_assign_requests_to_connections_threaded(
client, client_active, AWS_S3_META_REQUEST_UPDATE_FLAG_CONSERVATIVE);

/* If we still have connections left over, then don't pass any flags, indicating to meta requests that any logic for
* better sharing connections between meta requests can now be ignored. */
AWS_LOGF_DEBUG(
AWS_LS_S3_CLIENT,
"id=%p s_s3_client_process_work_default - Updating meta requests and connections without 'conservative' flag.",
(void *)client);
s_s3_client_assign_requests_to_connections_threaded(client, client_active, 0);

if (s_log_client_stats) {
{
uint32_t num_idle_connections = 0;

for (struct aws_linked_list_node *node = aws_linked_list_begin(&client->threaded_data.idle_vip_connections);
Expand All @@ -1300,9 +1319,9 @@ static void s_s3_client_process_work_default(struct aws_s3_client *client) {

AWS_LOGF(
s_log_level_client_stats,
AWS_LS_S3_CLIENT,
"CLIENT-STATS-LOGGING Requests-in-flight(approx/exact):%d/%d Requests-network:%d Requests-waiting:%d "
"Requests-streaming:%d Idle-connections:%d Allocated-connections:%d Active-connections:%d",
AWS_LS_S3_CLIENT_STATS,
"Requests-in-flight(approx/exact):%d/%d Requests-network:%d Requests-waiting:%d Requests-streaming:%d "
"Idle-connections:%d Allocated-connections:%d Active-connections:%d",
total_approx_requests,
client->threaded_data.num_requests_in_flight,
num_requests_network_io,
Expand Down

0 comments on commit 708eeeb

Please sign in to comment.