SDB provides high-accuracy stack profiling for Ruby applications. It can profile Ruby at microsecond (0.000001 second) intervals and offers event tagging for requests.
- Minimal Impact: SDB does not affect the target application’s performance.
- Event Tagging: SDB supports event tagging, making it easier to trace and identify slow functions.
- High Accuracy: SDB offers precision down to microseconds.
Instrumentation libraries like opentelemetry-ruby
generate data during application runtime, and some stack profilers block application threads. These approaches can introduce delays in your application.
SDB, inspired by LDB, operates by pulling stack traces on a separate thread, which minimizes the impact on our application.
Event tagging, such as adding trace_id for Puma requests, makes it easier to identify slow functions.
Moreover, SDB can precisely identify delays, down to a single microsecond.
Unlike other Ruby stack profilers, SDB doesn't acquire GVL. It only scans stacks, which are then collected into a buffer and written to the log.
As the stack scanner only gathers function addresses, the symbolizer is used for gathering human-readable information, such as function names, files, etc. To achieve this, the symbolizer instruments several Ruby VM methods, such as rb_iseq_new_with_opt
through eBPF.
SDB adds event tags for categorizing the stacks and the analyzer combines all those logs for us.
The image above is generated by sdb-analyzer. It represents a simple Ruby API application rendering an empty body.
The image clearly shows which methods are used and their latency, helping us understand the application's behavior and identify potential latency issues, even without prior background knowledge.
SDB is still in the experimental stage. Rather than focusing on ease of use and stability, I am exploring additional use cases, such as detecting concurrency issues or delays caused by GVL.