$ show riemann/riemann-jvm-profiler
This repository contains a JVM agent that samples thread stack traces and sends profiling data to a Riemann server. The agent is implemented in Java (Agent.java) which boots a Clojure runtime to perform the actual profiling logic. The core functionality involves periodically sampling stack traces of all runnable threads (excluding the sampler thread itself), aggregating them into a radix tree to estimate time spent per function, and sending the top functions as events to Riemann via HTTP. The design is lightweight and configurable, intended for production use in distributed systems like Hadoop clusters to identify CPU hotspots across thousands of nodes. The agent requires no application code changes and works with any JVM language.
The LLM identified 1 files worth highlighting for reuse:
Implements efficient stack trace aggregation using a radix tree (trie) data structure. The sample() function builds a tree where each path represents a call stack (top-to-bottom), incrementing counters at each node. The hotspots() function then computes self-time per method by subtracting child times, returning the top functions by CPU usage. This approach minimizes memory overhead and enables merging samples across threads. The component is loosely coupled (depends only on clj-radix and basic Java management APIs) and could be extracted for any call stack analysis task.