Hi,
bdb_search() allocates space for 128k candidate IDs and 64k scope IDs on the stack (about 768k of memory). bdb_idl_fetch_key() also allocates a large buffer on the stack (262352 bytes). Most other functions allocate roughly 1kB.
Using the stack rather than heap limits the size of these structures (idl.h observes: "IDL sizes - likely should be even bigger. limiting factors: sizeof(ID), thread stack size")
Using the stack for large allocations also creates the possibility of these arrays straddling the guard page (possibly resulting in local variables ending up in neighboring memory regions).
Would the performance cost of using the heap or thread local storage for these allocations outweigh the benefit of being able to use bigger arrays?
If you're interested in some statistics about slapd's stack usage, the static analysis perl script on kegel.com matches what I'm seeing from real running slapds:
http://www.kegel.com/stackcheck/
--
Thanks,
Sean Burford