Avoiding allocating first slab of the task allocator until task starts executing

As part of working on async deinit, I'm trying to make task that were enqueued, but did not start running yet to be as cheap as possible. In particular, I'm trying to avoid allocating slabs for task allocator until task starts running.

I've looked into this a bit, and tried to store TaskDependencyStatusRecord in the TaskPrivate, but I've hit this static assertion:

static assertion failed due to requirement 'sizeof(swift::AsyncTask::PrivateStorage) <= sizeof(swift::AsyncTask::OpaquePrivateStorage)': Task-private storage doesn't fit in reserved space

I'm 16 bytes short.

Looks like OpaquePrivateStorage is part of the ABI. Does that mean that size of the OpaquePrivateStorage cannot be changed?

If not, can I instead change memory layout of the TaskDependencyStatusRecord (which is also in the ABI folder)? I probably could avoid storing AsyncTask *WaitingTask;. And if TaskDependencyStatusRecord gets its own dedicated field inside TaskPrivate, does it even need to be a subclass of StatusRecord?

1 Like