Optimize networking (demo of concept) #1482

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
1 participant
@shenfeng

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.

Optimize networking (demo of 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 orignal path.
Benchmark shows, even under heavy load of redis-benchmark, the latter happens rarely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment