Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否可以直接执行Socket::StartWrite里的KeepWrite? #2588

Open
xybanpeng opened this issue Apr 1, 2024 · 9 comments · May be fixed by #2591
Open

是否可以直接执行Socket::StartWrite里的KeepWrite? #2588

xybanpeng opened this issue Apr 1, 2024 · 9 comments · May be fixed by #2591

Comments

@xybanpeng
Copy link

image
Socket::StartWrite里的KeepWrite,是不是可以直接调用,不需要起后台bthread。当前session的response已经返回了,直接用当前bthread执行排队的response就可以,不然在压力比较大的时候等其他worker去执行这个bthead,延迟会增加很多

@wwbmmm
Copy link
Contributor

wwbmmm commented Apr 2, 2024

如果直接在当前bthread执行KeepWrite,可能会阻塞异步rpc的CallMethod调用。

@xybanpeng
Copy link
Author

如果直接在当前bthread执行KeepWrite,可能会阻塞异步rpc的CallMethod调用。

baidu_rpc_protocol.cpp SendRpcResponse调用socket write的时候,在参数里加个标识是不是可行?
baidu_rpc_protocol.cpp:
image
socket.cpp:
image

@chenBright
Copy link
Contributor

这样也会影响服务端异步rpc响应吧。Socket::StartWrite里直接调用KeepWrite,会导致Write阻塞,不太合理吧。

加个参数,支持使用bthread_start_urgent原地执行KeepWrite,应该能满足需求。

@xybanpeng
Copy link
Author

这样也会影响服务端异步rpc响应吧。Socket::StartWrite里直接调用KeepWrite,会导致Write阻塞,不太合理吧。

加个参数,支持使用bthread_start_urgent原地执行KeepWrite,应该能满足需求。

当前请求的response已经返回了,client端应该是已经结束了。Write阻塞指的是什么?

@chenBright
Copy link
Contributor

单纯从Socket::Write接口看就是有可能会阻塞吧。

@xybanpeng
Copy link
Author

单纯从Socket::Write接口看就是有可能会阻塞吧。

只有baidu_rpc_protocol.cpp SendRpcResponse调用Socket::Write的时候才会在执行完之后去处理队列里的消息,默认都是使用bthread_start_background

@chenBright
Copy link
Contributor

用bthread_start_urgent效果差不多,但是影响更小?

@xybanpeng
Copy link
Author

用bthread_start_urgent效果差不多,但是影响更小?

效果应该差不多

@chenBright chenBright linked a pull request Apr 6, 2024 that will close this issue
@chenBright
Copy link
Contributor

@xybanpeng 可以使用 #2591 测试一下优化效果

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants