Skip to content

rust: Port util/profiler.c to obs-util #152

Closed

Description

@zackees

Phase 4 step 4. profiler-snapshot is already split out and ported (#88); test/cmocka/test_profiler.c is the Tier 2 check. source-profiler.c is out of scope (core code, see the core-design issue). Threaded: deterministic tests, no sleeps, run.sh --repeat 100 --tests test_profiler.

Acceptance: follows docs/rust-port/testing-policy.md. RED commit (Tier 1 on a todo!() core, plus the C characterization test if missing) then GREEN; Tier 2 passes with ENABLE_RUST_LIBOBS OFF and ON with identical exports; Tier 3 parity against the C oracle; intentional differences listed in the parity test header and rust/README.md.

Claim before coding: comment on this issue and add the claimed label (or ask a maintainer to). Check open PRs first (gh pr list --search "<unit>").

Activity

  1. added
    enhancement
    port
    on Oct 10, 2026
  2. nathan-v commented on Oct 11, 2026

    @nathan-v
    Contributor

    Claiming: util/profiler.c (#152)

    Plan (one PR, branch port/profiler):

    1. Move the print walkers and the CSV/gzip dump into util/profiler-io.c, compiled in both builds. They stay C (zlib, dstr printf). profile_print_func stays a non-exported C symbol. Variadic profile_store_name stays C, in util/profiler-variadic.c when ENABLE_RUST_LIBOBS=ON, and pushes the formatted buffer through a hidden profiler_name_store_push.
    2. RED: Tier 1 tests mirroring test_profiler.c (name store, disabled path, lifecycle counts and tree) fail on empty stubs. time_delta values are not asserted, matching the C test.
    3. GREEN: port the recording engine (open-addressing hashmap, TLS call stack, root mutex, pointer-identity names, snapshot build in the existing bmalloc/DARRAY layout). Tier 3 compares names, counts, and tree shape with the C oracle under a scripted clock. The unchanged cmocka test still covers CSV.
    4. CMake guard on profiler.c, export fragment, README row.

    Opening the PR today. This machine has no Docker, so Tier 2 (./unittest and run.sh --repeat 100 --tests test_profiler) is left to CI. Please add the claimed label; this account cannot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementport

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions