eunomia-bpf / bpftime

Userspace eBPF runtime for Observability, Network & General Extensions Framework
https://eunomia.dev/bpftime/
MIT License
788 stars 74 forks source link

vm: add AOT runner, API, and bench tool #258

Closed yunwei37 closed 5 months ago

yunwei37 commented 6 months ago

Description

Related to #254

Add a bench tool which can be easily used to compare AOT, JIT, and interpreter performance. The result and usage would be like:

$ /home/yunwei/ebpf-xdp-dpdk/build-bpftime/bpftime/tools/bpftimetool/bpftimetool run 3 /home/yunwei/ebpf-xdp-dpdk/bpftime/.clang-format repeat 10 type AOT
Running eBPF program with id 3 and data in file /home/yunwei/ebpf-xdp-dpdk/bpftime/.clang-format
Repeat N: 10 with run type AOT
[2024-03-26 16:04:06.411] [info] [bpftime_shm_internal.cpp:628] Global shm constructed. shm_open_type 1 for bpftime_maps_shm
[2024-03-26 16:04:06.411] [info] [bpftime_shm_internal.cpp:28] Global shm initialized
[2024-03-26 16:04:06.411] [info] [llvm_jit_context.cpp:81] Initializing llvm
[2024-03-26 16:04:06.411] [info] [llvm_jit_context.cpp:204] LLVM-JIT: Loading aot object
target_func called.
target_func called.
target_func called.
target_func called.
target_func called.
target_func called.
target_func called.
target_func called.
target_func called.
target_func called.
Time taken: 3392 ns
Return value: 0
INFO [1347842]: Global shm destructed
$ /home/yunwei/ebpf-xdp-dpdk/build-bpftime/bpftime/tools/bpftimetool/bpftimetool run 3 /home/yunwei/ebpf-xdp-dpdk/bpftime/.clang-format repeat 10 type JIT
Running eBPF program with id 3 and data in file /home/yunwei/ebpf-xdp-dpdk/bpftime/.clang-format
Repeat N: 10 with run type JIT
[2024-03-26 16:04:22.925] [info] [bpftime_shm_internal.cpp:628] Global shm constructed. shm_open_type 1 for bpftime_maps_shm
[2024-03-26 16:04:22.925] [info] [bpftime_shm_internal.cpp:28] Global shm initialized
[2024-03-26 16:04:22.925] [info] [llvm_jit_context.cpp:81] Initializing llvm
Time taken: 54 ns
Return value: 0
INFO [1348175]: Global shm destructed

In this case, we can easily experiment different kinds of optimize approaches.

We can dump the LLVM IR of any eBPF programs with maps and helpers, compile it with other tools and load it back to run.

Type of change

Officeyutong commented 5 months ago

CI is down