diff options
| author | 刘畅 <[email protected]> | 2023-10-17 09:24:08 +0000 |
|---|---|---|
| committer | 刘畅 <[email protected]> | 2023-10-17 09:24:08 +0000 |
| commit | 53c6bfd1ab307ecb8a6ec8e643172cda3c08afdc (patch) | |
| tree | 4c5ce57821a2d3345eb2c14000dcb67ec7cb5710 | |
| parent | 32d1ede9d57af683c942d5ab0ecd41b66a1efd56 (diff) | |
| parent | fc96d258c56ba5e48f5d6307ea7680cb77db82eb (diff) | |
Merge branch 'enable_jemalloc_gc_thread' into 'rel'v1.3.4
enable jemalloc backgroud gc thread
See merge request tango/shaping-engine!46
| -rw-r--r-- | conf/shaping.conf | 2 | ||||
| -rw-r--r-- | shaping/src/main.cpp | 9 | ||||
| -rw-r--r-- | shaping/src/shaper_stat.cpp | 3 | ||||
| -rw-r--r-- | shaping/test/gtest_shaper.cpp | 4 |
4 files changed, 13 insertions, 5 deletions
diff --git a/conf/shaping.conf b/conf/shaping.conf index 0fc74b7..986c468 100644 --- a/conf/shaping.conf +++ b/conf/shaping.conf @@ -30,7 +30,7 @@ SWARMKV_HEALTH_CHECK_PORT=0 SWARMKV_HEALTH_CHECK_ANNOUNCE_PORT=1111 [METRIC] -FIELDSTAT_OUTPUT_INTERVAL_MS=500 +FIELDSTAT_OUTPUT_INTERVAL_MS=1000 GLOBAL_STAT_OUTPUT_INTERVAL_S=1 LINE_PROTOCOL_SERVER_IP="127.0.0.1" LINE_PROTOCOL_SERVER_PORT=6667 diff --git a/shaping/src/main.cpp b/shaping/src/main.cpp index f9a38b2..8143bce 100644 --- a/shaping/src/main.cpp +++ b/shaping/src/main.cpp @@ -4,6 +4,7 @@ #include <unistd.h> #include <assert.h> #include <signal.h> +#include <jemalloc/jemalloc.h> #include "log.h" #include "utils.h" @@ -80,6 +81,14 @@ int main(int argc, char **argv) return -1; } + bool flag = true; + int ret = mallctl("background_thread", NULL, NULL, &flag, sizeof(flag)); + if (ret != 0) { + LOG_ERROR("%s: mallctl(background_thread) failed, ret %d", LOG_TAG_SHAPING, ret); + LOG_CLOSE(); + return -1; + } + ctx = shaping_engine_init(); if (!ctx) { return -1; diff --git a/shaping/src/shaper_stat.cpp b/shaping/src/shaper_stat.cpp index 6ede233..ef0cc75 100644 --- a/shaping/src/shaper_stat.cpp +++ b/shaping/src/shaper_stat.cpp @@ -15,7 +15,7 @@ #define SHAPER_STAT_ROW_NAME "traffic_shaping_rule_hits" -#define SHAPER_STAT_REFRESH_TIME_NS 200000000 //0.2s +#define SHAPER_STAT_REFRESH_TIME_NS 500000000 //0.5s struct shaper_stat_conf { int enable_backgroud_thread; @@ -205,7 +205,6 @@ void shaper_stat_refresh(struct shaping_thread_ctx *ctx, struct shaping_flow *sf clock_gettime(CLOCK_MONOTONIC, &curr_time); if (curr_time.tv_sec - sf->stat_update_time.tv_sec > 0 || curr_time.tv_nsec - sf->stat_update_time.tv_nsec > SHAPER_STAT_REFRESH_TIME_NS) { need_refresh = 1; - sf->stat_update_time = curr_time; memcpy(&sf->stat_update_time, &curr_time, sizeof(struct timespec)); } } diff --git a/shaping/test/gtest_shaper.cpp b/shaping/test/gtest_shaper.cpp index 252d5f5..41520aa 100644 --- a/shaping/test/gtest_shaper.cpp +++ b/shaping/test/gtest_shaper.cpp @@ -1361,7 +1361,7 @@ TEST(two_session_diff_priority_same_profile, session_timer_test) ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue)); sleep(3);//wait session timer to expire, to refresh priority queue_len to swarmkv - for (int i = 0; i < 200; i++) { + for (int i = 0; i < 500; i++) { stub_curr_time_inc(STUB_TIME_INC_FOR_PACKET);//inc time to refresh stat in timer } polling_entry(ctx->thread_ctx[0].sp, ctx->thread_ctx[0].stat, &ctx->thread_ctx[0]);//timer triggered in polling @@ -1384,7 +1384,7 @@ TEST(two_session_diff_priority_same_profile, session_timer_test) } sleep(3);//wait session timer to expire, to refresh priority queue_len to swarmkv - for (int i = 0; i < 200; i++) { + for (int i = 0; i < 500; i++) { stub_curr_time_inc(STUB_TIME_INC_FOR_PACKET);//inc time to refresh stat in timer } polling_entry(ctx->thread_ctx[0].sp, ctx->thread_ctx[0].stat, &ctx->thread_ctx[0]);//timer triggered in polling |
