BMC is an in-kernel key-value cache implemented in BPF and proposed by paper [1]. The paper discussed BMC for memcached, obtaining at least 6x performance speedup.
This patch implements a sample BMC for Redis. Paper [1] implements BMC in XDP, bypassing the kernel network stack totally. Since Redis is based on TCP protocol, and it's almost impossible to fully process TCP traffic in XDP, so this patch implements BMC in sockmap, which locates at the top of kernel network stack. Since kernel network stack is not bypassed, the speedup is not significant. Any way, this is only a sample implementation, and performance improvements can be continuously optimized.
See [2] for details on how to build samples/bpf.
Output files: samples/bpf/bmctool samples/bpf/bmc/bpf.o
Sample usage: bmctool prog load -p 6379 ./bmc/bpf.o # load bmc bpf prog and attach it # to sockets with listen port 6379
bmctool stat # dump bmc status
bmctool prog unload # detach and unload bmc prog
[1] https://www.usenix.org/conference/nsdi21/presentation/ghigoff [2] https://www.kernel.org/doc/readme/samples-bpf-README.rst
Xu Kuohai (3): bpf: Add helper bpf_tcp_udpate_seq to synchronize tcp seq/ack bpf: Add xdp load and store helpers samples: bpf: Add sample BMC for Redis
include/uapi/linux/bpf.h | 27 ++ net/core/filter.c | 98 +++++ samples/bpf/Makefile | 3 + samples/bpf/bmc/bpf.c | 485 +++++++++++++++++++++ samples/bpf/bmc/common.h | 21 + samples/bpf/bmc/tool.c | 763 +++++++++++++++++++++++++++++++++ tools/include/uapi/linux/bpf.h | 27 ++ 7 files changed, 1424 insertions(+) create mode 100644 samples/bpf/bmc/bpf.c create mode 100644 samples/bpf/bmc/common.h create mode 100644 samples/bpf/bmc/tool.c