Skip to content

Commit

Permalink
Merge #1091
Browse files Browse the repository at this point in the history
1091: Remove the semi-secret logging r=cuviper a=cuviper

Rayon has long had some logging functionality, but not well advertised.
The only mention is in the (private) module docs:

> To use in a debug build, set the env var `RAYON_LOG` as
> described below.  In a release build, logs are compiled out by
> default unless Rayon is built with `--cfg rayon_rs_log` (try
> `RUSTFLAGS="--cfg rayon_rs_log"`).
>
> Note that logs are an internally debugging tool and their format
> is considered unstable, as are the details of how to enable them.

I, for one, have not "internally" used this for debugging at all, yet it
comes at some cost to all users, even disabled in release builds. At the
very least it requires `crossbeam-channel` that we're not using anywhere
else except tests. Besides that, this code also bloats the compiled size
of `rayon-core` by about 30%, and similar for its compile time.

**So let's just rip out the logger!**

The remaining uses of `crossbeam-channel` in test cases are easily
avoidable too, since `std::sync::mpsc::Sender` is now `Sync`.


Co-authored-by: Josh Stone <cuviper@gmail.com>
  • Loading branch information
bors[bot] and cuviper committed Sep 19, 2023
2 parents 741d2b4 + 191ade2 commit dc7090a
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 582 deletions.
11 changes: 0 additions & 11 deletions ci/compat-Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion rayon-core/Cargo.toml
Expand Up @@ -17,7 +17,6 @@ categories = ["concurrency"]

# Some dependencies may not be their latest version, in order to support older rustc.
[dependencies]
crossbeam-channel = "0.5.0"
crossbeam-deque = "0.8.1"
crossbeam-utils = "0.8.0"

Expand Down
23 changes: 12 additions & 11 deletions rayon-core/src/broadcast/test.rs
Expand Up @@ -2,6 +2,7 @@

use crate::ThreadPoolBuilder;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::{thread, time};

Expand All @@ -14,7 +15,7 @@ fn broadcast_global() {
#[test]
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn spawn_broadcast_global() {
let (tx, rx) = crossbeam_channel::unbounded();
let (tx, rx) = channel();
crate::spawn_broadcast(move |ctx| tx.send(ctx.index()).unwrap());

let mut v: Vec<_> = rx.into_iter().collect();
Expand All @@ -33,7 +34,7 @@ fn broadcast_pool() {
#[test]
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn spawn_broadcast_pool() {
let (tx, rx) = crossbeam_channel::unbounded();
let (tx, rx) = channel();
let pool = ThreadPoolBuilder::new().num_threads(7).build().unwrap();
pool.spawn_broadcast(move |ctx| tx.send(ctx.index()).unwrap());

Expand All @@ -53,7 +54,7 @@ fn broadcast_self() {
#[test]
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn spawn_broadcast_self() {
let (tx, rx) = crossbeam_channel::unbounded();
let (tx, rx) = channel();
let pool = ThreadPoolBuilder::new().num_threads(7).build().unwrap();
pool.spawn(|| crate::spawn_broadcast(move |ctx| tx.send(ctx.index()).unwrap()));

Expand Down Expand Up @@ -81,7 +82,7 @@ fn broadcast_mutual() {
#[test]
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn spawn_broadcast_mutual() {
let (tx, rx) = crossbeam_channel::unbounded();
let (tx, rx) = channel();
let pool1 = Arc::new(ThreadPoolBuilder::new().num_threads(3).build().unwrap());
let pool2 = ThreadPoolBuilder::new().num_threads(7).build().unwrap();
pool1.spawn({
Expand Down Expand Up @@ -118,7 +119,7 @@ fn broadcast_mutual_sleepy() {
#[test]
#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)]
fn spawn_broadcast_mutual_sleepy() {
let (tx, rx) = crossbeam_channel::unbounded();
let (tx, rx) = channel();
let pool1 = Arc::new(ThreadPoolBuilder::new().num_threads(3).build().unwrap());
let pool2 = ThreadPoolBuilder::new().num_threads(7).build().unwrap();
pool1.spawn({
Expand Down Expand Up @@ -158,8 +159,8 @@ fn broadcast_panic_one() {
#[test]
#[cfg_attr(not(panic = "unwind"), ignore)]
fn spawn_broadcast_panic_one() {
let (tx, rx) = crossbeam_channel::unbounded();
let (panic_tx, panic_rx) = crossbeam_channel::unbounded();
let (tx, rx) = channel();
let (panic_tx, panic_rx) = channel();
let pool = ThreadPoolBuilder::new()
.num_threads(7)
.panic_handler(move |e| panic_tx.send(e).unwrap())
Expand Down Expand Up @@ -196,8 +197,8 @@ fn broadcast_panic_many() {
#[test]
#[cfg_attr(not(panic = "unwind"), ignore)]
fn spawn_broadcast_panic_many() {
let (tx, rx) = crossbeam_channel::unbounded();
let (panic_tx, panic_rx) = crossbeam_channel::unbounded();
let (tx, rx) = channel();
let (panic_tx, panic_rx) = channel();
let pool = ThreadPoolBuilder::new()
.num_threads(7)
.panic_handler(move |e| panic_tx.send(e).unwrap())
Expand Down Expand Up @@ -231,7 +232,7 @@ fn broadcast_sleep_race() {

#[test]
fn broadcast_after_spawn_broadcast() {
let (tx, rx) = crossbeam_channel::unbounded();
let (tx, rx) = channel();

// Queue a non-blocking spawn_broadcast.
crate::spawn_broadcast(move |ctx| tx.send(ctx.index()).unwrap());
Expand All @@ -247,7 +248,7 @@ fn broadcast_after_spawn_broadcast() {

#[test]
fn broadcast_after_spawn() {
let (tx, rx) = crossbeam_channel::bounded(1);
let (tx, rx) = channel();

// Queue a regular spawn on a thread-local deque.
crate::registry::in_worker(move |_, _| {
Expand Down
7 changes: 0 additions & 7 deletions rayon-core/src/latch.rs
Expand Up @@ -84,13 +84,6 @@ impl CoreLatch {
}
}

/// Returns the address of this core latch as an integer. Used
/// for logging.
#[inline]
pub(super) fn addr(&self) -> usize {
self as *const CoreLatch as usize
}

/// Invoked by owning thread as it prepares to sleep. Returns true
/// if the owning thread may proceed to fall asleep, false if the
/// latch was set in the meantime.
Expand Down
2 changes: 0 additions & 2 deletions rayon-core/src/lib.rs
Expand Up @@ -75,8 +75,6 @@ use std::marker::PhantomData;
use std::str::FromStr;
use std::thread;

#[macro_use]
mod log;
#[macro_use]
mod private;

Expand Down

0 comments on commit dc7090a

Please sign in to comment.