Skip to content

rust: Call _coz_add_delays() after counter increments#270

Merged
emeryberger merged 1 commit intoplasma-umass:masterfrom
camelid:fix-rust-crate-add-delays
Feb 23, 2026
Merged

rust: Call _coz_add_delays() after counter increments#270
emeryberger merged 1 commit intoplasma-umass:masterfrom
camelid:fix-rust-crate-add-delays

Conversation

@camelid
Copy link
Copy Markdown
Member

@camelid camelid commented Feb 23, 2026

Summary

The Rust crate was not calling _coz_add_delays() after incrementing progress counters, causing the profiler to detect 0 experiments despite counters being incremented correctly.

The C COZ_INCREMENT_COUNTER macro in coz.h calls _call_coz_add_delays() after every increment — this is how the profiler injects virtual delays for causal profiling experiments. The Rust crate was missing this critical call.

This PR:

  • Adds a coz_add_delays() function that dynamically loads _coz_add_delays via dlsym (matching the existing pattern for _coz_get_counter)
  • Calls coz_add_delays() after every counter increment in Counter::increment()
  • Changes atomic ordering from SeqCst to Relaxed to match the C implementation (__ATOMIC_RELAXED)

Testing

Tested by profiling rustdoc (the Rust documentation tool) with coz on the stm32f4 crate (~224k LOC, ~35s documentation time):

  • Before: 0 experiments, progress points never detected by profiler
  • After: 18 experiments in a single run, throughput_point entries correctly recorded

🤖 Generated with Claude Code

The Rust crate was not calling `_coz_add_delays()` after incrementing
progress counters. The C `COZ_INCREMENT_COUNTER` macro in `coz.h` calls
`_call_coz_add_delays()` after every increment — this is required for the
profiler to inject virtual delays for causal profiling experiments.
Without this call, the profiler detects 0 experiments despite counters
being incremented correctly.

Also changes the atomic ordering from SeqCst to Relaxed to match the C
implementation (`__ATOMIC_RELAXED`), which is sufficient since libcoz
uses its own synchronization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@emeryberger emeryberger merged commit 9546ac1 into plasma-umass:master Feb 23, 2026
2 checks passed
@camelid camelid deleted the fix-rust-crate-add-delays branch February 23, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants