-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
txn: use tokio_threadpool for txn scheduler #4628
txn: use tokio_threadpool for txn scheduler #4628
Conversation
Signed-off-by: fredchenbj <cfworking@163.com>
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
Great, PTAL @breeswish @hicqu |
@fredchenbj |
@fredchenbj Do you test the binary with grafana and check if these metrics work well? |
I use
From above, the latency under certain load is not decreased obviously, and the context switch decreased about 5%. |
I have tested the binary, I would check metrics more carefully and comment here later. |
@fredchenbj I wonder why the context switch decreased, do you have any idea? |
src/storage/txn/sched_pool_impl.rs
Outdated
.build() | ||
} | ||
|
||
#[inline] |
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 remove all of the inline hints, let the compiler decide to optimize the code.
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.
@ngaut The inline hint still letting the compiler decide inline or not. (note that it is not #[inline(always)]
)
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.
I know, we don't need to do that, usually the compiler is smart enough to make the decision.
src/storage/txn/sched_pool_impl.rs
Outdated
@@ -0,0 +1,106 @@ | |||
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. |
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.
No need to call it xxx_impl?
src/storage/txn/sched_pool_impl.rs
Outdated
.build() | ||
} | ||
|
||
#[inline] |
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.
@ngaut The inline hint still letting the compiler decide inline or not. (note that it is not #[inline(always)]
)
src/storage/txn/sched_pool_impl.rs
Outdated
m.borrow_mut() | ||
.command_keyread_duration | ||
.with_label_values(&[cmd]) | ||
.observe(count); |
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.
why this duration is called count
?
src/storage/txn/sched_pool_impl.rs
Outdated
m.borrow_mut() | ||
.processing_read_duration | ||
.with_label_values(&[cmd]) | ||
.start_coarse_timer(); |
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.
This timer does not record any time.
Signed-off-by: fredchenbj <cfworking@163.com>
…heduler-and-process
I have check these metrics work as before.
I don't have any ideas about this. |
src/storage/txn/sched_pool.rs
Outdated
} | ||
} | ||
|
||
pub fn build_sched_pool(pool_size: usize, name_prefix: &str) -> FuturePool { |
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.
The name is quite confusing.. build_sched_pool
does not build a SchedPool
but a FuturePool
instead.
src/storage/metrics.rs
Outdated
@@ -5,6 +5,9 @@ use prometheus_static_metric::*; | |||
|
|||
make_static_metric! { | |||
pub label_enum CommandKind { | |||
get, |
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 like this change is not necessary?
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.
yes, here I tested wrong before, and will remove it.
src/storage/txn/process.rs
Outdated
Executor { | ||
scheduler: Some(scheduler), | ||
pool: Some(pool), | ||
schedpool: Some(pool), |
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.
prefer sched_pool
@zhangjinpeng1987 A work-stealing pool have local task queues, which may help with reducing context switch. |
Signed-off-by: fredchenbj <cfworking@163.com>
/run-integration-tests |
friendly ping @siddontang @breeswish |
src/storage/txn/process.rs
Outdated
.processing_read_duration | ||
.with_label_values(&[tag]) | ||
.start_coarse_timer(); | ||
let read_duration = tikv_util::time::Instant::now_coarse(); |
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.
can we use Instant::now_coarse()
here?
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.
fixed it.
Signed-off-by: fredchenbj <cfworking@163.com>
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.
Mostly fine. @zhangjinpeng1987 PTAL
…heduler-and-process
PTAL @hicqu please fix the confliect @fredchenbj |
…heduler-and-process
e0113ce
to
3b84fae
Compare
I merged master and resolved some conflicts. PTAL again @breeswish thanks! |
3b84fae
to
9274fd6
Compare
LGTM |
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: fredchenbj <cfworking@163.com>
Signed-off-by: fredchenbj <cfworking@163.com>
Signed-off-by: fredchenbj cfworking@163.com
What have you changed? (mandatory)
use tokio-threadpool to replace threadpool in tikv_util used by
txn
scheduler.The currently defined types are listed below, please pick one of the types for this PR by removing the others:
How has this PR been tested? (mandatory)
manual tests