Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upReuse generator slots after StorageDead #52924
Comments
cramertj
assigned
Zoxc and
cramertj
and unassigned
Zoxc
Jul 31, 2018
cramertj
added
the
A-generators
label
Jul 31, 2018
This was referenced Nov 13, 2018
This comment has been minimized.
This comment has been minimized.
|
I am wondering if thinking of this as "slots of a struct" is the right model anyway. The content of the generator type (aside from the state flag) is basically the call frame for this generator, so shouldn't this be treated much more like the stack? There probably shouldn't even be types, just a large enough opaque "blob of bytes" that can be used for generator execution. If you think of this in terms of fields, you are not going to be able to reuse the space of two |
This comment has been minimized.
This comment has been minimized.
|
Yes, it's just a stack of bytes. This optimization was referring to the possibility to overlap some of the bytes to hold data that is currently stored in separate "slots of a struct". |
This comment has been minimized.
This comment has been minimized.
|
My intuition about generator layout is that it would be:
I expect that this is complicated by alignment and wanting to avoid moving values around inside of the generator as it iterates through states, but clearly we should be doing better than we are if the size is currently the sum of all yield point sizes instead of the max. If benchmarks are bad enough this may be a pre-stabilization priority. :-\ |
This comment has been minimized.
This comment has been minimized.
|
It's the sum of all variables that are alive across a yield point (one slot for every variable, not one slot for every yield point). We can do better by tracking which variables are live across non-intersecting sets of yield points and using the same space to store both. |
cramertj commentedJul 31, 2018
Currently, generators won't ever reuse storage slots, causing them to take up more space than is necessary:
Finding optimal solutions seems like a difficult packing problem, but it should be easy to do quite a bit better.