crossbeam-rs / crossbeam

Tools for concurrent programming in Rust
Apache License 2.0
7.3k stars 459 forks source link

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

Open PaulBone opened 4 years ago

PaulBone commented 4 years ago

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 commented 4 years ago

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.

https://github.com/crossbeam-rs/crossbeam/blob/bfb7705989a0961a16386ae2109bc2ef7f0bbe5e/crossbeam-epoch/src/internal.rs#L362-L363

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

https://github.com/crossbeam-rs/crossbeam/blob/bfb7705989a0961a16386ae2109bc2ef7f0bbe5e/crossbeam-epoch/src/internal.rs#L56-L67

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

ghost commented 4 years ago

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

PaulBone commented 4 years ago

Awesome thanks.

taiki-e commented 2 years ago

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