<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hi Jason and other Jemalloc Experts<br><br></div>I am using jemalloc 3.5.0 on my platform. I have my own API layer on top of Jemalloc.<br>On this platform (freebsd based), when a page is sbrk()'ed in, it is set to all zeros. This is given.<br><br></div>My API guarantees when Alloc is done by user code, bytes are all zero'ed out. So the user does not have to memset() or call calloc() for allocated memory. This is also a requirement on my API layer. If my alloc finds non-zero bytes in the allocated memory in the debug mode, it asserts because I presume that it is a write after free.<br><br>When a free() is done, my API layer memset(0) all the allocated bytes before calling jemalloc_free().<br></div><div>This is also a security guarantee given by my API layer.<br><br></div>Right now at Alloc time, I am forced to call memset(0) as sometimes I find that there are unwanted non-zero bytes in the allocated memory. If my layer memset(0) before jemalloc_free() is called, why & where do these extra bytes appear from? These bytes are located in very high on a page address and look like jemalloc housekeeping.<br><br><div>Why do we do things like these?<br></div> Based on my benchmark
tests I know that it is taking me around 118ns (nanoseconds) to allocate
a say 64 bytes using je_malloc() (without memset) and with a forced
memset() this cost goes up to 240ns. That is almost double.and very expensive.<br><br>Since platform is already burning cpu to memset(0) on paging in a
physical page first time, I think it is sub-optimal to do additional
memset(0) at alloc time.<br><br></div>If I were to modify/enhance jemalloc, where do I need to make changes? My list so far includes arena_run_split_large_helper(), arena_run_split_small() & chunk_recycle().<br></div></div><br></div>Any direction you can provide me in this case will be very helpful.<br><br></div>Thank you so much..<br></div>--sk<br><div><div><div><div><div><div><div><div><br><div><br></div></div></div></div></div></div></div></div></div></div>