On Sun, 2 Apr 2017 12:41:54 +0200, Jacob Carlborg wrote:

I've been thinking for a while about implementing some form of request
local allocations in one of my vibe.d applications. It would use
std.experimental.allocator with a thread/fiber local static array as the
memory with malloc as a fallback allocator. My idea is that it would
work like a bump the pointer alloctor which would at the end of a
request deallocate the memory by resetting the pointer to the beginning
of the buffer. To me this sounds really efficient, at least in theory.
Especially since most data is request specific and will not be shared
between request. I do have a couple of questions:

  1. To begin with, does this sound like a good idea in the first place?

It is good idea only if compiler can prevent leak of pointers to this storage out of request scope. How do you want to achieve this?

  1. Is it enough if the array is thread local or does it need to be fiber

local as well?

Many requests can be processed by the same thread at the same time, so thread-local is not enough, I think.