Repository navigation
Description
Context
This issue was first published as the consolidated profiling report, then rewritten as this coordination meta-issue. A fresh optimized profiling build, five complete Rust/C benchmark passes, five focused CPU samples, and C/Rust full-app recording profiles identified 22 of 70 benchmark comparisons above the project's 10% median slowdown bound. Nine implementation/investigation sub-issues cover every one of those 22 cases; a tenth covers the release-hardware recording evidence and noisy measurements.
Proposal and native sub-issues
Start with dstr safe formatting (58.2× at 4096 bytes), then concatenation and rounding. Confirm tiny/noisy candidates before coding. Claim an individual child, not the entire meta-issue. GitHub's native sub-issue list tracks progress; the links here explain scope.
- bug: dstr: safe formatting is 6.6–58.2× slower than C #1296 — bug: dstr: safe formatting is 6.6–58.2× slower than C (2 benchmark cases).
- bug: dstr: concatenation copies the entire buffer through an owned model #1297 — bug: dstr: concatenation copies the entire buffer through an owned model (2 benchmark cases).
- bug: graphics: vec2 ceil and floor regress against C code generation #1298 — bug: graphics: vec2 ceil and floor regress against C code generation (2 benchmark cases).
- chore: graphics: verify small vec2 abs and vec3 rand regressions #1299 — chore: graphics: verify small vec2 abs and vec3 rand regressions (2 benchmark cases).
- chore: bmem: verify allocator and allocation-counter overhead #1300 — chore: bmem: verify allocator and allocation-counter overhead (2 benchmark cases).
- bug: codec: AVC and HEVC keyframe scans exceed the Rust performance bound #1301 — bug: codec: AVC and HEVC keyframe scans exceed the Rust performance bound (4 benchmark cases).
- bug: codec: small AVC and HEVC header extraction regress against C #1302 — bug: codec: small AVC and HEVC header extraction regress against C (2 benchmark cases).
- bug: codec: AV1 keyframe OBU walking exceeds the Rust performance bound #1303 — bug: codec: AV1 keyframe OBU walking exceeds the Rust performance bound (2 benchmark cases).
- bug: codec: AV1 header and metadata output allocation regresses against C #1304 — bug: codec: AV1 header and metadata output allocation regresses against C (4 benchmark cases).
- chore: performance: establish hardware recording evidence and confirm noisy regressions #1305 — chore: performance: establish hardware recording evidence and confirm noisy regressions.
Complete regression inventory
| Benchmark | Rust ns | C ns | Rust/C | Paired run ratio range |
|---|---|---|---|---|
av1/extract/16384 |
741.258 | 588.611 | 1.259× | 1.205–1.423× |
av1/extract/256 |
235.976 | 159.787 | 1.477× | 1.160–3.133× |
av1/keyframe/16384 |
18.908 | 13.571 | 1.393× | 1.090–1.539× |
av1/keyframe/256 |
19.827 | 15.095 | 1.313× | 1.313–1.892× |
av1/metadata |
57.698 | 38.303 | 1.506× | 1.425–1.506× |
av1/metadata_itu_t35 |
55.405 | 40.521 | 1.367× | 1.163–1.647× |
avc/extract/256 |
301.855 | 240.697 | 1.254× | 0.338–1.636× |
avc/keyframe/16384 |
60.921 | 45.725 | 1.332× | 1.223–1.699× |
avc/keyframe/256 |
67.491 | 53.719 | 1.256× | 0.953–1.454× |
bmem/alloc_free/64 |
14.582 | 12.271 | 1.188× | 1.090–2.894× |
bmem/count |
1.826 | 1.514 | 1.207× | 0.595–1.370× |
dstr/cat/128 |
195.969 | 86.049 | 2.277× | 1.956–2.540× |
dstr/cat/4096 |
438.745 | 184.339 | 2.380× | 1.751–2.768× |
dstr/safe_printf/128 |
1424.165 | 215.802 | 6.599× | 5.926–9.126× |
dstr/safe_printf/4096 |
26033.556 | 447.311 | 58.200× | 58.135–70.310× |
hevc/extract/256 |
399.055 | 294.933 | 1.353× | 0.985–2.892× |
hevc/keyframe/16384 |
77.284 | 53.485 | 1.445× | 1.360–1.568× |
hevc/keyframe/256 |
90.273 | 62.659 | 1.441× | 1.330–1.796× |
vec2/abs |
3.062 | 2.392 | 1.280× | 1.199–1.370× |
vec2/ceil |
8.940 | 3.615 | 2.473× | 1.698–2.618× |
vec2/floor |
8.945 | 5.214 | 1.716× | 1.705–2.384× |
vec3/rand/1 |
30.279 | 24.239 | 1.249× | 0.993–1.249× |
Measurement context
Measured on 2026-10-17, AMD Ryzen 7 3700X, Linux x86_64, CPU affinity 7, Rust 1.98.1, GCC 15.2.0. Five complete passes of all 70 paired Criterion comparisons; 30 samples/case/pass, 0.1 s warmup, 0.4 s measurement, 10,000 resamples. Values below are medians of the five pass medians. The ratio range contains the five paired Rust/C ratios; the reported median ratio divides the two backend medians.
CARGO_PROFILE_BENCH_DEBUG=1 RUSTFLAGS='-C force-frame-pointers=yes' \
uv run rust/tools/benchmarks/record.py --cpu 7 --repeats 5 --output baseline.jsonThe optimized profiling build completed in 40.99 s. Recorded end-of-run HEAD: b56092cc66a979b2f543da20846b965c3517ac36. The checkout was shared and HEAD moved during work; the recorder's source fingerprint stayed unchanged across all five timing passes: 5eea3716b30cf03831eacbc1f06711c2c622f915ebd8945a6940e6fab9d0d422. Source links use fetched master; the fingerprint identifies the measured benchmark/implementation input set. Baseline JSON SHA-256: 9517eb96c66a484cf305a13758a856d893f4608ee454c1a6ea16f693f62c4f26.
This was a shared host. The application build ran on CPUs 0–3 during part of the CPU-7 benchmark run, and other workloads were present. Wide ranges and nanosecond-scale differences require confirmation on quiet release hardware. A descriptive threshold crossing is not proof of statistical significance. The C oracle uses Cargo's optimized C build, rather than full OBS C IPO; profiling frame pointers also affect tiny call costs. No cross-platform or whole-application speedup/slowdown is inferred from shim benchmarks. dstr/printf_control remains C in both configurations and is excluded from Rust regression decisions.
Local evidence: /home/niteris/dev/obs-rust/reports/obs-profile-20261017/ contains baseline.json (per-run medians/confidence intervals), build logs, perf data/reports, assembly, runtime logs/maps/results, and the profiling harness. Raw Criterion samples are in target/criterion, baselines ports-20261017T172745Z-1 through ports-20261017T172745Z-5. Key evidence is reproduced here so triage does not depend on local file access.
Full application profile
Built libobs-with-rust and obs-studio in the existing build_host RelWithDebInfo tree (cmake --build build_host --target libobs-with-rust obs-studio -j 4, pinned to CPUs 0–3). Missing propagated host include paths were supplied through process-scoped CPATH; no source fix was made. C and Rust libobs were selected by LD_LIBRARY_PATH; /proc/PID/maps verified the Rust twin for the ON run and its absence for the C control. Qt 6.11.1 plugin paths were isolated from the desktop's 6.11.2 plugins after an initial environment-related Qt abort. The config and X display were isolated; no desktop capture or microphone source was used.
Workload: Xvfb, 1920×1080 at 30 fps, color and FreeType text sources, x264 veryfast recording to MKV, 3 s warmup followed by a 30 s CPU sampling window and 15 GetStats observations. Recordings started/stopped successfully and processes exited; both logs report one remaining OBS allocation. No leak root cause or performance attribution is established here.
| Run | PID | Observed window | Median reported render ms (observation range) | Render skips / frames during window | Encoder skips / frames during window |
|---|---|---|---|---|---|
| Rust twin | 2806160 | 31.35 s | 37.780 (12.088–52.069) | 116 / 910 | 39 / 951 |
| C control | 2812278 | 31.32 s | 13.395 (11.615–66.577) | 55 / 909 | 0 / 910 |
These are single diagnostic runs, not independent-run medians or a valid default-flip comparison. The log explicitly reports Mesa llvmpipe, despite detecting the RTX 3060. Perf attributes Rust-run sampled cycles to JIT code (54.91%), Mesa libgallium (18.56%), and x264 (16.28%); C control is similar (55.85%, 19.47%, 14.48%). Do not attribute JIT symbols to Rust: these are software-rendering JIT samples. The Rust capture has ~18K cycle samples and 70 lost samples; C ~19K and 82 lost samples, with kernel symbols unavailable. This identifies software rendering as the dominant workload cost and leaves the observed Rust/C frame difference unexplained. Xvfb software rendering is expected here; it does not establish a product driver regression. Hardware-backed repeated recording comparisons without sampling overhead remain necessary before applying the release criteria's 5% gate.
Sampling command for each application PID:
perf record -F 199 -g --call-graph dwarf,16384 -p PID -o perf.data -- sleep 30Focused CPU samples
The benchmark executable was built with optimization, debug symbols and frame pointers. Profiles include Criterion fixture setup; paired timing regions exclude setup where the harness specifies it. Sample percentages must not be mistaken for a breakdown of timed-only costs.
perf record -e cycles:u -F 199 -g --call-graph dwarf,16384 -o CASE.perf.data -- \
taskset -c 7 target/release/deps/port_comparison-d7b18639337cde09 \
--bench CASE --profile-time SECONDS| Case | PID | Requested window | First-to-last sample | Main finding |
|---|---|---|---|---|
dstr/safe_printf/4096/rust |
2803484 | 10 s | 9.791 s | 1,966 samples; 67.88% memcmp via Dstr::replace, 19.70% Dstr::replace |
dstr/cat/4096/rust |
2825615 | 5 s | 5.049 s | 1,018 samples; Dstr::copy prominent, including fixture setup |
hevc/keyframe/16384/rust |
2827511 | 5 s | 5.201 s | 1,045 samples; 73.41% find_startcode, 22.52% obs_hevc_keyframe |
av1/extract/256/rust |
2829446 | 5 s | 5.479 s | 1,080 samples; allocation/free/realloc and memmove prominent |
vec2/ceil/rust |
2832754 | 5 s | 4.759 s | 956 samples; ceilf calls confirmed by disassembly |
All five focused profiles reported zero lost samples. Sampling and disassembly support the targeted investigations; the child issues distinguish confirmed code structure from unproven causes.
Acceptance criteria
- All ten listed children are native sub-issues, with every measured threshold crossing assigned to exactly one implementation/investigation child.
- Each fix supplies focused RED → GREEN performance evidence and the applicable Rust/C compatibility checks; noisy candidates may close with a supported negative result.
- Record release-hardware confirmation of all affected hot paths against the existing <=10% bound. A remaining regression needs explicit acceptance of measured user impact in a separate issue.
- Complete the separate hardware recording comparison under the existing <=5% frame-time/dropped-frame gate. This diagnostic llvmpipe profile cannot approve the Rust default flip.
Decisions
Group benchmark input sizes and codecs where they share the concrete implementation target. P1 for the largest dstr formatting regression; other confirmed paths and investigations P2. Priorities are triage defaults, not measurements of user-visible impact. Tiny or variable ratios are investigations, not established bottlenecks. No new workflow or production code change is part of this report. This inventory covers all findings from these workloads; it does not claim exhaustive discovery on unmeasured platforms, sources, drivers or encoders.
Related issues
#142 delivered the benchmark harness and historical baseline; it did not fix the regressions. #756 discusses experimental SIMD and recording harness work. #891 covers non-FHS hardware dependency discovery; intentional Xvfb software rendering is not evidence that its product bug recurred.
All 70 measured pairs (including passing cases and C formatting controls)
| Benchmark | Rust ns | C ns | Rust/C | Paired run ratio range |
|---|---|---|---|---|
av1/extract/16384 |
741.258 | 588.611 | 1.259× | 1.205–1.423× |
av1/extract/256 |
235.976 | 159.787 | 1.477× | 1.160–3.133× |
av1/keyframe/16384 |
18.908 | 13.571 | 1.393× | 1.090–1.539× |
av1/keyframe/256 |
19.827 | 15.095 | 1.313× | 1.313–1.892× |
av1/metadata |
57.698 | 38.303 | 1.506× | 1.425–1.506× |
av1/metadata_itu_t35 |
55.405 | 40.521 | 1.367× | 1.163–1.647× |
avc/extract/16384 |
1643.882 | 3857.074 | 0.426× | 0.395–0.485× |
avc/extract/256 |
301.855 | 240.697 | 1.254× | 0.338–1.636× |
avc/header/16384 |
647.318 | 2827.131 | 0.229× | 0.203–0.308× |
avc/header/256 |
226.970 | 403.178 | 0.563× | 0.407–0.590× |
avc/keyframe/16384 |
60.921 | 45.725 | 1.332× | 1.223–1.699× |
avc/keyframe/256 |
67.491 | 53.719 | 1.256× | 0.953–1.454× |
avc/packet/16452 |
1205.878 | 4014.329 | 0.300× | 0.250–0.352× |
avc/packet/324 |
193.155 | 554.613 | 0.348× | 0.331–0.382× |
avc/priority/16452 |
720.508 | 3081.047 | 0.234× | 0.210–0.286× |
avc/priority/324 |
105.926 | 100.952 | 1.049× | 0.890–1.510× |
avc/startcode/16384 |
533.008 | 2763.405 | 0.193× | 0.159–0.218× |
avc/startcode/256 |
19.087 | 67.568 | 0.282× | 0.221–0.395× |
bmem/alignment |
1.802 | 1.654 | 1.089× | 0.539–1.411× |
bmem/alloc_free/4096 |
39.334 | 37.788 | 1.041× | 0.894–4.455× |
bmem/alloc_free/64 |
14.582 | 12.271 | 1.188× | 1.090–2.894× |
bmem/alloc_free/65536 |
54.088 | 53.169 | 1.017× | 0.853–1.096× |
bmem/allocate/4096 |
20.220 | 18.933 | 1.068× | 0.899–1.222× |
bmem/allocate/64 |
15.079 | 14.988 | 1.006× | 0.560–1.049× |
bmem/allocate/65536 |
2041.125 | 2034.789 | 1.003× | 0.964–1.054× |
bmem/count |
1.826 | 1.514 | 1.207× | 0.595–1.370× |
bmem/dup_free/4096 |
95.177 | 103.469 | 0.920× | 0.846–1.267× |
bmem/dup_free/64 |
14.998 | 19.926 | 0.753× | 0.741–0.944× |
bmem/dup_free/65536 |
1258.044 | 1250.331 | 1.006× | 0.980–1.105× |
bmem/free/4096 |
15.410 | 18.629 | 0.827× | 0.790–1.014× |
bmem/free/64 |
8.326 | 8.679 | 0.959× | 0.905–6.838× |
bmem/free/65536 |
507.860 | 561.871 | 0.904× | 0.875–1.004× |
bmem/realloc/4096 |
153.435 | 155.759 | 0.985× | 0.884–1.105× |
bmem/realloc/64 |
34.856 | 34.695 | 1.005× | 0.906–1.116× |
bmem/realloc/65536 |
49637.167 | 51308.878 | 0.967× | 0.915–1.101× |
crc32/4096 |
8252.245 | 8378.042 | 0.985× | 0.782–1.083× |
crc32/64 |
122.169 | 115.073 | 1.062× | 0.983–1.092× |
crc32/65536 |
136296.663 | 136829.276 | 0.996× | 0.985–1.172× |
dstr/cat/128 |
195.969 | 86.049 | 2.277× | 1.956–2.540× |
dstr/cat/4096 |
438.745 | 184.339 | 2.380× | 1.751–2.768× |
dstr/printf_control/128 |
292.692 | 285.304 | 1.026× | 0.960–1.196× |
dstr/printf_control/4096 |
840.121 | 824.470 | 1.019× | 0.946–1.397× |
dstr/replace/128 |
793.902 | 1449.305 | 0.548× | 0.447–0.582× |
dstr/replace/4096 |
14485.433 | 82891.174 | 0.175× | 0.155–0.227× |
dstr/safe_printf/128 |
1424.165 | 215.802 | 6.599× | 5.926–9.126× |
dstr/safe_printf/4096 |
26033.556 | 447.311 | 58.200× | 58.135–70.310× |
hevc/extract/16384 |
1756.800 | 3588.904 | 0.490× | 0.486–0.494× |
hevc/extract/256 |
399.055 | 294.933 | 1.353× | 0.985–2.892× |
hevc/keyframe/16384 |
77.284 | 53.485 | 1.445× | 1.360–1.568× |
hevc/keyframe/256 |
90.273 | 62.659 | 1.441× | 1.330–1.796× |
hevc/packet/16478 |
1235.643 | 4220.063 | 0.293× | 0.251–0.310× |
hevc/packet/350 |
231.803 | 619.850 | 0.374× | 0.328–0.418× |
hevc/priority/16478 |
662.063 | 2931.054 | 0.226× | 0.213–0.234× |
hevc/priority/350 |
112.957 | 123.818 | 0.912× | 0.794–1.039× |
vec2/abs |
3.062 | 2.392 | 1.280× | 1.199–1.370× |
vec2/ceil |
8.940 | 3.615 | 2.473× | 1.698–2.618× |
vec2/close |
2.672 | 2.579 | 1.036× | 0.854–1.240× |
vec2/floor |
8.945 | 5.214 | 1.716× | 1.705–2.384× |
vec2/norm |
3.448 | 3.958 | 0.871× | 0.871–1.275× |
vec3/from_vec4 |
9.181 | 8.579 | 1.070× | 1.013–1.091× |
vec3/mirror |
6.695 | 11.866 | 0.564× | 0.340–0.588× |
vec3/mirrorv |
6.389 | 9.054 | 0.706× | 0.504–0.782× |
vec3/plane_dist |
2.463 | 2.442 | 1.008× | 0.927–1.229× |
vec3/rand/0 |
28.475 | 34.199 | 0.833× | 0.575–1.070× |
vec3/rand/1 |
30.279 | 24.239 | 1.249× | 0.993–1.249× |
vec3/rotate |
8.331 | 9.353 | 0.891× | 0.492–1.411× |
vec3/transform |
6.598 | 24.936 | 0.265× | 0.179–0.295× |
vec3/transform3x4 |
9.210 | 10.481 | 0.879× | 0.626–0.918× |
vec4/from_vec3 |
8.799 | 8.572 | 1.026× | 0.946–1.205× |
vec4/transform |
4.509 | 10.453 | 0.431× | 0.385–0.476× |
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTracker
Activity
[-]perf: profiling report for Rust hot paths and recording workload[/-][+]meta: resolve OBS Rust profiling regressions and validate recording performance[/+]