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

Pika Network Framework Optimization #2725

Closed
baixin01 opened this issue Jun 13, 2024 · 0 comments
Closed

Pika Network Framework Optimization #2725

baixin01 opened this issue Jun 13, 2024 · 0 comments
Labels
3.5.5 4.0.0 ✏️ Feature New feature or request

Comments

@baixin01
Copy link
Collaborator

Which PikiwiDB functionalities are relevant/related to the feature request?

No response

Description

Pika处理单个客户端请求流程:
1.WorkerThread负责处理客户端请求。客户端往pika写数据,触发读事件。
当read_status为kReadAll,则一次完整的请求被读取,会先把这个请求fd的读写事件给删除:
截屏2024-06-13 15 20 22
2.请求会交由工作线程池ThreadPool处理,处理完后。调用TryWriteResp:设置reply;同时调用NotifyEpoll(true):设置状态为kNotiEpolloutAndEpollin ,通知WorkerThread处理该状态。
截屏2024-06-13 15 44 04
截屏2024-06-13 15 41 02
3.WorkerThread此时将该请求fd的读写事件重新注册,此时处理客户端的返回/读取下一条命令。
截屏2024-06-13 15 41 02
在一次命令读取结束后,把连接fd的读写事件从epoll里面删除了。命令处理结束后又把读写事件加回来了。
因为pika用的是异步处理,一个连接的命令是异步地交给线程池处理,如果同个连接发了2个命令,因为是异步处理,没有办法保证2个命令满足FIFO,即先来的命令需要先回复,后来的命令后回复。pika是多线程异步处理,所以这里在读取了第一个命令后,把连接的读写事件删除了,等前一个命令处理完了才加回来,读取第二个命令来处理。
更详细的流程见:https://www.cnblogs.com/sigma0-/p/12828226.html

Proposed solution

性能提升验证:不删除读写事件,验证性能是否提升。
优化:设置一个队列,对同一个客户端请求编号,发送异步并发请求。将请求流程异步化。

Alternatives considered

暂无

@baixin01 baixin01 added ✏️ Feature New feature or request 4.0.0 3.5.5 labels Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.5.5 4.0.0 ✏️ Feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants