Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

router, backend: replace time.Time with mono-time to optimize duration calculation #461

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

djshow832
Copy link
Collaborator

What problem does this PR solve?

Issue Number: ref #420

Problem Summary:
We're adding more and more metrics and the overhead of time.Now() is getting more.
time.Now() involves wall time and nanotime, but we only need nanotime to calculate duration.

What is changed and how it works:
Replace time.Time with monotime.Time.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Benchmark results:

BenchmarkGoNow
BenchmarkGoNow-8       	13206856	        82.03 ns/op
BenchmarkMonoNow
BenchmarkMonoNow-8     	33960902	        34.73 ns/op
BenchmarkGoSince
BenchmarkGoSince-8     	 9926468	       123.3 ns/op
BenchmarkMonoSince
BenchmarkMonoSince-8   	15168806	        66.29 ns/op

Notable changes

  • Has configuration change
  • Has HTTP API interfaces change
  • Has tiproxyctl change
  • Other user behavior changes

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Replace time.Time with mono-time to optimize duration calculation

@ti-chi-bot ti-chi-bot bot requested review from bb7133 and xhebox January 25, 2024 02:53
@ti-chi-bot ti-chi-bot bot added the size/L label Jan 25, 2024
@ti-chi-bot ti-chi-bot bot added the lgtm label Jan 25, 2024
Copy link

ti-chi-bot bot commented Jan 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xhebox

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

ti-chi-bot bot commented Jan 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-01-25 02:57:22.516275874 +0000 UTC m=+1015884.080573578: ☑️ agreed by xhebox.

@ti-chi-bot ti-chi-bot bot added the approved label Jan 25, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@5273b42). Click here to learn what that means.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #461   +/-   ##
=======================================
  Coverage        ?   63.92%           
=======================================
  Files           ?       61           
  Lines           ?     5711           
  Branches        ?        0           
=======================================
  Hits            ?     3651           
  Misses          ?     1768           
  Partials        ?      292           
Flag Coverage Δ
unit 63.92% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ti-chi-bot ti-chi-bot bot merged commit 837db0b into pingcap:main Jan 25, 2024
5 checks passed
@djshow832 djshow832 deleted the timeutil branch January 25, 2024 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants