A Redis clone written in C/C++ from scratch. Practice makes perfect!
-
Use epoll instead of poll in the event loop.
-
Optimize the use of memmove in the read buffer.
We are usingmemmoveto reclaim read buffer space. However, usingmemmoveon every request is unnecessary. Change the code to performmemmoveonly before reading. -
Improve the write process in the
state_resfunction.
In thestate_resfunction, write was performed for a single response. In pipelined scenarios, we could buffer multiple responses and flush them at the end with a single write call. Note that the write buffer could be full in the middle.