On 5/10/15 12:52 AM, Marco Leise wrote:
* "zeroesAllocations"
   I called it "elementsAreInited" and as the name suggests, it
   tells whether new elements receive their T.init
   automatically.
   Now std.allocator deals mostly with raw memory, so zeroing
   is the only option, but I can see some friction coming up
   when typed allocators are built on those.
   Typed allocators backed by a "zeroesAllocations"
   allocator could overwrite the memory 3 times: zeroing,
   T.init, ctor assignments.

   a) Could the parent allocator be informed that it does not
      need to zero initialize because we will blit T.init over
      the memory anyways?

   b) If we get zeroed memory, can the typed allocator know at
      compile-time that T.init is all zeroes and elide the blit?

Yah, about that... I introduced this property as an OS interface courtesy - there are functions that already zero memory so it's wasteful to zero it again if that's all that's needed.

Sadly I found little if any interesting properties of this, and for anything that's not zero there's no gain - either the allocator does it or emplace() etc. does.

Long story short is I'm considering just dropping that.

* "roundingFunction"
   This is like a growth function, right? I often have some
   default lying around, but it is sure good to be able to
   provide your own. My default is: n' = n + (n >> 1) + 4
   One thing that could go wrong is that on 32-bit you pick a
   new size like n'=2*n and you just don't find enough
   contiguous virtual memory.

   a) On allocation failure the growth function is ignored and
      the minimal required size used.

   b) The growth function needs to be designed more carefully,
      putting the effort on the user.

This is not growth. Growth is "I have an array of size n and plan to append an unspecified number of elements to it, what's a good function that takes n and gives me a larger number?"

Quantization is different. What's happening here is you're reducing a large set of integer to a smaller number of quantas. That way you are overallocating (so indeed growth properties are nicer) but also reducing the total set of distinct sizes that the allocator needs to deal with.


Andrei

Reply via email to