Let the OS clear large new objects
Prefer calloc to malloc+memset when allocating large zeroed objects.
This avoids page thrashing when (make-vector
1000000000 nil)
allocates a large nil vector, as Emacs need not touch the
vector’s pages. This wins on platforms like GNU/Linux where
calloc can fiddle with page tables to create a block of memory
that is lazily zeroed.
* src/alloc.c (lisp_malloc, lmalloc, allocate_vectorlike):
New arg CLEARIT to tell callee whether to use malloc or calloc.
All callers changed.
(allocate_clear_vector, allocate_nil_vector): New functions.
* src/alloc.c (xzalloc, make_vector):
* src/lisp.h (make_nil_vector):
Prefer calloc to malloc + memset(...,0,...).