The code for the NSDI'21 paper "BMC: Accelerating Memcached using Safe In-kernel Caching and Pre-stack Processing".

Overview

BMC

The code for the NSDI'21 paper "BMC: Accelerating Memcached using Safe In-kernel Caching and Pre-stack Processing".

BibTex entry available here.

BMC (BPF Memory Cache) is an in-kernel cache for memcached. It enables runtime, crash-safe extension of the Linux kernel to process specific memcached requests before the execution of the standard network stack. BMC does not require modification of neither the Linux kernel nor the memcached application. Running memcached with BMC improves throughput by up to 18x compared to the vanilla memcached application.

Requirements

Linux kernel v5.3 or higher is required to run BMC.

Other software dependencies are required to build BMC and Memcached-SR (see Building BMC and Building Memcached-SR).

Build instructions

Building BMC

BMC must be compiled with libbpf and other header files obtained from kernel sources. The project does not include the kernel sources, but the kernel-src-download.sh and kernel-src-prepare.sh scripts automate the download of the kernel sources and prepare them for the compilation of BMC.

These scripts require the following software to be installed:

gpg curl tar xz make gcc flex bison libssl-dev libelf-dev

The project uses llvm and clang version 9 to build BMC, but more recent versions might work as well:

llvm-9 clang-9

Note that libelf-dev is also required to build libbpf and BMC.

With the previous software installed, BMC can be built with the following:

$ ./kernel-src-download.sh
$ ./kernel-src-prepare.sh
$ cd bmc && make

After BMC has been successfully built, kernel sources can be removed by running the kernel-src-remove.sh script from the project root.

Building Memcached-SR

Memcached-SR is based on memcached v1.5.19. Building it requires the following software:

clang-9 (or gcc-9) automake libevent-dev

Either clang-9 or gcc-9 is required in order to compile memcached without linking issues. Depending on your distribution, you might also need to use the -Wno-deprecated-declarations compilation flag.

Memcached-SR can be built with the following:

$ cd memcached-sr 
$ ./autogen.sh
$ CC=clang-9 CFLAGS='-DREUSEPORT_OPT=1 -Wno-deprecated-declarations' ./configure && make

The memcached binary will be located in the memcached-sr directory.

Further instructions

TC egress hook

BMC doesn't attach the tx_filter eBPF program to the egress hook of TC, it needs to be attached manually.

To do so, you first need to make sure that the BPF is mounted, if it isn't you can mount it with the following command:

# mount -t bpf none /sys/fs/bpf/

Once BMC is running and the tx_filter program has been pinned to /sys/fs/bpf/bmc_tx_filter, you can attach it using the tc command line:

# tc qdisc add dev 
   
     clsact
   
# tc filter add dev 
   
     egress bpf object-pinned /sys/fs/bpf/bmc_tx_filter
   

After you are done using BMC, you can detach the program with these commands:

# tc filter del dev 
   
     egress
   
# tc qdisc del dev 
   
     clsact
   

And unpin the program with # rm /sys/fs/bpf/bmc_tx_filter

License

Files under the bmc directory are licensed under the GNU Lesser General Public License version 2.1.

Files under the memcached-sr directory are licensed under the BSD-3-Clause BSD license.

Cite this work

BibTex:

