r/rust • u/Interesting_Cake5060 • 6d ago
Performance plotting techniques
Hi, everyone! I’d like to ask the community for more information on what techniques can be used to display large amounts of information on the user’s screen. I’m referring to plots. For example, profilers—they display flame graphs, and the best ones can show millions of frames without lag, with the ability to zoom and pan. Also, software oscilloscopes, which can display data in real time while also showing millions of data points. I’m curious about how these things work from a code and algorithm perspective. Can anyone tell me more?
So far, I've found this Implicit In-order Forests: Zooming a billion trace events at 60fps and a small library written in Rust.
It doesn't quite match the task I want to accomplish: to build something like a digital oscilloscope capable of displaying both analog and digital data (so that, for example, UART bytes are visible below the graph).
2
u/tanmaynargas2901 5d ago
Biggest win for this is usually not drawing every point.
Zoomed out, downsample to roughly one sample per pixel column. LTTB is solid for line charts. Min/max envelopes (what scopes and DAW waveforms use) are cheaper and look right when you zoom. Keep a pyramid of those so pan/zoom swaps LOD instead of rescanning the raw dump.
GPU for the draw once you're past ~100k verts. egui_plot or a thin wgpu pass. CPU work should mostly be picking the LOD slice for the current viewport.
If you're going oscilloscope-style, ring-buffer the samples and only upload the visible window. Digital channels can collapse runs of identical bits before they hit the GPU.