Repository navigation
rust: port util/profiler.c to obs-util - #248
Conversation
The recording engine stays in profiler.c. Print and the zlib CSV dump move verbatim into profiler-io.c, which both builds compile, so a later Rust port can drop profiler.c without dropping those exports.
NameStore::store returns null and profile_snapshot_create returns no roots. test_profiler_cmocka fails at the name-store assertion `!a.is_null()` (rust/obs-util/tests/profiler.rs), before the lifecycle counts run.
The recording engine, open-addressing hashmap, and snapshot builder move
to obs-util. Print and the zlib CSV dump stay in profiler-io.c.
profile_store_name stays in profiler-variadic.c and pushes through the
hidden profiler_name_store_push.
Tier 1 test_profiler_cmocka passes. Tier 3 matches the C oracle on the
lifecycle script and on 48 random call scripts, including time buckets,
under one scripted os_gettime_ns. Recording each call twice makes
lifecycle_matches_oracle fail (overall_count 5 vs 10).
Local-Gate: v1 tree=0dc0c3182f363bc6ce90ca32acec173d5dec7a9c secs=93 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791739522,"gate":"rust/all/fmt","host":"linux-x86_64","key":"d0cae094ec9dd4baa5eb48dc48010134acb659e7a7627df9c62ba68c9548ba01","lane":"lint","parents":["6d3100ea7909c8f6647079090e9441c138464ca0"],"secs":16,"stamp":"f7951355116ea57bee7aa3d44f7471fd","tree":"0dc0c3182f363bc6ce90ca32acec173d5dec7a9c","v":1,"via":"run"}
Ci-Attestation: {"at":1791739522,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"d0cae094ec9dd4baa5eb48dc48010134acb659e7a7627df9c62ba68c9548ba01","lane":"lint","parents":["6d3100ea7909c8f6647079090e9441c138464ca0"],"secs":16,"stamp":"a1866794b0a0465bc9a5f46d716847a6","tree":"0dc0c3182f363bc6ce90ca32acec173d5dec7a9c","v":1,"via":"run"}
Ci-Attestation: {"at":1791739522,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"3bdf6e80a5a5d91e938b4fe76091405b843fdffc4b3e46fffbd2da9cfcc6a4e8","lane":"rust-test","parents":["6d3100ea7909c8f6647079090e9441c138464ca0"],"secs":28,"stamp":"0ab80e57c1193667f6fc23cc85997e90","tree":"0dc0c3182f363bc6ce90ca32acec173d5dec7a9c","v":1,"via":"run"}
Ci-Attestation: {"at":1791739522,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"093d2031b7d4670ade8f516ae5e8639fcd1a7db1d1b99ffff440779554c07b3b","lane":"tier2-linux","parents":["6d3100ea7909c8f6647079090e9441c138464ca0"],"secs":48,"stamp":"79c4e32e16d74b03e1147d5b008607a6","tree":"0dc0c3182f363bc6ce90ca32acec173d5dec7a9c","v":1,"via":"run"}
|
Rebased onto master, fixed two Linux build breaks, verified and stamped. The new head is Fixes (each folded into the commit that introduced the break):
MSVC accepts both, which is probably why they didn't show up on your side. Evidence:
Merging once CI is green. |
126344b to
aafbc7b
Compare
ProfileName::from_static takes a &'static str and stores its pointer, which the profiler reads back as a C string. A &str has no NUL, so the read runs past the name: for a 3-byte slice of "abcdef" it returns hundreds of bytes of unrelated rodata. test_profiler_cmocka hit the same thing on macOS, where the byte after "test_other" is not 0 (left: 2, right: 1 at profiler.rs:190). Co-Authored-By: Claude Opus 5.5 <[email protected]>
ProfileName::from_static now takes a &'static CStr, so every name carries the NUL the profiler reads back to; a &str no longer compiles. The test names are c"..." literals. static_name_reads_back_exactly and test_profiler_cmocka pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=89e9438fc43d58735e6463bf858e37c1d2208b48 secs=88 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791740449,"gate":"rust/all/fmt","host":"linux-x86_64","key":"513fa453b2efacc1a74d0f71c9418f827e8620ba98340bc16bbadd4ad0efa4ce","lane":"lint","parents":["fa456208c4b4a3a34135c9647d1a09cd3c4452ac"],"secs":13,"stamp":"abe7eb30c7b4a67f0875041e0eed97eb","tree":"89e9438fc43d58735e6463bf858e37c1d2208b48","v":1,"via":"run"} Ci-Attestation: {"at":1791740449,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"513fa453b2efacc1a74d0f71c9418f827e8620ba98340bc16bbadd4ad0efa4ce","lane":"lint","parents":["fa456208c4b4a3a34135c9647d1a09cd3c4452ac"],"secs":13,"stamp":"2bc4bec3b8c50563c13427172c8856e5","tree":"89e9438fc43d58735e6463bf858e37c1d2208b48","v":1,"via":"run"} Ci-Attestation: {"at":1791740449,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"12de692a3e155a147c43bb113996f7984f8f7786aca2ecfc76d2cf97e5ff1da4","lane":"rust-test","parents":["fa456208c4b4a3a34135c9647d1a09cd3c4452ac"],"secs":26,"stamp":"67bda1eff185ffa944211dbbba189152","tree":"89e9438fc43d58735e6463bf858e37c1d2208b48","v":1,"via":"run"} Ci-Attestation: {"at":1791740449,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"4dfc9331f77946d33924e016365a40c8ef81f5fab43eb67e3d38c66c0a91adf4","lane":"tier2-linux","parents":["fa456208c4b4a3a34135c9647d1a09cd3c4452ac"],"secs":48,"stamp":"16be5ae771ffcd50623805d6e78d4b53","tree":"89e9438fc43d58735e6463bf858e37c1d2208b48","v":1,"via":"run"}
|
macOS Rust Tests failed: Cause: Two commits on top:
Merging once CI, including macOS, is green. |
Since obs-rust#248, obs-util exports the Rust profile_start, profile_end and profile_reenable_thread, and the audio-io oracle's no-op hooks of the same names collided at link time (rust-lld: duplicate symbol: profile_start, in every obs-media-io test binary). Rename the oracle's hooks before audio-io.c is included. Co-Authored-By: Claude Opus 5.5 <[email protected]>
oracle/profiler.c (obs-rust#248) defines a scripted os_gettime_ns for the profiler parity tests, and the audio-io oracle defined the real one, so profiler_parity failed to link (duplicate symbol: os_gettime_ns). Audio-io keeps the real clock under private names. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=4186644fea8923a5acfe9827b0d1724c6c4382ee secs=112 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791764047,"gate":"rust/all/fmt","host":"linux-x86_64","key":"15f0038c088e377d14cd58325a0e46f280243c729ff086205ac29805a56209e7","lane":"lint","parents":["6806dc73038a88c9265e5cc4deb58ef37cda1ddd"],"secs":16,"stamp":"d50d30a484537a6bc9ad91aef46d7b0b","tree":"4186644fea8923a5acfe9827b0d1724c6c4382ee","v":1,"via":"run"} Ci-Attestation: {"at":1791764047,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"15f0038c088e377d14cd58325a0e46f280243c729ff086205ac29805a56209e7","lane":"lint","parents":["6806dc73038a88c9265e5cc4deb58ef37cda1ddd"],"secs":16,"stamp":"d1de8177ce400889c11035a11705397a","tree":"4186644fea8923a5acfe9827b0d1724c6c4382ee","v":1,"via":"run"} Ci-Attestation: {"at":1791764047,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"36a0373dcf8c96780d5585411d8541906456a1362bfc70845691c22a19f1b3e5","lane":"rust-test","parents":["6806dc73038a88c9265e5cc4deb58ef37cda1ddd"],"secs":46,"stamp":"b5f961a801e226b4e43233150736f25c","tree":"4186644fea8923a5acfe9827b0d1724c6c4382ee","v":1,"via":"run"} Ci-Attestation: {"at":1791764047,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"11b51f291675aaf52fe851484317638db6be7a1fb637e16059a64ec9f2676e79","lane":"tier2-linux","parents":["6806dc73038a88c9265e5cc4deb58ef37cda1ddd"],"secs":50,"stamp":"95692a6eeb235b95cf404f1d19dd69f6","tree":"4186644fea8923a5acfe9827b0d1724c6c4382ee","v":1,"via":"run"}
Summary
Ports the
util/profiler.crecording engine toobs-util. Print and the zlib CSV dump stay inutil/profiler-io.c(always compiled).profile_store_namestays inutil/profiler-variadic.cand pushes through the hiddenprofiler_name_store_push.source-profiler.cstays out of scope.ENABLE_RUST_LIBOBSdropsutil/profiler.cand compilesutil/profiler-variadic.cinstead. Exports are inlibobs/cmake/rust-exports.d/obs-util-profiler.txt.Fixes #152
Commits
cee923a09moves print and CSV/gz intoprofiler-io.cso the oracle can compile the engine without zlib. Behavior of the C build is unchanged. The existingtest_profiler.cstill covers CSV.371351bb2adds Tier 1test_profiler_cmockaagainst empty stubs.NameStore::storereturns null, so the test fails atassertion failed: !a.is_null()inrust/obs-util/tests/profiler.rsbefore the lifecycle checks.126344b4dreplaces the stubs. Tier 1test_profiler_cmockapasses. Tier 3 matches the C oracle on the lifecycle script and on 48 random call scripts, including time buckets, under one scriptedos_gettime_ns. Recording each merged call twice makeslifecycle_matches_oraclefail (overall_count5 vs 10, times(3000, 5)vs(3000, 10)). That change was reverted.Intentional differences
profiler_freedestroys it, so the cmocka file runs lifecycle last and never reuses the profiler. Rustprofiler_startafterprofiler_freeis defined.pthread_mutex_initcan.max_probe_countis not stored. C only used it in a commentedblog.time_deltais compared only under the scripted clock. The unchanged cmocka test still does not assert time values.Not run here
This machine has no Docker, so Tier 2 (
ENABLE_RUST_LIBOBSOFF and ON, identical exports,run.sh --repeat 100 --tests test_profiler) was not run. The local-gate stamp was not applied.python ci/local_gate.py --lane lint --fixformattedprofiler.c; the lane's own Python checks then failed because Windows has nobashorcmake. That is not a profiler result. Please do not treat CI as green until the GitHub checks say so.Please add the
claimedlabel on #152. This account cannot.