asdfkkkkkkkkk

This commit is contained in:
Janis 2025-07-02 00:10:28 +02:00
parent edf25e407f
commit f8aa8d9615
8 changed files with 24 additions and 22 deletions

View file

@ -48,4 +48,4 @@ cfg-if = "1.0.0"
async-std = "1.13.0"
tracing-test = "0.2.5"
tracing-tracy = "0.11.4"
distaff = {path = "distaff"}
distaff = {path = "distaff", features = ["tracing"]}

View file

@ -191,11 +191,7 @@ fn join_distaff(b: &mut Bencher) {
let pool = ThreadPool::new();
let tree = tree::Tree::new(TREE_SIZE, 1u32);
fn sum<'scope, 'env>(
tree: &tree::Tree<u32>,
node: usize,
scope: &'scope Scope<'scope, 'env>,
) -> u32 {
fn sum<'scope, 'env>(tree: &tree::Tree<u32>, node: usize, scope: Scope<'scope, 'env>) -> u32 {
let node = tree.get(node);
let (l, r) = scope.join(
|s| node.left.map(|node| sum(tree, node, s)).unwrap_or_default(),
@ -215,7 +211,7 @@ fn join_distaff(b: &mut Bencher) {
assert_ne!(sum, 0);
sum
});
eprintln!("{sum}");
std::hint::black_box(sum);
});
eprintln!("Done with distaff join");
}

View file

@ -10,7 +10,7 @@ debug = true
debug = true
[features]
default = ["metrics"]
default = []
tracing = ["dep:tracing"]
std = []
metrics = []

View file

@ -136,6 +136,9 @@ impl<T: Send> Receiver<T> {
.is_ok()
{
continue;
} else {
// The state was changed to `State::Ready` by the `Sender`, so we can return.
break;
}
}
Err(state) if state == State::Ready as u8 => {
@ -183,13 +186,13 @@ impl<T: Send> Receiver<T> {
}
unsafe fn take(&self) -> thread::Result<T> {
let result = unsafe { (*self.0.val.get()).take().map(|b| *b).unwrap() };
assert_eq!(
self.0.state.swap(State::Taken as u8, Ordering::Release),
self.0.state.swap(State::Taken as u8, Ordering::Acquire),
State::Ready as u8
);
let result = unsafe { (*self.0.val.get()).take().map(|b| *b).unwrap() };
result
}
}

View file

@ -27,6 +27,8 @@ impl HeartbeatList {
}
pub fn notify_nth(&self, n: usize) {
#[cfg(feature = "tracing")]
tracing::trace!("notifying worker-{}", n);
self.inner.lock().notify_nth(n);
}

View file

@ -63,6 +63,7 @@ impl WorkerThread {
/// This function must be called from a worker thread.
#[allow(dead_code)]
#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace", skip_all))]
pub(crate) fn join_heartbeat2_every<A, B, RA, RB, const TIMES: usize>(
&self,
a: A,

View file

@ -8,6 +8,7 @@
box_as_ptr,
box_vec_non_null,
strict_provenance_atomic_ptr,
btree_extract_if,
likely_unlikely,
let_chains
)]

View file

@ -66,7 +66,7 @@ fn join_distaff(tree_size: usize) {
let tree = Tree::new(tree_size, 1);
fn sum<'scope, 'env>(tree: &Tree<u32>, node: usize, scope: &'scope Scope<'scope, 'env>) -> u32 {
fn sum<'scope, 'env>(tree: &Tree<u32>, node: usize, scope: Scope<'scope, 'env>) -> u32 {
let node = tree.get(node);
let (l, r) = scope.join(
|s| node.left.map(|node| sum(tree, node, s)).unwrap_or_default(),
@ -134,16 +134,15 @@ fn join_rayon(tree_size: usize) {
}
fn main() {
tracing_subscriber::fmt::init();
// use tracing_subscriber::layer::SubscriberExt;
// tracing::subscriber::set_global_default(
// tracing_subscriber::registry()
// .with(tracing_tracy::TracyLayer::default()),
// )
// .expect("Failed to set global default subscriber");
//tracing_subscriber::fmt::init();
use tracing_subscriber::layer::SubscriberExt;
tracing::subscriber::set_global_default(
tracing_subscriber::registry().with(tracing_tracy::TracyLayer::default()),
)
.expect("Failed to set global default subscriber");
// eprintln!("Press Enter to start profiling...");
// std::io::stdin().read_line(&mut String::new()).unwrap();
eprintln!("Press Enter to start profiling...");
std::io::stdin().read_line(&mut String::new()).unwrap();
let size = std::env::args()
.nth(2)
@ -166,7 +165,7 @@ fn main() {
}
}
// eprintln!("Done!");
eprintln!("Done!");
// // wait for user input before exiting
// std::io::stdin().read_line(&mut String::new()).unwrap();
}