mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Tracy thread names.
This commit is contained in:
parent
48d7f7dafd
commit
02f18825ef
@ -41,6 +41,22 @@ macro_rules! plot {
|
||||
#[cfg(feature = "tracy")]
|
||||
pub use tracy_client::plot;
|
||||
|
||||
#[cfg(feature = "tracy")]
|
||||
#[macro_export]
|
||||
macro_rules! set_thread_name {
|
||||
($name:expr) => {
|
||||
$crate::tracy_client::Client::running()
|
||||
.expect("set_thread_name! without a running Client")
|
||||
.set_thread_name($name);
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
#[macro_export]
|
||||
macro_rules! set_thread_name {
|
||||
($name:expr) => {};
|
||||
}
|
||||
|
||||
// https://discordapp.com/channels/676678179678715904/676685797524766720/723358438943621151
|
||||
#[cfg(not(feature = "tracy"))]
|
||||
#[macro_export]
|
||||
|
@ -190,6 +190,8 @@ impl State {
|
||||
Ok(())
|
||||
})
|
||||
.start_handler(move |i| {
|
||||
let name = format!("rayon-{}-{}", thread_name_infix, i);
|
||||
common_base::set_thread_name!(&name);
|
||||
if let Some(&core_id) = i.checked_sub(rayon_offset + tokio_count).and_then(|i| core_ids_.get(i)) {
|
||||
core_affinity::set_for_current(core_id);
|
||||
}
|
||||
@ -236,6 +238,8 @@ impl State {
|
||||
if tokio_count > 0 {
|
||||
static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0);
|
||||
let index = ATOMIC_ID.fetch_add(1, Ordering::SeqCst) % tokio_count;
|
||||
let name = format!("tokio-{}-{}", thread_name_infix, index);
|
||||
common_base::set_thread_name!(&name);
|
||||
if let Some(&core_id) = index.checked_add(num_cpu - tokio_count - 1).and_then(|i| core_ids_.get(i)) {
|
||||
core_affinity::set_for_current(core_id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user