summaryrefslogtreecommitdiff
path: root/shaping/src/shaper_stat.cpp
diff options
context:
space:
mode:
authorroot <[email protected]>2023-12-15 10:50:52 +0000
committerroot <[email protected]>2023-12-15 10:50:52 +0000
commit55c8ad6b4c439b29f681a8c5e604646f81b8a768 (patch)
tree3f04d8590b26c41bf735eb931865979a1c87f8f6 /shaping/src/shaper_stat.cpp
parent908b0f3a8e6a492b6ba185cda47beae3a5aef39d (diff)
global stat 由原子操作改为每个线程自己计数,每次输出时合并
Diffstat (limited to 'shaping/src/shaper_stat.cpp')
-rw-r--r--shaping/src/shaper_stat.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/shaping/src/shaper_stat.cpp b/shaping/src/shaper_stat.cpp
index e9cd3e6..d8895fa 100644
--- a/shaping/src/shaper_stat.cpp
+++ b/shaping/src/shaper_stat.cpp
@@ -136,18 +136,19 @@ static void shaper_stat_swarmkv_hincrby_cb(const struct swarmkv_reply *reply, vo
{
struct shaping_hincrby_cb_arg *arg = (struct shaping_hincrby_cb_arg *)cb_arg;
struct shaping_thread_ctx *ctx = arg->ctx;
+ struct shaping_global_stat *global_stat = ctx->ref_ctx->global_stat;
struct timespec curr_time;
long long curr_time_us;
clock_gettime(CLOCK_MONOTONIC, &curr_time);
curr_time_us = curr_time.tv_sec * MICRO_SECONDS_PER_SEC + curr_time.tv_nsec / NANO_SECONDS_PER_MICRO_SEC;
- shaper_global_stat_swarmkv_latency_update(ctx->global_stat, curr_time_us - arg->start_time_us);
+ shaper_global_stat_swarmkv_latency_update(global_stat, curr_time_us - arg->start_time_us);
- shaper_global_stat_async_callback_inc(ctx->global_stat);
- shaper_global_stat_hincrby_callback_inc(ctx->global_stat);
+ shaper_global_stat_async_callback_inc(&ctx->thread_global_stat);
+ shaper_global_stat_hincrby_callback_inc(&ctx->thread_global_stat);
if (reply->type != SWARMKV_REPLY_INTEGER) {
- shaper_global_stat_async_hincrby_failed_inc(ctx->global_stat);
+ shaper_global_stat_async_hincrby_failed_inc(&ctx->thread_global_stat);
}
free(cb_arg);
@@ -190,8 +191,8 @@ static void shaper_stat_profile_metirc_refresh(struct shaping_thread_ctx *ctx, i
clock_gettime(CLOCK_MONOTONIC, &curr_time);
arg->ctx = ctx;
arg->start_time_us = curr_time.tv_sec * MICRO_SECONDS_PER_SEC + curr_time.tv_nsec / NANO_SECONDS_PER_MICRO_SEC;
- shaper_global_stat_async_invoke_inc(ctx->global_stat);
- shaper_global_stat_hincrby_invoke_inc(ctx->global_stat);
+ shaper_global_stat_async_invoke_inc(&ctx->thread_global_stat);
+ shaper_global_stat_hincrby_invoke_inc(&ctx->thread_global_stat);
swarmkv_async_command(ctx->swarmkv_db, shaper_stat_swarmkv_hincrby_cb, arg, "HINCRBY tsg-shaping-%d priority-%d %lld", profile->id, profile->priority, profile_stat->in.queue_len + profile_stat->out.queue_len);
memset(profile_stat, 0, sizeof(struct shaping_stat_for_profile));