This repository contains the code and scripts for evaluating Redis with io_uring as part of my thesis. The project integrates the official redis repository as a git submodule. Additionally, it includes my custom implementation as a git submodule redis-io_uring.
Before getting started, ensure your system meets the following requirements:
- Kernel Version: Ensure your kernel version is >= 6.x.
Run the ./setup.sh script. This script will:
- Pull both
redisandredis-io_uringgit submodules, if not already pulled. - Install all necessary dependencies.
- Build both
redisandredis-io_uring.
Simply execute the following command in your terminal:
./setup.shIf you prefer to install dependencies manually, ensure you have the following installed on your system:
makegccpython3- Python libraries:
pandas,psutil,matplotlib,redis(You can also install these withpip3)
Follow these steps:
-
Pull Git Submodules:
If you didn't pull the repository with
--recurse-submodules, initialize and update the submodules:git submodule update --init --recursive
-
Build Redis and Redis-IO_Uring:
Navigate to the project root directory and run the following commands to build
redisandredis-io_uring:make -C redis make -C redis-io_uring
-
Copy Redis Tools:
Copy the
redis-benchmarkandredis-check-aoftools to thescriptsdirectory:cp redis/src/redis-benchmark scripts/ cp redis/src/redis-check-aof scripts/
To run Redis, navigate to either the redis or redis-io_uring directory and execute the following command:
./src/redis-server redis.confAdditional configuration options can be set in the redis.conf file. Here are the liburing configurations for append-only file operations:
appendonly-liburing yes
liburing-queue-depth xl
liburing-retry-count xl
liburing-sqpoll no
correct-test no
correct-test-reqnum 100000
To run the benchmark tests, use the redis-benchmark tool here:
./src/redis-benchmark -t set,incr -n 500000 -qThis command will run benchmark tests for the set and incr operations with 500,000 requests, providing a quick summary of the results.
First, navigate to the scripts directory by executing:
cd scriptsEnsure that the directory contains the necessary executables: redis-benchmark redis-check-aof
To run the benchmark without reformatting the filesystem, execute the following command:
sudo python3 run_benchmarks.py --requests 4000000To run the benchmark with reformatting between each test, follow these steps:
cp -r data/RDB-<timestamp> <root-partition>
sudo umount /mnt/ext4
sudo mkfs -t ext4 /dev/<drive>
sudo mount /mnt/ext4
# REPEAT INSTALLATION
sudo python3 run_benchmarks.py --benchmark AOF --requests 4000000
cp -r data/AOF-all-<timestamp> <root-partition>
sudo umount /mnt/ext4
sudo mkfs -t ext4 /dev/<drive>
sudo mount /mnt/ext4
# REPEAT INSTALLATION
sudo python3 run_benchmarks.py --benchmark URING_AOF --requests 4000000Repeat this sequence three times to achieve results comparable to those presented in the evaluation.
IMPORTANT! Execute the benchmarks with elevated privileges because strace requires these privileges to function properly.
Benchmark Data: Each Redis configuration directory stores its respective benchmark data, typically located in benchmarks/<config>/data.
Arguments:
-
--benchmark: Specifies which benchmark to run. Options include:- AOF: Runs the Append-Only File benchmark.
- RDB: Runs the Redis Database benchmark.
- URING_AOF: Runs the benchmark using
io_uringwith AOF.
If no benchmark is specified, the script will run all three benchmarks by default.
-
--requests: Specifies the number of requests to be sent during the benchmark. The default is100,000, but for a more extensive test, you can increase this number as shown in the example (4,000,000requests). -
--fsync: Defines thefsyncmode for the AOF benchmark. Available options include:- always: Ensures that data is written to disk immediately after each write operation.
- everysec: Synchronizes data to disk every second.
- no: Disables synchronization after write operations.
- all: Runs the benchmark for all
fsyncmodes.
The default setting is
all. -
--no-strace: When this flag is set, the benchmark runs without invokingstrace, which can reduce overhead and improve performance during the tests. By default,straceis used.
Navigate to the scripts directory:
cd scriptsTo verify the correctness of the data, and run the 3 mentioned tests, you can execute the following command in the terminal:
sudo python3 correctness-test.pyArguments:
-
--requests: Specifies the number of requests to be used in the benchmark. The default value is100,000, but you can adjust this number depending on the scope of your testing. -
--no-bgrewriteaof: This flag, if set, disables the triggering of theBGREWRITEAOFcommand during the test. TheBGREWRITEAOFcommand is typically used to rewrite the AOF (Append Only File) to reduce its size and optimize its structure. By default, this feature is enabled, but you can disable it with this flag to test scenarios without AOF rewriting.
To generate plots navigate to the scripts directory:
cd scriptsAnd execute the script:
sudo python3 plot.py --dir_rdb <path> --dir_aof <path> --dir_uring <path> --dir <output-dir> --type allThe directories for each persistence mode can contain many sub directories (for each run) generated by the benchmark. For example if you run the benchmark without reformatting you can just execute:
sudo python3 plot.py --dir_rdb benchmark/RDB/data --dir_aof benchmark/AOF/data --dir_uring benchmark/URING_AOF/data --dir ./output --type allThis will generate all the graphs.
Arguments:
-
--dir_rdb: Specifies the directory containing the CSV files for the RDB persistence mode. This argument is mandatory. -
--dir_aof: Specifies the directory containing the CSV files for the AOF persistence mode. This argument is mandatory. -
--dir_uring: Specifies the directory containing the CSV files for the URING_AOF persistence mode. This argument is mandatory. -
--dir: Defines the directory where the generated graphs will be saved. The default is the current directory. -
--type: Specifies the type of graph to plot. The following options are available:rps: Generates a graph comparing the requests per second (RPS) across the different persistence modes.cpu: Generates a graph comparing CPU usage across the different persistence modes.memory: Generates a graph comparing memory usage across the different persistence modes.latency: Generates a graph comparing latency statistics across the different persistence modes.all: Generates all of the above graphs.