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

Optimize networking (demo of concept) #1482

Closed
wants to merge 1 commit into from

Conversation

shenfeng
Copy link

Hi, this is a demo of concept, use code to discuss the concept.

When we have content need to be written to TCP buffer, instead of

  1. register AE_WRITABLE event
  2. get notified that the TCP buffer has space
  3. write the buffer
  4. deregister‎ AE_WRITABLE event

We can first try 3, if all the content get copied to TCP buffer, then we save at least 2 system calls. If not, follow the original path.
Benchmark shows, even under heavy load of redis-benchmark, the latter happens rarely. So, most of the time, we can save two system call(two epoll_ctl on linux, which is O(n)), and less latency, since we do not need to wait until the next round, aeProcessEvents get called.

Only commands handing modified, we may need to modify replication logic too.

With this patch, /src/redis-benchmark -t get -n 500000 can get 2%-3% faster.
You can see from a profile without the patch, epoll_ctl cost ~8% of the CPU time.

When we have content need to be written to TCP buffer, instead of

1. register AE_WRITABLE event
2. get notified that the TCP buffer has space
3. write the buffer
4. deregister‎ AE_WRITABLE event

We can first try 3, if all the content get copied to TCP buffer, then we save at least 2 system calls. If not, follow the orignal path.
Benchmark shows, even under heavy load of redis-benchmark, the latter happens rarely.
Copy link
Collaborator

@enjoy-binbin enjoy-binbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, it is a good idea, and it is handled in 1c7d87d, so i am closing it

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 this pull request may close these issues.

None yet

2 participants