Repository navigation
Description
Unit
libobs/util/profiler-io.c.h (363 lines) into rust/obs-util. It is the print and CSV half of util/profiler.c, left C when the profiler (#152) and the snapshot accessors were ported:
profiler_print,profiler_print_time_between_calls(log lines throughblog)profiler_snapshot_dump_csv,profiler_snapshot_dump_csv_gz(file output; gzip through zlib)profile_print_func: non-static but notEXPORT; nothing else calls it. Ported as a hidden shim (rust-hidden.txt), so the exported symbol sets stay identical.- statics:
make_indent_string,gather_stats,gather_stats_between,profile_print_entry,profile_print_entry_expected,entry_dump_csv,profiler_snapshot_dump,dump_csv_fwrite,dump_csv_gzwrite
Phase and position
Unit 3 of #1846. The recording engine (obs-util::profiler) and the snapshot accessors (obs-util::profiler_snapshot) are Rust; this removes the last C of the profiler except its variadic profile_store_name (profiler-variadic.c.h). It also takes the two _WIN32 conditionals of this file listed in #874 (gzopen_w/gzclose_w): Rust opens the file through platform::path_from_bytes, so the host split leaves the C.
Dependencies and existing tests
- Snapshots: read in place through the existing
#[repr(C)]mirrors inffi::profiler_snapshot;NULLtakes and frees a snapshot through the portedprofile_snapshot_create/profile_snapshot_free. - Number and pointer spelling:
%gand%pgo through the C runtime'ssnprintfinplatform::stdio(asos_dtostrandconfig_set_default_doublealready do), sonan/infand pointer spellings match the host C exactly. - gzip: zlib is replaced by
flate2(pure-Rustminiz_oxidebackend), so neither libobs-rust nor the Rust test runners need zlib (the Windows runners have none). The oracle compilesprofiler-io.c.hwith a pass-through stand-in for the four zlib calls, so Tier 3 compares the decompressed Rust output with the C's uncompressed bytes. - Logging: the shim calls
blog(LOG_INFO, "%s", line)like the C. test_profileronly checks the CSV header. A characterization testtest/cmocka/test_profiler_io.clands first: every print line for a hand-built snapshot,NULLsnapshots, exact CSV bytes, truncation, empty snapshot, gzip magic, failure paths.
Characterized, not endorsed: a median on the boundary of two time entries prints as 0 ms; a calls-per-parent ratio that rounds to 1.0 is not printed.
Intentional differences:
- The
.csv.gzstream is deflated by miniz_oxide, not zlib: the compressed bytes (and the gzip header's OS byte) differ, the decompressed CSV is identical. - A snapshot entry with a NULL name (never produced by the profiler; C passes NULL to
%s, undefined behavior) prints an empty name.
Plan
One PR:
- Characterization:
test/cmocka/test_profiler_io.c, registered intest/cmocka/build/test-graph.json. - RED:
obs-util::profiler_iosafe core andffi::profiler_ioshim withtodo!(); Tier 1 tests intests/profiler/profiler_io.rs; export fragmentrust-exports.d/obs-util-profiler_io.txt. - GREEN: the port;
profiler-io.c.hmoves to a ported group; Tier 3 proptest parity against the oracle (log lines and CSV / decompressed CSV.gz bytes for random snapshot trees); Tier 2 runstest_profilerandtest_profiler_ioagainst hybrid and C reference;port_comparisonbench. - Tier 4 does not apply.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Oct 23, 2026
Claiming: profiler-io port (unit 3 of #1846), one PR, branch port/profiler-io.
util: Test profiler-io against a Rust stub (RED)
util: Port profiler-io to obs-util (GREEN)
zackees commentedon Oct 23, 2026
Draft PR #1875 (RED 75266c5, GREEN 283e295). One more intentional difference found by Tier 3: an expected time above u64::MAX / 1.02 saturates the ±2% bound in Rust, where the C's (uint64_t) conversion is undefined; excluded from the parity inputs.
util: Silence -Wformat-nonliteral in the profiler-io oracle capture
util: Test profiler-io against a Rust stub (RED)
util: Port profiler-io to obs-util (GREEN)
util: Silence -Wformat-nonliteral in the profiler-io oracle capture
util: Test profiler-io against a Rust stub (RED)
util: Port profiler-io to obs-util (GREEN)
util: Silence -Wformat-nonliteral in the profiler-io oracle capture
util: Test profiler-io against a Rust stub (RED)
util: Port profiler-io to obs-util (GREEN)
util: Silence -Wformat-nonliteral in the profiler-io oracle capture
util: Port profiler-io to obs-util (obs-rust#1875)