4 ms·
I haven't read the code, but there are 2 areas where I expect allocations: - The continuation which is passed to .then, and which is typically a closure, must
by Matthias247 8y ago
I haven't read the code, but there are 2 areas where I expect allocations:
- The continuation which is passed to .then, and which is typically a closure, must be type-erased, which requires an allocation. Storing the continuation in a std::function would allocate too. A short glance at https://github.com/scylladb/seastar/blob/master/core/future.hh https://github.com/scylladb/seastar/blob/master/core/future.... also confirms that there is a make_unique there.
- Since continuations are most likely not called inline on completion but deferred into the next eventloop iteration there needs to be a dynamically sized queue to hold the ready continuations. I am not 100% sure if that's the case for seastar too, but I would guess so.
- gpderetta 8y agoI do not think the continuation is type erased. I belive that then, at least optionally (depending on the actual futurator passed in) can returns a future whose type encodes the continuation type and stores it inline. The queue might be dynamically sized which might eventually require allocation, but that can be ammortized across many futures. A large enough queue might never require reallocation. I'm also not 100% sure as I have never used seastar.