Memcached Performance Issue Diagnosis • #2 Dead Code Detection • #3 Inspecting C extension behavior • #4 Measuring the time taken for legacy batch jobs • #5 Long-Term Internal Metrics Recap
Memcached Performance Issue Diagnosis • #2 Dead Code Detection • #3 Inspecting C extension behavior • #4 Measuring the time taken for legacy batch jobs • #5 Long-Term Internal Metrics Recap
• Slow deployment process with a huge code base • Extremely hard to tell whether code is actually unused • Not only in web code but also in batch jobs, etc. • Some jobs might run once a month or even less often
events • Attach to PHP binaries (cli / apache module / php-fpm) • The BPF program runs when compile events happen, and records compile information • Provide JSON-formatted reports via an HTTP API
PHP binary must be compiled with --enable-dtrace • Already done in most Linux distros • USE_ZEND_DTRACE=1 environment variable must be set • You can add it to a systemd unit file, etc. $ php -i |grep -i dtrace DTrace Support => available, disabled $ USE_ZEND_DTRACE=1 php -i |grep -i dtrace DTrace Support => enabled USE_ZEND_DTRACE => 1
to location B Network location A Network location A App / API App / API Batch jobs Migrating Batch jobs +1.6 ms latency DB Network location B (target) Low latency (co-located) DB
to location B Network location A Network location A App / API App / API Batch jobs Batch jobs TC command inject delay Migrating +1.6 ms latency Network location B (target) DB DB Co-located: delay added artificially to simulate the move
Run as a one-liner or from a script file (.bt) bpftrace is a high-level tracing language for Linux. bpftrace uses LLVM as a backend to compile scripts to eBPF-bytecode and makes use of libbpf and bcc for interacting with the Linux BPF subsystem, as well as existing Linux tracing capabilities: kernel dynamic tracing (kprobes), user-level dynamic tracing (uprobes), tracepoints, etc. The bpftrace language is inspired by awk, C, and predecessor tracers such as DTrace and SystemTap.3 3 https://github.com/bpftrace/bpftrace