Generated by GPT-5-mini| bpftrace | |
|---|---|
| Name | bpftrace |
| Developer | Isovalent, Netflix, Facebook |
| Released | 2017 |
| Programming language | C++, LLVM |
| Operating system | Linux |
| License | GPL |
bpftrace
bpftrace is a high-level tracing language and tool for dynamic tracing on Linux systems using extended Berkeley Packet Filter (eBPF) technology. It provides a compact domain-specific language inspired by awk, DTrace and BCC to instrument kernel and user-space events for performance analysis, debugging and observability. Developed and used by teams at companies such as Isovalent, Netflix, and Facebook, the project integrates with toolchains like LLVM and Clang and runs on distributions such as Debian, Ubuntu and Red Hat Enterprise Linux.
bpftrace emerged to simplify event-driven tracing on Linux by leveraging the in-kernel verifier and runtime of eBPF introduced in the Linux Kernel community. It complements other observability projects including SystemTap, perf, FlameGraph, and Prometheus by offering higher-level syntactic constructs while targeting the same low-level tracing substrate used by Cilium and Katran. Contributors include engineers from Netflix, Facebook, Isovalent, and academic groups associated with University of California, Berkeley and Princeton University.
The language is designed around probe types such as kprobes, uprobes, tracepoints, and perf events, exposing a concise syntax influenced by awk and DTrace's scripting model. Its primitives include associative maps, histograms, stacks and built-in functions; these map to in-kernel eBPF helpers and data structures implemented via LLVM code generation. The compiler pipeline uses Clang frontends and LLVM backends to emit BPF bytecode that the Linux Kernel loader and verifier accept. Language semantics emphasize safety and bounded execution similar to design discussions in Google and Intel kernel engineering teams.
Typical usage involves writing one-liners or small scripts that attach kprobes to functions in binaries like nginx, mysqld, or openssl and aggregate metrics across threads and CPUs. Example tasks include CPU stack sampling for latency investigations with FlameGraph post-processing, syscall frequency counts for services such as Redis and PostgreSQL, and latency histograms for RPC frameworks like gRPC. Toolchains often combine bpftrace scripts with continuous monitoring stacks featuring Grafana, Prometheus, and log systems like ELK Stack for dashboards and alerts. Operators from teams at Uber, Twitter, and Airbnb have published tracing recipes targeting microservices frameworks such as Envoy and Istio.
At runtime bpftrace parses scripts into an intermediate representation that it compiles via LLVM into eBPF bytecode, which is then loaded into the Linux Kernel using libbpf or kernel APIs maintained by projects like iovisor. The in-kernel verifier, developed alongside contributions from Facebook and Google, enforces safety properties such as bounded loops and stack usage. Data is transferred to user-space through per-CPU maps and perf ring buffers shared with tools like BCC and libraries from Kernel.org. Integration points and build systems reference CMake and continuous integration workflows using Jenkins or GitHub Actions from participating organizations.
bpftrace benefits from eBPF's in-kernel execution model, avoiding context switches and reducing overhead compared to user-space tracing methods used by strace or agent-based profilers created by New Relic and Datadog. Its performance characteristics depend on probe density, map sizes, and verifier constraints; production teams from Netflix and Isovalent publish best practices such as using histograms and sampling to minimize CPU and memory impact. Security considerations include kernel attack surface hardening from the verifier, SELinux/AppArmor interactions on distributions like Fedora and CentOS, and supply-chain concerns addressed in policies by organizations such as OpenSSF. Privilege requirements for loading eBPF programs invite access controls aligned with systemd service policies and Linux Security Module configurations.
bpftrace is adopted across cloud providers, observability vendors, and open-source projects including Cilium, Envoy, Kubernetes, and Docker for troubleshooting and performance tuning. The ecosystem includes complementary projects like BCC, perf-tools, FlameGraph, and vendor integrations from Google Cloud Platform, Amazon Web Services and Microsoft Azure for managed observability solutions. Educational resources and community contributions are hosted on platforms such as GitHub, discussed at conferences like KubeCon, Linux Plumbers Conference, and USENIX, and used in coursework at universities including Massachusetts Institute of Technology and Stanford University.
Category:Free software Category:Linux software Category:Observability software