Skip to content
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

Add reduced-collection-frequency for niche use case #862

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crossbeam-deque/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ default = ["std"]
# NOTE: Disabling `std` feature is not supported yet.
std = ["crossbeam-epoch/std", "crossbeam-utils/std"]

epoch-reduced-collection-frequency = ["crossbeam-epoch/reduced-collection-frequency"]

[dependencies]
cfg-if = "1"

Expand Down
8 changes: 8 additions & 0 deletions crossbeam-epoch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ nightly = ["crossbeam-utils/nightly"]
# patch versions of crossbeam may make breaking changes to them at any time.
loom = ["loom-crate", "crossbeam-utils/loom"]

# Reduce collection frequency
#
# NOTE: This feature is to avoid the O(N) overhead, which only manifests under
# the situation where excessive number of threads (= N) are all accessing to
# the shared Global inside a single process space. This feature might introduce
# a potential slow memory reclamation as a trade-off.
reduced-collection-frequency = []

[build-dependencies]
autocfg = "1"

Expand Down
7 changes: 7 additions & 0 deletions crossbeam-epoch/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,15 @@ fn local_size() {
impl Local {
/// Number of pinnings after which a participant will execute some deferred functions from the
/// global queue.
#[cfg(not(feature = "reduced-collection-frequency"))]
const PINNINGS_BETWEEN_COLLECT: usize = 128;

#[cfg(feature = "reduced-collection-frequency")]
// ~10% collection overhead is observed with the normal 128 frequency with rayon under
// 1000-2000 threads including inactive ones. Reduce by ~100x factor to attain
// <1% overhead by large margin.
const PINNINGS_BETWEEN_COLLECT: usize = 128 * 128;

/// Registers a new `Local` in the provided `Global`.
pub(crate) fn register(collector: &Collector) -> LocalHandle {
unsafe {
Expand Down