summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author刘畅 <[email protected]>2023-06-05 02:20:36 +0000
committer刘畅 <[email protected]>2023-06-05 02:20:36 +0000
commit038fb1788f3680a04f29c718f17c6cecc41449a2 (patch)
treeca887b4a07c755b99e6c5df7bad6830b3a6fe243
parent4e63a3a5cd61c1ff579864b03324163e26e1b515 (diff)
parent49b1128205177576fcb000474c6283184bbc44d1 (diff)
Merge branch 'bugfix-remove-borrow-latency' into 'rel'v1.2.1
don't calculate latency for borrow profile See merge request tango/shaping-engine!25
-rw-r--r--shaping/src/shaper.cpp21
-rw-r--r--shaping/src/shaper_global_stat.cpp1
-rw-r--r--shaping/test/gtest_shaper.cpp12
3 files changed, 18 insertions, 16 deletions
diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp
index 6ca182d..0943932 100644
--- a/shaping/src/shaper.cpp
+++ b/shaping/src/shaper.cpp
@@ -281,11 +281,10 @@ int shaper_flow_push(struct shaping_thread_ctx *ctx, struct shaping_flow *sf, un
swarmkv_async_command(ctx->swarmkv_db, swarmkv_reply_cb_do_nothing, ctx->global_stat, "HINCRBY tsg-shaping-%d priority-%d 1", s_rule_info->primary.id, priority);
}
shaper_stat_queueing_pkt_inc(&s_rule_info->primary.stat, pkt_wrapper->direction, ctx->thread_index);
- s_rule_info->primary.enqueue_time_us = enqueue_time;
}
if (s_rule_info->borrowing_num == 0) {// no borrow profile
- return ret;
+ goto END;
}
for (i = 0; i < s_rule_info->borrowing_num; i++) {
@@ -297,10 +296,14 @@ int shaper_flow_push(struct shaping_thread_ctx *ctx, struct shaping_flow *sf, un
shaper_global_stat_async_invoke_inc(ctx->global_stat);
swarmkv_async_command(ctx->swarmkv_db, swarmkv_reply_cb_do_nothing, ctx->global_stat, "HINCRBY tsg-shaping-%d priority-%d 1", s_rule_info->borrowing[i].id, priority);
}
- s_rule_info->borrowing[i].enqueue_time_us = enqueue_time;
}
}
+END:
+ if (ret == 0) {//all avl tree success
+ s_rule_info->primary.enqueue_time_us = enqueue_time;
+ }
+
return ret;
}
@@ -338,13 +341,10 @@ void shaper_flow_pop(struct shaping_thread_ctx *ctx, struct shaping_flow *sf)
}
shaper_stat_queueing_pkt_dec(&s_rule_info->primary.stat, pkt_wrapper->direction, ctx->thread_index);
-
- latency = shaper_pkt_latency_calculate(&s_rule_info->primary, &curr_time);
- shaper_stat_max_latency_update(&s_rule_info->primary.stat, pkt_wrapper->direction, latency, ctx->thread_index);
}
if (s_rule_info->borrowing_num == 0) {
- return;
+ goto END;
}
for (i = 0; i < s_rule_info->borrowing_num; i++) {
@@ -355,12 +355,13 @@ void shaper_flow_pop(struct shaping_thread_ctx *ctx, struct shaping_flow *sf)
shaper_global_stat_async_invoke_inc(ctx->global_stat);
swarmkv_async_command(ctx->swarmkv_db, swarmkv_reply_cb_do_nothing, ctx->global_stat, "HINCRBY tsg-shaping-%d priority-%d -1", s_rule_info->borrowing[i].id, priority);
}
-
- latency = shaper_pkt_latency_calculate(&s_rule_info->borrowing[i], &curr_time);
- shaper_stat_max_latency_update(&s_rule_info->borrowing[i].stat, pkt_wrapper->direction, latency, ctx->thread_index);
}
}
+END:
+ latency = shaper_pkt_latency_calculate(&s_rule_info->primary, &curr_time);
+ shaper_stat_max_latency_update(&s_rule_info->primary.stat, pkt_wrapper->direction, latency, ctx->thread_index);
+
return;
}
diff --git a/shaping/src/shaper_global_stat.cpp b/shaping/src/shaper_global_stat.cpp
index 75dbc8b..11f44e1 100644
--- a/shaping/src/shaper_global_stat.cpp
+++ b/shaping/src/shaper_global_stat.cpp
@@ -60,7 +60,6 @@ struct shaping_global_stat* shaper_global_stat_init()
{
struct shaping_global_stat *stat = NULL;
struct shaping_global_stat_conf conf;
- int column_num;
stat = (struct shaping_global_stat*)calloc(1, sizeof(struct shaping_global_stat));
diff --git a/shaping/test/gtest_shaper.cpp b/shaping/test/gtest_shaper.cpp
index f97591b..a1a9b77 100644
--- a/shaping/test/gtest_shaper.cpp
+++ b/shaping/test/gtest_shaper.cpp
@@ -607,7 +607,7 @@ TEST(single_session, udp_borrow)
shaping_stat_judge(line, 1, 1, 1, 0, 0, 0, 0, 170, SHAPING_DIR_OUT, profile_type_primary);
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 2, borrow
- shaping_stat_judge(line, 1, 2, 2, 100, 10000, 0, 0, 170, SHAPING_DIR_OUT, profile_type_borrow);
+ shaping_stat_judge(line, 1, 2, 2, 100, 10000, 0, 0, 0, SHAPING_DIR_OUT, profile_type_borrow);
fclose(stat_file);
stat_file = fopen(SHAPING_STAT_FILE_NAME, "w");//clear stat file
@@ -681,11 +681,13 @@ TEST(single_session, udp_borrow_same_priority_9)
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 1, primary
shaping_stat_judge(line, 1, 1, 9, 0, 0, 0, 0, 170, SHAPING_DIR_OUT, profile_type_primary);
+#if 0 //fieldstat don't output a row when all values is zero
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 2, borrow
- shaping_stat_judge(line, 1, 2, 9, 0, 0, 0, 0, 170, SHAPING_DIR_OUT, profile_type_borrow);
+ shaping_stat_judge(line, 1, 2, 9, 0, 0, 0, 0, 0, SHAPING_DIR_OUT, profile_type_borrow);
+#endif
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 3, borrow
- shaping_stat_judge(line, 1, 3, 9, 100, 10000, 0, 0, 170, SHAPING_DIR_OUT, profile_type_borrow);
+ shaping_stat_judge(line, 1, 3, 9, 100, 10000, 0, 0, 0, SHAPING_DIR_OUT, profile_type_borrow);
fclose(stat_file);
stat_file = fopen(SHAPING_STAT_FILE_NAME, "w");//clear stat file
@@ -1168,7 +1170,7 @@ TEST(two_session_diff_priority_same_profile, udp_borrow_in_order)
shaping_stat_judge(line, 1, 1, 1, 0, 0, 0, 0, 470, SHAPING_DIR_OUT, profile_type_primary);
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 2, borrow
- shaping_stat_judge(line, 1, 2, 2, 100, 10000, 0, 0, 470, SHAPING_DIR_OUT, profile_type_borrow);
+ shaping_stat_judge(line, 1, 2, 2, 100, 10000, 0, 0, 0, SHAPING_DIR_OUT, profile_type_borrow);
ASSERT_TRUE(NULL != fgets(line, sizeof(line), stat_file));//profile_id 2, primary
shaping_stat_judge(line, 2, 2, 1, 100, 10000, 0, 0, 190, SHAPING_DIR_OUT, profile_type_primary);
@@ -1638,6 +1640,6 @@ TEST(statistics, udp_queueing_pkt)
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
- //testing::GTEST_FLAG(filter) = "statistics.udp_queueing_pkt";
+ //testing::GTEST_FLAG(filter) = "single_session.udp_borrow_same_priority_9";
return RUN_ALL_TESTS();
} \ No newline at end of file