Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: 3928453 Improve buffer pools statistics and report #131

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -1059,9 +1059,9 @@ Note that usage of Mutex might increase latency.
Default: 0 (Spin)

XLIO_PRINT_REPORT
Print a report in human readable format in case of runtime errors. The report is
printed during termination phase. It can be missed if the process is killed with
SIGKILL signal.
Print a human readable report of resources usage at exit. The report is printed
during termination phase. Therefore, It can be missed if the process is killed
with the SIGKILL signal.
Default: 0 (Disabled)

XLIO Monitoring & Performance Counters
Expand Down
24 changes: 9 additions & 15 deletions src/core/dev/buffer_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ bool buffer_pool::expand(size_t count)
}
}
m_n_buffers_created += count;
m_p_bpool_stat->n_buffer_pool_created = m_n_buffers_created;
return true;
}

Expand Down Expand Up @@ -216,37 +217,30 @@ void buffer_pool::print_report(vlog_levels_t log_level /*=VLOG_DEBUG*/)
vlog_printf(log_level, "Buffer pool %p (%s%s):\n", this, m_p_bpool_stat->is_rx ? "Rx" : "Tx",
m_buf_size ? "" : ", zcopy");
vlog_printf(log_level, " Buffers: %zu created, %zu free\n", m_n_buffers_created, m_n_buffers);
vlog_printf(log_level, " Memory consumption: %s (%s per buffer)\n",
vlog_printf(log_level, " Memory consumption: %s (%s per buffer), expanded %u times\n",
option_size::to_str(m_buf_size * m_n_buffers_created, str1, sizeof(str1)),
option_size::to_str(m_buf_size, str2, sizeof(str2)));
option_size::to_str(m_buf_size, str2, sizeof(str2)),
m_p_bpool_stat->n_buffer_pool_expands);
vlog_printf(log_level, " Requests: %u unsatisfied buffer requests\n",
m_p_bpool_stat->n_buffer_pool_no_bufs);
}

/* static */
void buffer_pool::print_report_on_errors(vlog_levels_t log_level)
void buffer_pool::print_full_report(vlog_levels_t log_level)
{
std::vector<buffer_pool *> pools = {g_buffer_pool_rx_rwqe, g_buffer_pool_rx_stride,
g_buffer_pool_tx, g_buffer_pool_zc};
bool do_print = false;
bool is_error = false;

for (auto &pool : pools) {
if (pool->m_p_bpool_stat->n_buffer_pool_no_bufs) {
do_print = true;
break;
}
is_error = is_error || pool->m_p_bpool_stat->n_buffer_pool_no_bufs;
pool->print_report(log_level);
}

if (do_print) {
if (is_error) {
vlog_printf(log_level,
"XLIO detected insufficient memory. Increasing XLIO_MEMORY_LIMIT can improve "
"performance.\n");
for (auto &pool : pools) {
// Print report for every non-zcopy buffer pool and zcopy pools with errors.
if (pool->m_buf_size || pool->m_p_bpool_stat->n_buffer_pool_no_bufs) {
pool->print_report(log_level);
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/dev/buffer_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class buffer_pool {
void register_memory(ib_ctx_handler *p_ib_ctx_h);
void print_val_tbl();
void print_report(vlog_levels_t log_level = VLOG_DEBUG);
static void print_report_on_errors(vlog_levels_t log_level);
static void print_full_report(vlog_levels_t log_level);

uint32_t find_lkey_by_ib_ctx_thread_safe(ib_ctx_handler *p_ib_ctx_h);

Expand Down
2 changes: 1 addition & 1 deletion src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static int free_libxlio_resources()
g_socketxtreme_ec_pool = NULL;

if (safe_mce_sys().print_report) {
buffer_pool::print_report_on_errors(VLOG_INFO);
buffer_pool::print_full_report(VLOG_INFO);
}

if (g_buffer_pool_zc) {
Expand Down
1 change: 1 addition & 0 deletions src/core/util/xlio_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ typedef struct {
uint32_t n_buffer_pool_size;
uint32_t n_buffer_pool_no_bufs;
uint32_t n_buffer_pool_expands;
uint32_t n_buffer_pool_created;
} bpool_stats_t;

typedef struct {
Expand Down
2 changes: 2 additions & 0 deletions src/stats/stats_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ void print_bpool_stats(bpool_instance_block_t *p_bpool_inst_arr)
printf("\tBUFFER_POOL=[%u]\n", i);
}
printf(FORMAT_STATS_32bit, "Size:", p_bpool_stats->n_buffer_pool_size);
printf(FORMAT_STATS_32bit, "Buffers in use:",
p_bpool_stats->n_buffer_pool_created - p_bpool_stats->n_buffer_pool_size);
printf(FORMAT_STATS_32bit, "No buffers error:", p_bpool_stats->n_buffer_pool_no_bufs);
if (p_bpool_stats->n_buffer_pool_expands) {
printf(FORMAT_STATS_32bit, "Expands:", p_bpool_stats->n_buffer_pool_expands);
Expand Down