Stop setting core affinity on macos (#4676)

# Description of Changes

Explicitly disables core pinning on macos since it's not supported
anyway.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

N/A

Should have no behavior change since setting core affinity was basically
a no-op already.

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
This commit is contained in:
joshua-spacetime
2026-04-01 15:50:57 -07:00
committed by GitHub
parent 8239f5ee8b
commit 037acfcc29
4 changed files with 25 additions and 5 deletions
+4 -4
View File
@@ -14,6 +14,7 @@ use tracing_subscriber::{reload, EnvFilter};
use crate::config::{ConfigFile, LogConfig};
use crate::util::jobs::JobCores;
use crate::util::thread_scheduling::apply_compute_thread_hint;
pub use core_affinity::CoreId;
@@ -362,7 +363,7 @@ impl TokioCores {
// so this ends up working fine
builder.on_thread_start(move || {
if let Some(core) = cores_queue.pop() {
core_affinity::set_for_current(core);
apply_compute_thread_hint(Some(core));
} else {
#[cfg(target_os = "linux")]
if let Some(cpuset) = &self.blocking {
@@ -388,9 +389,8 @@ impl RayonCores {
.spawn_handler(thread_spawn_handler(tokio_handle))
.num_threads(self.0.as_ref().map_or(0, |cores| cores.len()))
.start_handler(move |i| {
if let Some(cores) = &self.0 {
core_affinity::set_for_current(cores[i]);
}
let core = self.0.as_ref().and_then(|cores| cores.get(i).copied());
apply_compute_thread_hint(core);
})
.build_global()
.unwrap()
+3 -1
View File
@@ -11,6 +11,8 @@ use tokio::runtime;
use tokio::sync::{mpsc, oneshot, watch};
use tracing::Instrument;
use crate::util::thread_scheduling::apply_compute_thread_hint;
/// A handle to a pool of Tokio executors for running database WASM code on.
///
/// Each database has a [`SingleCoreExecutor`],
@@ -239,7 +241,7 @@ impl CorePinner {
#[inline]
fn do_pin(move_core_rx: &mut watch::Receiver<CoreId>) {
let core_id = *move_core_rx.borrow_and_update();
core_affinity::set_for_current(core_id);
apply_compute_thread_hint(Some(core_id));
}
/// Pin the current thread to the appropriate core.
+1
View File
@@ -8,6 +8,7 @@ pub mod prometheus_handle;
pub mod jobs;
pub mod notify_once;
pub mod thread_scheduling;
// TODO: use String::from_utf8_lossy_owned once stabilized
pub(crate) fn string_from_utf8_lossy_owned(v: Vec<u8>) -> String {
+17
View File
@@ -0,0 +1,17 @@
use core_affinity::CoreId;
/// Apply the current platform's preferred scheduler hint for compute-heavy worker threads.
///
/// On Linux and other non-macOS platforms, this uses CPU affinity when a core is provided.
/// On macOS, scheduler hints are intentionally disabled.
pub(crate) fn apply_compute_thread_hint(core_id: Option<CoreId>) {
#[cfg(target_os = "macos")]
{
let _ = core_id;
}
#[cfg(not(target_os = "macos"))]
if let Some(core_id) = core_id {
core_affinity::set_for_current(core_id);
}
}