From f8d17013a40ac8be991040f69e910bb095c1d505 Mon Sep 17 00:00:00 2001 From: Tal Zussman Date: Tue, 17 May 2022 21:28:42 -0400 Subject: [PATCH 1/3] Fix simplekvspec.h VERBOSE function - struct Node no longer has member num --- xrp-bpf/simplekvspec.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/xrp-bpf/simplekvspec.h b/xrp-bpf/simplekvspec.h index c5cb662..b9cb9e8 100644 --- a/xrp-bpf/simplekvspec.h +++ b/xrp-bpf/simplekvspec.h @@ -37,7 +37,6 @@ static __inline void print_query(struct Query *q) { static __inline void print_node(Node *node) { dbg_print("struct Node {\n"); - dbg_print("\tnum = %ld\n", node->num); dbg_print("\ttype = %ld\n", node->type); dbg_print("\tkey[0] = %ld\n", node->key[0]); dbg_print("\tkey[30] = %ld\n", node->key[NODE_CAPACITY - 1]); @@ -50,6 +49,4 @@ static __inline void print_node(Node *node) { #define dbg_print(...) #endif - - #endif From 7a07b143bc7e476b5d3ecfc5b3249913084c22eb Mon Sep 17 00:00:00 2001 From: Tal Zussman Date: Tue, 17 May 2022 21:35:33 -0400 Subject: [PATCH 2/3] Add LDFLAG for libbpf in Makefile - Default install directory for libbpf isn't in gcc's default paths - Use default path specified in libbpf's src/Makefile - Can override the path by setting LIBDIR when running make --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 4eafc39..5a63c0f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,14 @@ CC = gcc CFLAGS = -Wall -D_GNU_SOURCE -Wunused + +ifeq ($(filter-out %64 %64be %64eb %64le %64el s390x, $(shell uname -m)),) + LIBDIR ?= /usr/lib64 +else + LIBDIR ?= /usr/lib +endif + +LDFLAGS = -L$(LIBDIR) + LDLIBS = -pthread -lbpf -lm From 5dfb0dc98d0bc6fbd6442a3f99182edd57bed06f Mon Sep 17 00:00:00 2001 From: Tal Zussman Date: Tue, 17 May 2022 22:04:26 -0400 Subject: [PATCH 3/3] Update README.md - Reflect usage of LD_PRELOAD in all commands - Mention clang and llvm deps - Remove section about xrp_loader - Mention root access requirement for bpf --- README.md | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 87ec261..4eaf73e 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,18 @@ query operations. SimpleKV supports low-latency IO via the XRP BPF interface and can also run using user-space IO (`pread()`) on mainline (and XRP compatible) kernels. -For usage instructions run `./simplekv --help` after compiling. +For usage instructions run `LD_PRELOAD="/usr/lib64/libbpf.so.0" ./simplekv --help` after compiling. # Building -SimpleKV is built using the provided Makefile. Compiling the simplekv binary +SimpleKV is built using the provided Makefile. Compiling the `simplekv` binary is as simple as running `make`. To perform IO with XRP via the `--use-xrp` flag the corresponding BPF programs in the `xrp-bpf` directory must be compiled. These BPF programs require [libbpf](https://github.com/libbpf/libbpf) and an XRP compatible kernel. Before compiling, install libbpf via your distribution's package manager or source. +Compiling these programs also requires installing `clang` and `llvm`. To compile on an XRP compatible kernel with libbpf, run: ``` @@ -26,6 +27,9 @@ Alternatively, you can compile simplekv without the BPF programs and use userspa make simplekv ``` +For the below commands, we assume your libbpf installation is located in the +default directory specified by libbpf: `/usr/lib64` (for 64-bit architectures). + # Running ## Create a Database File @@ -45,39 +49,28 @@ space. To create a 6-layer database file: ``` -./simplekv 6-layer-db 6 create +LD_PRELOAD="/usr/lib64/libbpf.so.0" ./simplekv 6-layer-db 6 create ``` ## Running the benchmark SimpleKV supports get queries and range queries, both of which can be run with various options. Usage and option docs can be reviewed by passing the `--help` flag to either command: ``` -./simplekv 6-layer-db 6 get --help -./simplekv 6-layer-db 6 range --help +LD_PRELOAD="/usr/lib64/libbpf.so.0" ./simplekv 6-layer-db 6 get --help +LD_PRELOAD="/usr/lib64/libbpf.so.0" ./simplekv 6-layer-db 6 range --help ``` ### Using XRP -Before running with XRP you must load the corresponding BPF function using the -`xrp_loader` program built via the default make target. Note that GET and RANGE operations -use separate BPF programs, so be sure to load the correct one. - -For GET operations: -``` -LD_PRELOAD="/usr/lib64/libbpf.so.0" ./xrp_loader xrp-bpf/get_op.o -``` - -For RANGE operations: -``` -LD_PRELOAD="/usr/lib64/libbpf.so.0" ./xrp_loader xrp-bpf/range_op.o -``` NOTE: You may need to change `LD_PRELOAD` depending on where `libbpf.so.0` is located on your machine. With the BPF program loaded, you can run a basic GET benchmark as follows: ``` -./simplekv 6-layer-db 6 get --requests=100000 --use-xrp +sudo LD_PRELOAD="/usr/lib64/libbpf.so.0" ./simplekv 6-layer-db 6 get --requests=100000 --use-xrp ``` +Root access is required in order to load the bpf programs. + ### CPU Configuration For consistent benchmark results you may need to disable CPU frequency scaling.