1 Star 0 Fork 32

compile_success/gazelle_3

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0115-add-usleep-when-write_ring-is-busy.patch 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
吴昌盛 提交于 2022-11-04 10:27 . optimize ceph client performance
From 701e207702945705c0f8a94babf09d1fe8c2b3da Mon Sep 17 00:00:00 2001
From: wu-changsheng <wuchangsheng2@huawei.com>
Date: Mon, 31 Oct 2022 17:37:08 +0800
Subject: [PATCH 4/7] add usleep when write_ring is busy
---
src/lstack/core/lstack_lwip.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 00afc75..3a1eb81 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -282,16 +282,11 @@ ssize_t write_stack_data(struct lwip_sock *sock, const void *buf, size_t len)
GAZELLE_RETURN(ENOTCONN);
}
- uint32_t free_count = gazelle_ring_readable_count(sock->send_ring);
- if (free_count == 0) {
- return 0;
- }
-
struct pbuf *pbuf = NULL;
ssize_t send_len = 0;
uint32_t send_pkt = 0;
- while (send_len < len && send_pkt < free_count) {
+ while (send_len < len) {
if (sock->send_lastdata) {
pbuf = sock->send_lastdata;
} else {
@@ -322,6 +317,10 @@ ssize_t write_stack_data(struct lwip_sock *sock, const void *buf, size_t len)
sock->wakeup->stat.app_write_cnt += send_pkt;
}
+ if (send_len == 0) {
+ /* 100: give up cpu to other threads, when send_ring is full */
+ usleep(100);
+ }
return send_len;
}
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/compile_success/gazelle_3.git
git@gitee.com:compile_success/gazelle_3.git
compile_success
gazelle_3
gazelle_3
master

搜索帮助