hawkw/mycelium

maitake: We could monomorphize task vtables less

Closed this issue · 2 comments

From a hardware no_std build of mnemos using maitake, I had the following cargo bloat output:

https://gist.github.com/jamesmunns/b4feb5c52d144ec683523f33598aa49f

@hawkw noted we could monomorphize smarter:

maitake is monomorphizing the waker vtable methods

per task

but the waker vtable only needs to be monomorphized per scheduler

it doesn't care about the task's future/storage, only the scheduler

(it cares about the future bc the tracing event in there records the future type, but we could just remove that)

hawkw commented

this is probably gonna mean adding even more horrible Fun struct layout hacking in maitake::task, because we're gonna need a way to turn a *const () into a ptr to something that has access to a Scheduler, but without having to know any of the other generic types, so we can't cast to a Task...we probably need to wrap the Header in some kind of HeaderAndScheduler<S> struct, or something...

hawkw commented

the other observation here is that we probably want to be careful about adding new task vtable functions, at least if binary size is important to us...