@inproceedings{265047,
	title        = {{BMC}: Accelerating Memcached using Safe In-kernel Caching and Pre-stack Processing},
	author       = {Yoann Ghigoff and Julien Sopena and Kahina Lazri and Antoine Blin and Gilles Muller},
	year         = 2021,
	month        = apr,
	booktitle    = {18th {USENIX} Symposium on Networked Systems Design and Implementation ({NSDI} 21)},
	publisher    = {{USENIX} Association},
	pages        = {487--501},
	isbn         = {978-1-939133-21-2},
	url          = {https://www.usenix.org/conference/nsdi21/presentation/ghigoff}
}
Comments
  • tx_filter does not work?

    tx_filter does not work?

    After I start bmc, I can see that rx_filter has received data, but tx_filter has never been called.I don't see tx_filter being attached to the egress hook of tc in the code. Do I need to attach it separately?How to attach it?

    opened by zouwen4321 2
  • error while building bmc

    error while building bmc

    Hi, I'm tring to build bmc, got the following error while building

    I'm running this build in in following environment:

    1. debian 11
    2. clang 11, llvm 11
    3. gcc 10.2.1
    4. downloaded the kernel source by running apt source linux, and the kernel version is 5.10.84
    gcc -g -O2 -Wall -I. -I../linux-5.10.84/tools/lib -I../linux-5.10.84/tools/include/uapi  -o bmc bmc_user.c ../linux-5.10.84/tools/lib/bpf/libbpf.a -L../linux-5.10.84/tools/lib/bpf -l:libbpf.a -lelf
    In file included from /usr/include/linux/kernel.h:5,
                     from ../linux-5.10.84/tools/include/uapi/linux/netlink.h:5,
                     from ../linux-5.10.84/tools/include/uapi/linux/if_link.h:6,
                     from bmc_user.c:20:
    /usr/include/linux/sysinfo.h:9:2: error: unknown type name ‘__kernel_long_t’
        9 |  __kernel_long_t uptime;  /* Seconds since boot */
          |  ^~~~~~~~~~~~~~~
    /usr/include/linux/sysinfo.h:10:2: error: unknown type name ‘__kernel_ulong_t’
       10 |  __kernel_ulong_t loads[3]; /* 1, 5, and 15 minute load averages */
          |  ^~~~~~~~~~~~~~~~
    /usr/include/linux/sysinfo.h:11:2: error: unknown type name ‘__kernel_ulong_t’
       11 |  __kernel_ulong_t totalram; /* Total usable main memory size */
          |  ^~~~~~~~~~~~~~~~
    /usr/include/linux/sysinfo.h:12:2: error: unknown type name ‘__kernel_ulong_t’
       12 |  __kernel_ulong_t freeram; /* Available memory size */
          |  ^~~~~~~~~~~~~~~~
    /usr/include/linux/sysinfo.h:13:2: error: unknown type name ‘__kernel_ulong_t’
       13 |  __kernel_ulong_t sharedram; /* Amount of shared memory */
          |  ^~~~~~~~~~~~~~~~
    /usr/include/linux/sysinfo.h:14:2: error: unknown type name ‘__kernel_ulong_t’
       14 |  __kernel_ulong_t bufferram; /* Memory used by buffers */
          |  ^~~~~~~~~~~~~~~~
    /usr/include/linux/sysinfo.h:15:2: error: unknown type name ‘__kernel_ulong_t’
       15 |  __kernel_ulong_t totalswap; /* Total swap space size */
          |  ^~~~~~~~~~~~~~~~
    /usr/include/linux/sysinfo.h:16:2: error: unknown type name ‘__kernel_ulong_t’
       16 |  __kernel_ulong_t freeswap; /* swap space still available */
          |  ^~~~~~~~~~~~~~~~
    /usr/include/linux/sysinfo.h:19:2: error: unknown type name ‘__kernel_ulong_t’
       19 |  __kernel_ulong_t totalhigh; /* Total high memory size */
          |  ^~~~~~~~~~~~~~~~
    /usr/include/linux/sysinfo.h:20:2: error: unknown type name ‘__kernel_ulong_t’
       20 |  __kernel_ulong_t freehigh; /* Available high memory size */
          |  ^~~~~~~~~~~~~~~~
    /usr/include/linux/sysinfo.h:22:22: error: ‘__kernel_ulong_t’ undeclared here (not in a function)
       22 |  char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)]; /* Padding: libc5 uses this.. */
          |                      ^~~~~~~~~~~~~~~~
    
    opened by smartding 1
  • autogen.sh error for memcached-sr

    autogen.sh error for memcached-sr

    ./autogen.sh

    fatal: No names found, cannot describe anything.
    aclocal...
    autoheader...
    automake...
    autoconf...
    configure.ac:8: warning: 'AM_CONFIG_HEADER': this macro is obsolete.
    configure.ac:8: You should use the 'AC_CONFIG_HEADERS' macro instead.
    ./lib/autoconf/general.m4:2434: AC_DIAGNOSE is expanded from...
    aclocal.m4:745: AM_CONFIG_HEADER is expanded from...
    configure.ac:8: the top level
    configure.ac:79: warning: AC_PROG_CC_C99 is obsolete; use AC_PROG_CC
    configure.ac:82: warning: ac_ext=c
    configure.ac:82: ac_cpp='$CPP $CPPFLAGS'
    configure.ac:82: ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
    configure.ac:82: ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
    configure.ac:82: ac_compiler_gnu=$ac_cv_c_compiler_gnu
    configure.ac:82: if test -n "$ac_tool_prefix"; then
    configure.ac:82:   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
    configure.ac:82: set dummy ${ac_tool_prefix}gcc; ac_word=$2
    configure.ac:82: { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
    configure.ac:82: printf %s "checking for $ac_word... " >&6; }
    configure.ac:82: if test ${ac_cv_prog_CC+y}
    configure.ac:82: then :
    configure.ac:82:   printf %s "(cached) " >&6
    configure.ac:82: else $as_nop
    configure.ac:82:   if test -n "$CC"; then
    configure.ac:82:   ac_cv_prog_CC="$CC" # Let the user override the test.
    configure.ac:82: else
    configure.ac:82: as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    configure.ac:82: for as_dir in $PATH
    configure.ac:82: do
    configure.ac:82:   IFS=$as_save_IFS
    configure.ac:82:   case $as_dir in #(((
    configure.ac:82:     '' is m4_require'd but not m4_defun'd
    lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    ./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
    ./lib/autoconf/programs.m4:41: _AC_CHECK_PROG is expanded from...
    ./lib/autoconf/programs.m4:101: AC_CHECK_PROG is expanded from...
    ./lib/autoconf/programs.m4:221: AC_CHECK_TOOL is expanded from...
    ./lib/autoconf/c.m4:452: AC_PROG_CC is expanded from...
    configure.ac:82: the top level
    
    opened by ultperf 0
  • "make" works under bmc folder but ./bmc eth0 churns error below:

    "make" works under bmc folder but ./bmc eth0 churns error below:

    ; for (off = 4; off < BMC_MAX_PACKET_LENGTH && payload+off+1 <= data_end && payload[off] == ' '; off++) {} // move offset to the start of the first key
    46: (1f) r7 -= r8
    47: (b7) r1 = 54
    48: (bf) r2 = r7
    49: (07) r2 += -50
    ; for (off = 4; off < BMC_MAX_PACKET_LENGTH && payload+off+1 <= data_end && payload[off] == ' '; off++) {} // move offset to the start of the first key
    50: (1d) if r7 == r1 goto pc+23
     R0=map_value(id=0,off=0,ks=4,vs=12,imm=0) R1_w=inv54 R2_w=inv(id=0) R6=ctx(id=0,off=0,imm=0) R7_w=inv(id=3) R8=pkt(id=0,off=0,r=54,imm=0) R10=fp0 fp-8=mmmm????
    ; for (off = 4; off < BMC_MAX_PACKET_LENGTH && payload+off+1 <= data_end && payload[off] == ' '; off++) {} // move offset to the start of the first key
    51: (bf) r3 = r8
    52: (0f) r3 += r1
    last_idx 52 first_idx 41
    regs=2 stack=0 before 51: (bf) r3 = r8
    regs=2 stack=0 before 50: (1d) if r7 == r1 goto pc+23
    regs=2 stack=0 before 49: (07) r2 += -50
    regs=2 stack=0 before 48: (bf) r2 = r7
    regs=2 stack=0 before 47: (b7) r1 = 54
    53: (71) r3 = *(u8 *)(r3 +0)
    invalid access to packet, off=54 size=1, R3(id=0,off=54,r=54)
    R3 offset is outside of the packet
    processed 52 insns (limit 1000000) max_states_per_insn 0 total_states 4 peak_states 4 mark_read 2
    
    libbpf: -- END LOG --
    libbpf: failed to load program 'bmc_rx_filter'
    libbpf: failed to load object './bmc_kern.o'
    Error: bpf_object__load_xattr failed
    
    
    opened by ultperf 1
  • error in compilation using bmc-cache/memcached-sr# CC=clang CFLAGS='-DREUSEPORT_OPT=1 -Wno-deprecated-declarations' ./configure && make

    error in compilation using bmc-cache/memcached-sr# CC=clang CFLAGS='-DREUSEPORT_OPT=1 -Wno-deprecated-declarations' ./configure && make

    bmc-cache/memcached-sr# CC=clang CFLAGS='-DREUSEPORT_OPT=1 -Wno-deprecated-declarations' ./configure && make

    ./configure: line 5148: syntax error near unexpected token `newline'
    
    opened by ultperf 0
  • Question on Benchmarks

    Question on Benchmarks

    Hi! I see that BMC is using UDP get requests for benchmarks. I was wondering how you dealt with packet drops. Did the open-loop generator retransmit requests after some time?

    opened by yanniszark 0
Owner
Orange
Open Source by Orange
Orange
Inference code for "StylePeople: A Generative Model of Fullbody Human Avatars" paper. This code is for the part of the paper describing video-based avatars.

NeuralTextures This is repository with inference code for paper "StylePeople: A Generative Model of Fullbody Human Avatars" (CVPR21). This code is for

Visual Understanding Lab @ Samsung AI Center Moscow 18 Oct 6, 2022
This is the official source code for SLATE. We provide the code for the model, the training code, and a dataset loader for the 3D Shapes dataset. This code is implemented in Pytorch.

SLATE This is the official source code for SLATE. We provide the code for the model, the training code and a dataset loader for the 3D Shapes dataset.

Gautam Singh 66 Dec 26, 2022
Code for paper ECCV 2020 paper: Who Left the Dogs Out? 3D Animal Reconstruction with Expectation Maximization in the Loop.

Who Left the Dogs Out? Evaluation and demo code for our ECCV 2020 paper: Who Left the Dogs Out? 3D Animal Reconstruction with Expectation Maximization

Benjamin Biggs 29 Dec 28, 2022
TensorFlow code for the neural network presented in the paper: "Structural Language Models of Code" (ICML'2020)

SLM: Structural Language Models of Code This is an official implementation of the model described in: "Structural Language Models of Code" [PDF] To ap

null 73 Nov 6, 2022
Code for the prototype tool in our paper "CoProtector: Protect Open-Source Code against Unauthorized Training Usage with Data Poisoning".

CoProtector Code for the prototype tool in our paper "CoProtector: Protect Open-Source Code against Unauthorized Training Usage with Data Poisoning".

Zhensu Sun 1 Oct 26, 2021
Code to use Augmented Shapiro Wilks Stopping, as well as code for the paper "Statistically Signifigant Stopping of Neural Network Training"

This codebase is being actively maintained, please create and issue if you have issues using it Basics All data files are included under losses and ea

J K Terry 32 Nov 9, 2021
Code for our method RePRI for Few-Shot Segmentation. Paper at http://arxiv.org/abs/2012.06166

Region Proportion Regularized Inference (RePRI) for Few-Shot Segmentation In this repo, we provide the code for our paper : "Few-Shot Segmentation Wit

Malik Boudiaf 138 Dec 12, 2022
Code for ACM MM 2020 paper "NOH-NMS: Improving Pedestrian Detection by Nearby Objects Hallucination"

NOH-NMS: Improving Pedestrian Detection by Nearby Objects Hallucination The offical implementation for the "NOH-NMS: Improving Pedestrian Detection by

Tencent YouTu Research 64 Nov 11, 2022
Official TensorFlow code for the forthcoming paper

~ Efficient-CapsNet ~ Are you tired of over inflated and overused convolutional neural networks? You're right! It's time for CAPSULES :)

Vittorio Mazzia 203 Jan 8, 2023
This is the code for the paper "Contrastive Clustering" (AAAI 2021)

Contrastive Clustering (CC) This is the code for the paper "Contrastive Clustering" (AAAI 2021) Dependency python>=3.7 pytorch>=1.6.0 torchvision>=0.8

Yunfan Li 210 Dec 30, 2022
Code for the paper Learning the Predictability of the Future

Learning the Predictability of the Future Code from the paper Learning the Predictability of the Future. Website of the project in hyperfuture.cs.colu

Computer Vision Lab at Columbia University 139 Nov 18, 2022
PyTorch code for the paper: FeatMatch: Feature-Based Augmentation for Semi-Supervised Learning

FeatMatch: Feature-Based Augmentation for Semi-Supervised Learning This is the PyTorch implementation of our paper: FeatMatch: Feature-Based Augmentat

null 43 Nov 19, 2022
Code for the paper A Theoretical Analysis of the Repetition Problem in Text Generation

A Theoretical Analysis of the Repetition Problem in Text Generation This repository share the code for the paper "A Theoretical Analysis of the Repeti

Zihao Fu 37 Nov 21, 2022
Code for our ICASSP 2021 paper: SA-Net: Shuffle Attention for Deep Convolutional Neural Networks

SA-Net: Shuffle Attention for Deep Convolutional Neural Networks (paper) By Qing-Long Zhang and Yu-Bin Yang [State Key Laboratory for Novel Software T

Qing-Long Zhang 199 Jan 8, 2023
Open source repository for the code accompanying the paper 'Non-Rigid Neural Radiance Fields Reconstruction and Novel View Synthesis of a Deforming Scene from Monocular Video'.

Non-Rigid Neural Radiance Fields This is the official repository for the project "Non-Rigid Neural Radiance Fields: Reconstruction and Novel View Synt

Facebook Research 296 Dec 29, 2022
Code for the Shortformer model, from the paper by Ofir Press, Noah A. Smith and Mike Lewis.

Shortformer This repository contains the code and the final checkpoint of the Shortformer model. This file explains how to run our experiments on the

Ofir Press 138 Apr 15, 2022
PyTorch code for ICLR 2021 paper Unbiased Teacher for Semi-Supervised Object Detection

Unbiased Teacher for Semi-Supervised Object Detection This is the PyTorch implementation of our paper: Unbiased Teacher for Semi-Supervised Object Detection

Facebook Research 366 Dec 28, 2022
Official code for paper "Optimization for Oriented Object Detection via Representation Invariance Loss".

Optimization for Oriented Object Detection via Representation Invariance Loss By Qi Ming, Zhiqiang Zhou, Lingjuan Miao, Xue Yang, and Yunpeng Dong. Th

ming71 56 Nov 28, 2022
Code for our CVPR 2021 paper "MetaCam+DSCE"

Joint Noise-Tolerant Learning and Meta Camera Shift Adaptation for Unsupervised Person Re-Identification (CVPR'21) Introduction Code for our CVPR 2021

FlyingRoastDuck 59 Oct 31, 2022