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

The Local structure is 2104 bytes long and jemalloc rounds this to 4096 bytes. #551

Open
PaulBone opened this issue Sep 1, 2020 · 4 comments · Fixed by #552 · May be fixed by #963
Open

The Local structure is 2104 bytes long and jemalloc rounds this to 4096 bytes. #551

PaulBone opened this issue Sep 1, 2020 · 4 comments · Fixed by #552 · May be fixed by #963

Comments

@PaulBone
Copy link

PaulBone commented Sep 1, 2020

The Local structure here https://searchfox.org/mozilla-central/source/third_party/rust/crossbeam-epoch/src/internal.rs#287 is 2104 bytes long. When compiled into Firefox and using the jamalloc memory allocator this is rounded up to 4096 bytes (a very common practice). This wastes just under 12KB for a Firefox process that loads a simple website. It'd be nice if it could allocate 2048 bytes or less saving this memory.

Thanks.

@taiki-e
Copy link
Member

taiki-e commented Sep 1, 2020

Local::bag field is 2056 bytes and already exceeds 2048 bytes, so there seems to be no other way to do this than reduce the size of Bag.

/// The local bag of deferred functions.
pub(crate) bag: UnsafeCell<Bag>,

And to reduce the size of the Bag, it needs to reduce MAX_OBJECTS.

/// Maximum number of objects a bag can contain.
#[cfg(not(feature = "sanitize"))]
const MAX_OBJECTS: usize = 64;
#[cfg(feature = "sanitize")]
const MAX_OBJECTS: usize = 4;
/// A bag of deferred functions.
pub struct Bag {
/// Stashed objects.
deferreds: [Deferred; MAX_OBJECTS],
len: usize,
}

@stjepang: Is it okay to reduce MAX_OBJECTS? Or do you think we need to think of another way?

@ghost
Copy link

ghost commented Sep 1, 2020

It should be totally fine to reduce it to 31 (if my calculation is right).

@PaulBone
Copy link
Author

PaulBone commented Sep 2, 2020

Awesome thanks.

@taiki-e
Copy link
Member

taiki-e commented Jul 22, 2022

Reopening -- #552 has been reverted in #879. (See #869 for the context.)

@taiki-e taiki-e reopened this Jul 22, 2022
@danielkeller danielkeller linked a pull request Feb 25, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants