Skip to content

fix: clock source miss-match between Rust and Go#1742

Draft
Elvis339 wants to merge 6 commits intomainfrom
es/replace-coarsetime
Draft

fix: clock source miss-match between Rust and Go#1742
Elvis339 wants to merge 6 commits intomainfrom
es/replace-coarsetime

Conversation

@Elvis339
Copy link
Contributor

@Elvis339 Elvis339 commented Mar 6, 2026

Why this should be merged

Note: This PR will change after #1712 is merged.

coarsetime was introduced to avoid syscall overhead from std::time, but @demosdemon confirmed (and we verified empirically) that std::time uses clock_gettime(CLOCK_MONOTONIC) via vDSO on modern Linux which is resolving in userspace with no kernel entry. The two are equivalent in cost.

Removing coarsetime fixes the clock source mismatch between Rust CLOCK_MONOTONIC_COARSE and Go CLOCK_MONOTONIC that was causing the Firewood dashboard to show Rust commit time higher than Go commit time, which is physically impossible since Go wraps Rust synchronously via CGO.

How this works

Replaces all coarsetime::Instant / coarsetime::Duration usages withstd::time::Instant / std::time::Duration

How this was tested

Full methodology in #1720.

Breaking Changes

  • firewood
  • firewood-storage
  • firewood-ffi (C api) — commit_proposal token closure parameter type changes from coarsetime::Duration to std::time::Duration
  • firewood-go (Go api)
  • fwdctl

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Metrics Change Detection ⚠️

This PR contains changes related to metrics:

@@ -96 +95 @@ metrics::counter!(concat!("my.metric", "_ms"), labels)

However, the dashboard was not modified.

You may need to update benchmark/Grafana-dashboard.json accordingly.


This check is automated to help maintain the dashboard.

@Elvis339 Elvis339 changed the title feat: replace and remove coarsetime with std::time fix: clock source miss-match between Rust and Go Mar 6, 2026
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.

1 participant