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

Add a Cargo optional feature to replace std::time::Instant with tikv/minstant::Instant #512

Open
eval-exec opened this issue Jan 25, 2024 · 1 comment

Comments

@eval-exec
Copy link
Contributor

Is your feature request related to a problem? Please describe.
minstant is drop-in replacement for std::time::Instant that measures time with high performance and high accuracy powered by TSC.

Describe the solution you'd like
Add a cargo feature "minstant" to

[features]
default = ["protobuf"]
gen = ["protobuf-codegen-pure"]
nightly = ["libc"]
process = ["libc", "procfs"]
push = ["reqwest", "libc", "protobuf"]

Describe alternatives you've considered

Additional context
In my project, I am using the Histogram module and noticed that it relies on std::time::Instant for time measurement:

pub fn elapsed(&self) -> Duration {
match self {
// We use `saturating_duration_since` to avoid panics caused by non-monotonic clocks.
Instant::Monotonic(i) => StdInstant::now().saturating_duration_since(*i),
// It is different from `Instant::Monotonic`, the resolution here is millisecond.

Adding the optional minstant feature to rust-prometheus would be beneficial.

@eval-exec
Copy link
Contributor Author

Hello, if you think it's a good idea, I would like to open a pull request.

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

No branches or pull requests

1 participant