DataViewer Rendering Pipeline Benchmarks
Overview
This document presents the results of ad-hoc benchmarks measuring the DataViewer_Widget rendering pipeline performance. The benchmarks quantify read throughput across storage backends, vertex generation costs, cache extraction overhead, min/max decimation strategies, per-pixel buffer approaches, and multi-channel scaling behavior.
Hardware: 12-core CPU @ 2.9 GHz, 32 KiB L1d (x6), 256 KiB L2 (x6), 12 MiB L3
Compiler: Clang Release (C++23), -O2/-O3 via CMake preset linux-clang-release
Date: April 2026
Source: benchmark/adhoc/rendering/
1. Storage Backend Read Throughput
This benchmark measures raw read throughput for each AnalogTimeSeries storage backend, isolating how fast we can extract sample values from each implementation.
Results
| Backend | Access Method | 10K samples | 100K samples | 1M samples |
|---|---|---|---|---|
| Vector | viewValues() |
939 M/s | 968 M/s | 911 M/s |
| Vector | Span range | 971 M/s | 978 M/s | 940 M/s |
| Vector | Raw pointer | 983 M/s | 978 M/s | 937 M/s |
| Vector | viewTimeValueRange() |
414 M/s | 429 M/s | 416 M/s |
| TensorColumn (32ch) | viewValues() |
— | 970 M/s | 932 M/s |
| TensorColumn (384ch) | viewValues() |
— | 975 M/s | — |
| TensorColumn (32ch) | Span range | — | 972 M/s | 935 M/s |
| TensorColumn (384ch) | Span range | — | 974 M/s | — |
| BlockCachedMmap (32ch) | viewValues() |
99 M/s | 8.7 M/s | — |
| BlockCachedMmap (384ch) | viewValues() |
100 M/s | 0.73 M/s | — |
| BlockCachedMmap (32ch) | Cold start | 9.1 M/s | 7.9 M/s | — |
| MemoryMapped (32ch) | Per-element | 211 M/s | 132 M/s | — |
| MemoryMapped (384ch) | Per-element | 96 M/s | — | — |
Key Findings
viewTimeValueRange()is 2.3x slower than direct span orviewValues()access on Vector storage ($$416 M/s vs $$940 M/s). This is the path currently used by the rendering pipeline. The overhead comes from constructingTimeValuePointstructs with virtual dispatch per element.- Vector, TensorColumn, and raw pointer all achieve $$940–980 M/s at 1M samples — effectively memory-bandwidth limited. There is no penalty for using Armadillo column storage vs.
std::vector. - BlockCachedMmap degrades catastrophically at scale. At 100K samples with 384 channels, throughput drops to 0.73 M/s — over 1000x slower than contiguous storage. This is caused by per-element mutex acquisition and block-lookup overhead in the access path.
- Raw MemoryMapped is 5–7x slower than contiguous storage due to byte offset calculation,
memcpy, type switch, and scaling per element.
2. Vertex Generation Pipeline
This benchmark measures the full vertex generation pipeline: read → transform → materialize to vertex array. It compares the current TimeSeriesMapper::mapAnalogSeriesWithIndices() pipeline against fast-path alternatives.
Results
| Method | 10K | 100K | 500K | 1M |
|---|---|---|---|---|
| Current pipeline (Vector) | 223 M/s | 221 M/s | 213 M/s | 209 M/s |
| Span fast-path (Vector) | 1025 M/s | 1019 M/s | 898 M/s | 865 M/s |
| Span-pair path (Vector) | 1104 M/s | 1104 M/s | 973 M/s | 864 M/s |
| Current pipeline (TensorCol, 32ch) | — | 225 M/s | — | 210 M/s |
| Current pipeline (TensorCol, 384ch) | — | 224 M/s | — | — |
| Current pipeline (BlockCached, 32ch) | 70 M/s | 9.0 M/s | — | — |
| Current pipeline (BlockCached, 384ch) | 70 M/s | — | — | — |
Key Findings
- The current pipeline is $$4.1x slower than a span-based fast-path at 1M samples (209 M/s vs 865 M/s). This overhead is the combined cost of
viewTimeValueRange(), lazyviews::transform, and per-elementMappedAnalogVertexconstruction. - The span fast-path and span-pair path converge at 1M samples ($$865 M/s), suggesting they become memory-bandwidth limited at that scale.
- At small sizes (10K), the span-pair path is slightly faster (1104 M/s vs 1025 M/s), likely due to better branch prediction with paired x/y writes.
- BlockCached pipeline is dominated by storage read cost — vertex generation adds negligible overhead on top of the already-slow per-element access.
3. Cache Extraction
This benchmark measures the cost of extracting vertex data from the AnalogVertexCache ring buffer into GPU-uploadable float arrays.
Results
| Method | 10K vertices | 100K | 500K | 1M |
|---|---|---|---|---|
| Current (alloc + copy) | 21.5 µs (3.5 GiB/s) | 225 µs (3.3 GiB/s) | 1344 µs (2.8 GiB/s) | 2828 µs (2.6 GiB/s) |
| Pre-allocated | 23.7 µs | 260 µs | 1949 µs | 3443 µs |
| Zero-copy baseline | 1.75 µs (42.6 GiB/s) | 26.4 µs (28.3 GiB/s) | 299 µs (12.5 GiB/s) | 673 µs (11.1 GiB/s) |
Incremental scroll cost (window=100K, varying scroll step):
| Scroll Step | Time |
|---|---|
| 10 samples | 230 µs |
| 100 samples | 227 µs |
| 1000 samples | 240 µs |
Key Findings
- Pre-allocation does not help — it is actually slightly slower than the current alloc+copy path. The allocator is efficient for sequential same-size allocations, and the pre-allocated path has extra bookkeeping overhead.
- The zero-copy baseline (direct pointer access) is 4.2x faster at 1M vertices (673 µs vs 2828 µs). This is the theoretical speedup available if the cache stored data in GPU-upload-ready format.
- Scroll step size has minimal impact on extraction cost — the cache always re-extracts the full window. This indicates the current cache is not truly incremental; it rebuilds the extraction buffer every frame regardless of how much actually changed.
4. Min/Max Decimation
This benchmark measures the throughput of min/max decimation algorithms, which reduce \(N\) samples to \(2 \times \text{canvas\_width}\) vertices (one min and one max per pixel column).
Results (1M input samples)
| Method | 1K bins | 2K bins | 4K bins |
|---|---|---|---|
| Span, allocating | 880 M/s | 884 M/s | 874 M/s |
| Span, in-place | 869 M/s | 888 M/s | 819 M/s |
| Generic (Vector) | 896 M/s | 878 M/s | — |
| Generic (BlockCached, 32ch) | 10.0 M/s | 10.0 M/s | — |
| Generic (BlockCached, 384ch) | 0.71 M/s | 0.75 M/s | — |
| Raw vertices (no decimation) | 823 M/s | — | — |
Key Findings
- Decimation is essentially free for contiguous storage — the throughput ($$880 M/s) is close to the raw vertex copy rate (823 M/s). The min/max comparison adds negligible overhead over a simple data scan.
- Output bin count does not matter. Whether we decimate to 1K or 4K bins, the bottleneck is the input scan, not the output write. This makes the algorithm well-suited for variable canvas widths.
- In-place and allocating variants perform identically for contiguous data — there is no allocation overhead to save.
- BlockCached decimation is catastrophically slow (0.71 M/s for 384ch) due to per-element storage access. Decimation cannot fix a fundamentally slow storage backend — the data must first be loaded into contiguous memory.
5. Per-Pixel Buffer Strategy
This benchmark compares a pre-allocated per-pixel output buffer (allocated once, reused across frames) against allocating a new output buffer every frame.
Single-Channel Results (1M samples)
| Canvas Width | Per-pixel (pre-alloc) | Alloc every frame |
|---|---|---|
| 1000 px | 902 M/s | 907 M/s |
| 2000 px | 888 M/s | 894 M/s |
| 4000 px | 864 M/s | — |
Multi-Channel Results (100K samples/ch)
| Channels | Canvas | Throughput | Output Vertices |
|---|---|---|---|
| 32 | 1K | 739 M/s | 64K |
| 32 | 2K | 765 M/s | 128K |
| 384 | 1K | 760 M/s | 768K |
| 384 | 2K | 754 M/s | 1.54M |
Canvas Resize Cost
| Samples | Time |
|---|---|
| 100K | 116 µs |
| 500K | 556 µs |
| 1M | 1152 µs |
Key Findings
- Pre-allocation provides no measurable throughput benefit for single-channel rendering. Modern allocators (glibc malloc) are highly optimized for repeated same-size allocations.
- Multi-channel per-pixel rendering scales linearly with channel count: 32ch at 739 M/s, 384ch at 760 M/s — throughput per channel is constant.
- Canvas resize cost is negligible ($$1.15 ms for 1M samples) — the output buffer reallocation on resize is not a concern.
6. Multi-Channel Scaling
This is the most realistic benchmark, simulating the full pipeline for multi-channel neural recordings. It tests how performance scales from 1 to 384 channels.
TensorColumn: Raw vs. Decimated (1920 px canvas)
| Channels | Samples/ch | Raw (M/s) | Decimated (M/s) | Raw Vertices | Decimated Vertices | Raw Time | Decimated Time |
|---|---|---|---|---|---|---|---|
| 32 | 30K | 582 | 632 | 960K | 123K | 1.65 ms | 1.53 ms |
| 128 | 30K | 633 | 615 | 3.84M | 492K | 6.07 ms | 6.24 ms |
| 384 | 30K | 541 | 618 | 11.5M | 1.47M | 21.3 ms | 18.6 ms |
| 32 | 100K | 648 | 764 | 3.2M | 123K | 4.94 ms | 4.19 ms |
| 128 | 100K | 536 | 775 | 12.8M | 492K | 23.9 ms | 16.5 ms |
| 384 | 100K | 544 | 766 | 38.4M | 1.47M | 71.2 ms | 50.1 ms |
| 32 | 300K | 530 | 817 | 9.6M | 123K | 18.3 ms | 11.8 ms |
| 128 | 300K | 543 | 791 | 38.4M | 492K | 70.7 ms | 48.5 ms |
BlockCached: Raw vs. Decimated
| Channels | Samples/ch | Raw (M/s) | Decimated (M/s) | Raw Time | Decimated Time |
|---|---|---|---|---|---|
| 32 | 30K | 78.5 | 76.4 | 12.2 ms | 12.6 ms |
| 128 | 30K | 75.9 | 75.4 | 50.6 ms | 50.9 ms |
| 32 | 100K | 8.6 | 8.8 | 372 ms | 365 ms |
Channel Scaling (Decimated TensorColumn, 100K samples/ch, 1920 px canvas)
| Channels | Time | Throughput | Output Vertices |
|---|---|---|---|
| 1 | 0.12 ms | 833 M/s | 3.8K |
| 4 | 0.49 ms | 824 M/s | 15.4K |
| 16 | 2.09 ms | 767 M/s | 61.4K |
| 32 | 4.24 ms | 754 M/s | 123K |
| 64 | 8.50 ms | 753 M/s | 246K |
| 128 | 16.5 ms | 774 M/s | 492K |
| 256 | 33.2 ms | 772 M/s | 983K |
| 384 | 49.6 ms | 775 M/s | 1.47M |
Key Findings
- Decimation advantage grows with data size. At 384ch × 300K samples (not tested, but extrapolated from 128ch × 300K), the raw pipeline would produce $$115M vertices while decimated produces $$1.5M — a 78x vertex reduction.
- At 384ch × 100K samples, decimation reduces wall-clock time from 71.2 ms → 50.1 ms (30% improvement). The improvement is modest because the decimation scan still touches every input sample; the savings come from reduced vertex materialization and output.
- Channel scaling is perfectly linear for decimated TensorColumn: doubling channels doubles time, while per-channel throughput stays constant at $$775 M/s.
- BlockCached is 70–85x slower than TensorColumn regardless of whether decimation is applied. Decimation cannot compensate for a slow storage backend.
7. Memory Profile (Heaptrack)
The bm_rendering_memory_profile target was run under heaptrack to measure allocation patterns. All scenarios use TensorColumn storage.
Allocation Summary
| Metric | Value |
|---|---|
| Total allocations | 777,228 |
| Temporary allocations | 60,630 (7.8%) |
| Peak heap consumption | 538.85 MB |
| Allocation rate | 65,922 allocs/s |
Per-Scenario Vertex Counts
| Scenario | Method | Scroll Frames | Total Vertices | Time |
|---|---|---|---|---|
| A: 32ch Interactive (100K window) | Current (alloc/frame) | 100 | 320M | 438 ms |
| A: 32ch Interactive (100K window) | Decimated (alloc once) | 100 | 12.3M | 436 ms |
| B: 384ch Stress (100K window) | Current (alloc/frame) | 10 | 384M | 497 ms |
| B: 384ch Stress (100K window) | Decimated (alloc once) | 10 | 14.7M | 549 ms |
| C: 384ch Zoomed (10K window) | Current (alloc/frame) | 50 | 192M | 268 ms |
| C: 384ch Zoomed (10K window) | Decimated (alloc once) | 50 | 73.7M | 491 ms |
Peak Memory Consumers
| Source | Peak Consumption |
|---|---|
Armadillo Mat (TensorColumn data) |
460.80 MB |
| libtorch static initialization | 21.58 MB |
std::vector allocations (rendering) |
11.83 MB |
Key Findings
- 460 MB is consumed by the Armadillo matrix backing TensorColumn storage. This is the data itself, not the rendering pipeline.
- The rendering pipeline’s
std::vectorallocations peak at 11.83 MB — modest compared to the underlying data. - The “current pipeline” generates 100K vectors per frame (32ch × 100K samples = 3.2M × 8 bytes = 25.6 MB per frame, freed immediately). Over 100 frames, this is 2.56 GB of churn — all temporary allocations that stress the allocator and fragment the heap.
- The “decimated” method allocates 384 output buffers once ($$12 MB total) and reuses them. The allocation count drops to effectively zero per frame.
- Scenario C (zoomed) shows the decimated path is actually slower than current (491 ms vs 268 ms). This is because at 10K samples/ch with 1920 px canvas, the decimation ratio is only $$2.6x (10K / 3840), so the overhead of the decimation loop exceeds the savings from reduced output.
Conclusions and Recommendations
What We Learned
The biggest bottleneck is
viewTimeValueRange(). The current rendering pipeline pays a 2.3x penalty using the time+value accessor path instead of direct span access. Switching to a span-based data read would immediately improve vertex generation throughput from $$209 M/s to $$865 M/s — a 4.1x speedup at the data-read stage.Decimation helps, but mostly for vertex count reduction. The decimation scan itself runs at near-memory-bandwidth speeds ($$880 M/s). The real savings come downstream: fewer vertices to materialize, cache, and upload to GPU. At 384ch × 100K, decimation reduces output from 38.4M to 1.47M vertices — a 26x reduction in GPU upload data.
Pre-allocation and in-place buffers provide no measurable benefit for the compute-side pipeline. Modern allocators handle repeated same-size allocations efficiently. The benefit of pre-allocation would only appear in reducing allocation count (reducing heap fragmentation and GC pressure over long sessions), not in per-frame throughput.
BlockCachedMmap is fundamentally incompatible with real-time rendering. At 70–85x slower than TensorColumn, no amount of algorithmic optimization at the rendering layer can compensate. If mmap data needs real-time visualization, it must be pre-loaded into contiguous memory (either full copy or block-level pre-fetch).
Channel scaling is perfectly linear for contiguous storage. There are no super-linear effects from cache pressure or memory bandwidth saturation up to 384 channels. This means the rendering pipeline can be straightforwardly parallelized if needed.
The cache extraction layer is not truly incremental. Scrolling by 10 samples costs the same as scrolling by 1000 samples — the entire window is re-extracted every frame. A true incremental approach (ring buffer with only-new-data extraction) would reduce scroll costs proportionally to scroll step.
Recommended Optimizations (Priority Order)
Add a span-based fast-path for contiguous storage in the vertex generation pipeline. When the storage backend supports
getDataInTimeFrameIndexRange()returning a contiguousstd::span, bypassviewTimeValueRange()entirely. Expected improvement: 4x at the data-read stage.Implement min/max decimation when
samples_per_pixel > threshold(e.g., > 4). Output 2 vertices per pixel column (min, max). This reduces vertex count by up to 100x for zoomed-out views and costs essentially nothing beyond the data scan.Use direct-to-GPU vertex format in the cache. Instead of caching
CachedAnalogVertex{x, y, TimeFrameIndex}(24 bytes) and then copying tofloat[2](8 bytes), store the GPU-ready format directly. This eliminates the extraction copy entirely — a 4.2x speedup for the cache extraction stage.Make cache extraction truly incremental. Track the last-extracted range and only extract newly-visible samples on scroll. For small scroll steps, this would reduce extraction cost from \(O(W)\) to \(O(\Delta)\).
Pre-load mmap data into contiguous buffers before rendering. For BlockCachedMmap, perform a bulk read of the visible window into a temporary
std::vector<float>and render from that. This converts a 70x-slower per-element path into a single bulk I/O + contiguous render.
Performance Budget (384ch × 100K samples, 1920 px canvas)
| Stage | Current | With Recommendations | Improvement |
|---|---|---|---|
| Data read | 71.2 ms | ~17.8 ms (span path) | 4x |
| Vertex generation | (included above) | ~17.8 ms | — |
| Decimation | — | ~0 ms (folded into read) | — |
| Cache extraction | ~4 ms | ~0 ms (zero-copy) | — |
| GPU upload | ~5 ms (38.4M verts) | ~0.2 ms (1.47M verts) | 25x |
| Total CPU | ~80 ms | ~18 ms | ~4.4x |
| Frame rate | ~12 FPS | ~55 FPS | — |
These numbers exclude Qt overhead, OpenGL state changes, and actual fragment shading. The CPU-side rendering budget of $$18 ms would comfortably support 60 FPS interactive browsing even at 384-channel scale.