diff options
| author | Qiuwen Lu <[email protected]> | 2020-07-13 17:13:23 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2020-07-13 17:13:23 +0800 |
| commit | d88306ecbe19ac393ef8206f8cdbb64b022c8c05 (patch) | |
| tree | 0d8700f5eb252c55233e755f530933416274161c /tunnat | |
| parent | 29189285e1261a0be8bcb1b037b1e0cec91f68e3 (diff) | |
提供send_burst_flush接口,避免开启burst后小流量情况下报文在发送队列内堆积导致的延迟提高。v4.3.25-20200714
Diffstat (limited to 'tunnat')
| -rw-r--r-- | tunnat/include/tunnat.h | 6 | ||||
| -rw-r--r-- | tunnat/src/core.cc | 5 | ||||
| -rw-r--r-- | tunnat/src/runtime.cc | 15 |
3 files changed, 25 insertions, 1 deletions
diff --git a/tunnat/include/tunnat.h b/tunnat/include/tunnat.h index 17a322f..a104768 100644 --- a/tunnat/include/tunnat.h +++ b/tunnat/include/tunnat.h @@ -59,6 +59,10 @@ struct TunnatThreadInstance; #define MR_TUNNAT_DEFAULT_SESSION_EXPIRE_TIME 0 #endif +#ifndef MR_TUNNAT_DEFAULT_IDLE_POLL_THRESHOLD +#define MR_TUNNAT_DEFAULT_IDLE_POLL_THRESHOLD 1000000 +#endif + enum bridge_mode { MR_TUNNAT_BRIDGE_MODE_DISABLE, @@ -91,6 +95,8 @@ struct TunnatInstance unsigned int nr_burst{MR_TUNNAT_DEFAULT_NR_BURST}; /* 运行数据面线程核心掩码 */ cpu_set_t coremask{}; + /* IDLE POLL Threshold */ + unsigned int idle_threshold{MR_TUNNAT_DEFAULT_IDLE_POLL_THRESHOLD}; /* 会话表使用四元组还是二元组 */ unsigned int sess_tb_order_by_tuple4{MR_TUNNAT_DEFAULT_SESSION_TUPLE4}; diff --git a/tunnat/src/core.cc b/tunnat/src/core.cc index 0588f44..1999d96 100644 --- a/tunnat/src/core.cc +++ b/tunnat/src/core.cc @@ -340,6 +340,11 @@ int tunnat_mrinstance_setup(TunnatInstance * instance) } instance->mr_instance = _mr_instance; + + // Idle threshold + MESA_load_profile_uint_def(instance->cfgfile.c_str(), "tunnat", "idle_threshold", + &instance->idle_threshold, MR_TUNNAT_DEFAULT_IDLE_POLL_THRESHOLD); + return RT_SUCCESS; } diff --git a/tunnat/src/runtime.cc b/tunnat/src/runtime.cc index cb0c7ae..6055d1a 100644 --- a/tunnat/src/runtime.cc +++ b/tunnat/src/runtime.cc @@ -705,11 +705,24 @@ void * tunnat_thread_loop(void * arg) auto & virtdev = instance->virtdevs[0]; auto & phydev = instance->phydevs[0]; + /* Idle Counter*/ + unsigned long idle_counter = 0; + while (g_keep_running) { __phy_to_virt_one_device(instance, th_instance, &phydev, &virtdev); __virt_to_phy_one_device(instance, th_instance, &phydev, &virtdev); + + if(likely(instance->idle_threshold > 0) && + unlikely(idle_counter >= instance->idle_threshold)) + { + marsio_send_burst_flush(virtdev.vdev_sendpath, th_instance->thread_id); + marsio_send_burst_flush(phydev.vdev_sendpath, th_instance->thread_id); + idle_counter = 0; + } + + idle_counter++; } - return 0; + return (void *)nullptr; } |
