Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Dec 27, 2025

Why I'm doing:

Merge commit latency metrics use bvar LatencyRecorder, and the unit is nanoseconds, but if the latency is larger than 2 seconds, the bvar will report overflow as the following

image

The reason is that although LatencyRecorder accepts int64_t as input (https://github.com/apache/brpc/blob/master/src/bvar/latency_recorder.h#L100
), but it actually uses IntRecorder to store the latency as int (https://github.com/apache/brpc/blob/master/src/bvar/latency_recorder.h#L54), so the allowed latency in nanosecond is 2147483647 (about 2.1s)

class LatencyRecorder : public detail::LatencyRecorderBase {
public:
    // Record the latency.
    LatencyRecorder& operator<<(int64_t latency);
class LatencyRecorderBase {
public:
    explicit LatencyRecorderBase(time_t window_size);
    time_t window_size() const { return _latency_window.window_size(); }
protected:
    IntRecorder _latency;

What I'm doing:

bvar does not provide other recorders to support int64_t. For merge commit latency, it's not necessary to use nanosecond precision, so just change the latency unit to microsecond, and the max latency can be 35.8 minutes which should be enough.

Note changing metric unit introduces behavior change, and add the document to explain it

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.0
    • 3.5
    • 3.4
    • 3.3

Note

Fixes overflow in merge-commit latency metrics by switching from nanoseconds to microseconds and documenting the change.

  • Replace g_mc_*_latency_ns with g_mc_*_latency_us in isomorphic_batch_write.cpp, add NS_TO_US conversions, and update logs/recorders accordingly
  • No functional logic changes to write flow; only metric units and names updated
  • Add "Merge Commit BE Metrics" docs (EN/JA/ZH): new counters described; latency metrics now reported in microseconds with note about pre-v3.4.11/v3.5.12/v4.0.4 behavior

Written by Cursor Bugbot for commit 126d8f7. This will update automatically on new commits. Configure here.


This is an automatic backport of pull request #67168 done by [Mergify](https://mergify.com).

Signed-off-by: PengFei Li <[email protected]>
(cherry picked from commit 39bc4ea)
@github-actions github-actions bot added documentation Improvements or additions to documentation automerge labels Dec 27, 2025
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) December 27, 2025 04:31
@mergify
Copy link
Contributor Author

mergify bot commented Dec 27, 2025

🧪 CI Insights

Here's what we observed from your CI run for f47a7b1.

🟢 All jobs passed!

But CI Insights is watching 👀

@wanpengfei-git wanpengfei-git merged commit 090ce5d into branch-3.5 Dec 27, 2025
43 of 44 checks passed
@wanpengfei-git wanpengfei-git deleted the mergify/bp/branch-3.5/pr-67168 branch December 27, 2025 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge documentation Improvements or additions to documentation version:3.5.12

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants