Repository navigation
util: Port profiler-io to obs-util - #1875
Merged
Merged
Conversation
zackees
force-pushed
the
port/profiler-io
branch
from
October 23, 2026 03:47
7160e73 to
283e295
Compare
zackees
marked this pull request as ready for review
October 23, 2026 04:20
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 23, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 23, 2026
Member
Author
|
Coordinator: this was ejected from the queue twice. The cause is on master, not in this PR: |
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 23, 2026
zackees
force-pushed
the
port/profiler-io
branch
from
October 23, 2026 05:39
28323b2 to
70ce1fa
Compare
zackees
added a commit
that referenced
this pull request
Oct 23, 2026
Master's test graph gained two core tests while this PR was queued, so the core partition now holds 142 tests (#1875 adds test_profiler_io).
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 23, 2026
zackees
force-pushed
the
port/profiler-io
branch
from
October 23, 2026 05:42
70ce1fa to
2a0f4eb
Compare
zackees
enabled auto-merge
October 23, 2026 05:42
Member
Author
|
Coordinator: #1896 landed. I rebased this PR onto it and set the core count to 142 (141 on master, plus this PR's |
test_profiler_io pins what libobs/util/profiler-io.c does today, which test_profiler only touches through the CSV header line. It builds a snapshot by hand through the private profiler-snapshot.h layout, so every time and count is fixed, and checks: - profiler_print: every log line, with the tree pipes, the min == max form, the expected-time percentage and calls per parent call; - profiler_print_time_between_calls: the within/lower/higher split, the all-within and all-higher shortcuts, and that entries without an expected time print nothing (nor do their children); - profiler_print(NULL) and _time_between_calls(NULL) on a profiler that never ran: intro and footer only; - profiler_snapshot_dump_csv: the exact bytes (pointer columns spelled by the same C runtime's %p), truncation of an existing file, an empty snapshot, and failure on a missing directory; - profiler_snapshot_dump_csv_gz: a gzip stream, and failure on a missing directory. Two quirks are characterized, not endorsed: a median that lands on the boundary between two time entries prints as 0 ms, and a calls-per-parent ratio that rounds to 1.0 is not printed. Registered in the native test graph like test_profiler. Refs #1846
rust/obs-util/src/profiler_io.rs holds the safe core with todo!() bodies:
the indent string, gather_stats / gather_stats_between, the two report
printers over any Entry tree, the CSV walk and the CSV / CSV.gz file
writers. %g and %p go through the C runtime's snprintf
(platform::snprintf_double, new platform::snprintf_ptr); gzip is flate2
over miniz_oxide, so neither libobs-rust nor the test runners need zlib.
ffi/profiler_io.rs is the C ABI shim: profiler_print,
profiler_print_time_between_calls, profiler_snapshot_dump_csv and
_csv_gz (rust-exports.d/obs-util-profiler_io.txt), and profile_print_func,
which the C never exports, hidden in rust-hidden.txt, rust-exports.map and
rust-unexports-macos.txt. Lines go to blog(LOG_INFO, "%s", line).
profiler-io.c.h moves to its own ported group, libobs.ported-profiler-io,
with libobs-ported-profiler-io.pch.h (zlib leaves libobs.pch.h). The
oracle compiles it as oracle_* (oracle/profiler_io.c) over a
pass-through <zlib.h> stand-in (oracle/zlib-shim).
Tier 1 (tests/profiler/profiler_io.rs) ports test_profiler_io.c and adds
stats, rounding and pipe edge cases: all 9 fail on
todo!("profiler-io port").
Refs #1870
Refs #1846
The core follows profiler-io.c step for step over any Entry tree: the indent pipes (with the C's int-shift mask for the last child), gather_stats and gather_stats_between in the same double arithmetic, the two report printers, and the CSV walk (times rows, then between-call rows, then children). %g and %p are the C runtime's snprintf, so every line and CSV byte is the C's on the same host. The CSV file is created or truncated and write errors are ignored, as the C ignores fwrite; the gz file is gzip level 6 through flate2. - Tier 1 (tests/profiler/profiler_io.rs): all 9 cases pass. - Tier 3 (profiler_io_parity.rs): proptest against the oracle on random snapshot trees (depth 4, repeated names, zero and u64-sized times and counts, so nan/inf and e-notation occur): every logged line of both reports, and the CSV and CSV.gz bytes with the address columns mapped to walk order; profile_print_func's printer calls; missing-directory failures. A thread-owned log capture in oracle/profiler_io.c keeps other tests' lines out, and a shared LOG_HANDLER_LOCK (tests/common) serializes it with base_parity.rs. - Mutation check: 0.98 -> 0.97 in print_entry_expected fails print_parity on its first case. - port_comparison: profiler_snapshot_dump_csv (8 roots x 8 children, 32 + 32 rows each), Rust 5.05 ms vs C 8.77 ms. Intentional differences (rust/README.md, test files): gzip bytes differ (miniz_oxide, not zlib; the CSV inside is identical); NULL snapshot, file name or entry name, which the C dereferences; an expected time above u64::MAX / 1.02 saturates the +-2% bound where the C conversion is undefined (excluded from the parity inputs). Fixes #1870 Refs #1846 Refs #874
Clang (macOS Rust Tests) rejects the vsnprintf in oracle_profiler_io_log_capture under -Wformat-nonliteral; GCC's -Wformat pragma already covered it. Reproduced locally with CC=clang. Refs #1870
zackees
force-pushed
the
port/profiler-io
branch
from
October 23, 2026 05:48
2a0f4eb to
2ded418
Compare
zackees
added a commit
that referenced
this pull request
Oct 23, 2026
This was referenced Oct 23, 2026
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 23, 2026
…rust#1899) (obs-rust#1901) * test: characterize the obs-service capability and connect-info getters (obs-rust#1899) * test: run the service getter cases on one libobs and fail instead of skipping with a display (obs-rust#1899) * test: count test_service_getters on top of obs-rust#1875's core test (obs-rust#1899)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1870
Refs #1846
Refs #874
Unit 3 of #1846:
libobs/util/profiler-io.c.h→obs-util::profiler_io, as one PR.Commits
test/cmocka/test_profiler_io.c(every print line for a hand-built snapshot, NULL snapshots, exact CSV bytes, truncation, empty snapshot, gzip magic, failure paths), registered in the native test graph.todo!(), C ABI shim, export fragment, hiddenprofile_print_func, new ported grouplibobs.ported-profiler-iowith its own PCH (zlib leaveslibobs.pch.h), oracle wrapper over a pass-through<zlib.h>stand-in. All 9 Tier 1 cases intests::profiling::profiler_iofail ontodo!("profiler-io port").obs-util --lib800/800 pass locally../lintclean.Mutation check:
0.98→0.97inprint_entry_expectedfailsprint_parityon its first case.port_comparison (
profiler_snapshot_dump_csv, 8 roots × 8 children, 64 rows each): Rust 5.05 ms, C 8.77 ms.Design:
%g/%pgo through the C runtime'ssnprintf(platform::stdio, asos_dtostrdoes), so output is byte-identical per host. gzip usesflate2(miniz_oxide), so neither libobs-rust nor the Rust test runners need zlib. The file is opened throughplatform::path_from_bytes, so the Rust side has no_WIN32split (#874's two profiler-io conditionals stay only in the C reference copy).Intentional differences (rust/README.md, test files, #1870): gzip compressed bytes / header OS byte differ (CSV inside identical); NULL snapshot, file name, or entry name (C dereferences); expected time above
u64::MAX / 1.02saturates the ±2% bound (C conversion undefined; excluded from parity inputs).Tier 2:
test_profilerandtest_profiler_iorun against hybrid and C reference in PR CI (local Tier 2 was occupied by another run). Tier 4: n/a.