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

Make Local less than 2048 bytes #552

Merged
merged 1 commit into from
Sep 1, 2020
Merged
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
11 changes: 8 additions & 3 deletions crossbeam-epoch/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use crate::sync::queue::Queue;

/// Maximum number of objects a bag can contain.
#[cfg(not(feature = "sanitize"))]
const MAX_OBJECTS: usize = 64;
const MAX_OBJECTS: usize = 62;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, if make Local to be less than or equal to 1024 bytes, MAX_OBJECTS needs to be 30 (1016 bytes)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I didn't misunderstand @stjepang's this comment, It seems fine with less than half of what it is now, so it may be okay with this.

#[cfg(feature = "sanitize")]
const MAX_OBJECTS: usize = 4;

Expand Down Expand Up @@ -174,8 +174,6 @@ impl Default for Bag {
Deferred::new(no_op_func),
Deferred::new(no_op_func),
Deferred::new(no_op_func),
Deferred::new(no_op_func),
Deferred::new(no_op_func),
],
};
#[cfg(feature = "sanitize")]
Expand Down Expand Up @@ -374,6 +372,13 @@ pub struct Local {
pin_count: Cell<Wrapping<usize>>,
}

// Make sure `Local` is less than or equal to 2048 bytes.
// https://github.com/crossbeam-rs/crossbeam/issues/551
#[test]
fn local_size() {
assert_eq!(2040, core::mem::size_of::<Local>());
}

impl Local {
/// Number of pinnings after which a participant will execute some deferred functions from the
/// global queue.
Expand Down