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 resource group for the read path #14001
Merged
Merged
Changes from 6 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0c2f846
add resource group for the read path
glorv 2190d5f
fix clippy
glorv 2beb118
fix test
glorv 7a62f72
update yatp
glorv 8815643
Merge branch 'master' of https://github.com/tikv/tikv into resource_g…
glorv b44b022
simplify some code
glorv 814bc33
update kv proto
glorv ad172f0
renew the resource group factor calculate logic
glorv e42c326
remove useless code
glorv 23d7cc6
Merge branch 'master' of https://github.com/tikv/tikv into resource_g…
glorv c659e69
use crossbeam skiplist from crates.io
glorv 171d7f6
resolve comments
glorv 0afce74
add a comment about mutex
glorv 5b7c20d
Merge branch 'master' into resource_group
glorv bc3c5ec
Merge branch 'master' of https://github.com/tikv/tikv into resource_g…
glorv f866d91
Merge branch 'resource_group' of ssh://github.com/glorv/tikv into res…
glorv File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "resource_control" | ||
version = "0.0.1" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
byteorder = "1.2" | ||
crossbeam-skiplist = { git = "https://github.com/crossbeam-rs/crossbeam" } | ||
dashmap = "5.1" | ||
kvproto = { git = "https://github.com/pingcap/kvproto.git" } | ||
lazy_static = "1.0" | ||
online_config = { workspace = true } | ||
pin-project = "1.0" | ||
prometheus = { version = "0.13", features = ["nightly"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
slog = { version = "2.3", features = ["max_level_trace", "release_max_level_debug"] } | ||
slog-global = { version = "0.1", git = "https://github.com/breeswish/slog-global.git", rev = "d592f88e4dbba5eb439998463054f1a44fbf17b9" } | ||
tikv_util = { workspace = true } | ||
yatp = { git = "https://github.com/tikv/yatp.git", branch = "master" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0. | ||
|
||
use std::{ | ||
future::Future, | ||
pin::Pin, | ||
sync::Arc, | ||
task::{Context, Poll}, | ||
}; | ||
|
||
use pin_project::pin_project; | ||
use tikv_util::time::Instant; | ||
|
||
use crate::resource_group::{ResourceConsumeType, ResourceController}; | ||
|
||
#[pin_project] | ||
pub struct ControlledFuture<F> { | ||
#[pin] | ||
future: F, | ||
controller: Arc<ResourceController>, | ||
group_name: Vec<u8>, | ||
} | ||
|
||
impl<F> ControlledFuture<F> { | ||
pub fn new(future: F, controller: Arc<ResourceController>, group_name: Vec<u8>) -> Self { | ||
Self { | ||
future, | ||
controller, | ||
group_name, | ||
} | ||
} | ||
} | ||
|
||
impl<F: Future> Future for ControlledFuture<F> { | ||
type Output = F::Output; | ||
|
||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
let this = self.project(); | ||
let now = Instant::now(); | ||
let res = this.future.poll(cx); | ||
this.controller.consume( | ||
this.group_name, | ||
ResourceConsumeType::CpuTime(now.saturating_elapsed()), | ||
); | ||
res | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0. | ||
|
||
use online_config::OnlineConfig; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
mod resource_group; | ||
pub use resource_group::{ResourceController, ResourceGroupManager, MIN_PRIORITY_UPDATE_INTERVAL}; | ||
|
||
mod future; | ||
pub use future::ControlledFuture; | ||
|
||
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, OnlineConfig, Default)] | ||
#[serde(default)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct Config { | ||
#[online_config(skip)] | ||
pub enabled: bool, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also add a sample in config-tempalte.toml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Connor1996 PTAL, do you feel ok with this new config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad name. Should be
enable
.