Reduce stack usage by boxing File
in Dist
, CachePolicy
and large futures
#1004
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.
This is #947 again but this time merging into main instead of downstack, sorry for the noise.
Windows has a default stack size of 1MB, which makes puffin often fail with stack overflows. The PR reduces stack size by three changes:
File
inDist
, reducing the size from 496 to 240.CachePolicy
Method
Debugging happened on linux using #941 to limit the stack size to 1MB. Used ran the command below.
The main drawback is top-type-sizes not saying what the
__awaitee
is, so it requires manually looking up with a future with matching size.When the
brotli
features onreqwest
is active, a lot of brotli types show up. Toggling this feature however seems to have no effect. I assume they are false positives since thebrotli
crate has elaborate control about allocation. The sizes are therefore shown with the feature off.Results
The largest future goes from 12208B to 6416B, the largest type (
PrioritizedDistribution
, see also #948) from 17448B to 9264B. Full diff: https://gist.github.com/konstin/62635c0d12110a616a1b2bfcde21304fFor the second commit, i iteratively boxed the largest file until the tests passed, then with an 800KB stack limit looked through the backtrace of a failing test and added some more boxing.
Quick benchmarking showed no difference: