[ANN] ArrayAllocators.jl v0.3 composes with OffsetArrays.jl v1.12.1+ for faster zeros with offset indexing

Indeed - if “blob of zeros” is not a valid representation for your type, just using calloc will not help you.

Sort of. In general it depends on how your OS is handling calls to calloc in the libc you’re using. Linux at least has a dedicated zeroed page, to allow reads from calloced memory to be fast, but this of course doesn’t help with writes - the first write still has to allocate a page, which takes time. So in effect, the time an allocation takes is moved from the calloc call to the first real use of the memory.

There’s a bunch of discussion in this related thread:

but I personally don’t think calloc is a good idea, since it can mask performance problems due to the time being spent no longer being directly linked to the original allocation.

1 Like