jefe: move a biggish bit of Jefe off the stack #2351
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, Jefe represents task states in an array that's initialized in the
main()function and passed as a&mut [TaskStatus; NUM_TASKS]slice to theServerImplinitializer. This is a kind of biggish array, since eachTaskStatusis in excess of 64 bytes (it's a timestamp plus a couple enum discriminants), multiplied byNUM_TASKS, which can be in the vicinity of 20-30 tasks. Because the array is initialized as a local variable in themain()function, the array is on the stack all of the time. It doesn't have to be on the stack, and it could also be not on the stack.This commit makes it not be on the stack by putting it in a static instead. Also, I made the static be initialized by code that runs in
const fn, rather than having to loop over the held tasks at runtime and update them to be held by mutating the array. This just seemed a lot nicer, despite making the code look a bit less nicer. Oh well.This makes Jefe's stack usage a lot smaller; contrast the Gimletlet image on
master:...and after this change:
So that's some 600B of
maingone away, which seems cool.We could probably go through and adjust all the Jefe task sizes to be smaller now that they can be smaller.