Idea: Runtime Optimization, Iterator Blocks and Compiler-generated State Machines #7629
Replies: 3 comments 11 replies
-
@AdamSobieski similar to related discussions you've brought up in the past, this seems to lack information on why this would be beneficial. Furthermore, it doesn't really explain what the language would do here. |
Beta Was this translation helpful? Give feedback.
-
@CyrusNajmabadi, hello. I'm not sure that I'd tend to agree with that. The last time that I opened a discussion here was in February of this year and six of us, yourself included, appeared to enjoy talking about Metadata Attributes on Statements and Expressions. This discussion topic about Runtime Optimization, Iterator Blocks and Compiler-generated State Machines could be even more interesting, more significant, and, potentially, more beneficial to the developer community. I wanted to share these ideas as soon as they occurred and, as a result, I am still awaiting some emails about some of the technical particulars pertaining to the optimization of multiple interconnected, interrelated, interdependent compiler-generated state machines. The intended benefits would be speed- and performance-related. The gist of the envisioned language features, what the language would do here, would be to allow developers to choose to use another return type for their iterator and generator functions. That is, The envisioned return-type interface, |
Beta Was this translation helpful? Give feedback.
-
As this is a suggestion to make language changes to support optimizations, but no information had been given in that, I'm going to close this out. If you can provide better specifics in the future, that would be appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. I would like to discuss some ideas towards enabling the optimization of iterator blocks and their resultant compiler-generated state machines.
At first, towards enabling runtime optimizations, one might consider features which would surface in C# in a manner resembling:
Next, one might consider that these functions are transformed by compilers into state machines. So, techniques for runtime optimization might surface in C# in a manner resembling:
When developers would utilize the state-machine-related interfaces as return types, this would signal that they desired to provide iteration while also providing inspectability for runtime optimizers.
As considered, state machines would provide read-only access to their states and transitions.
IStateMachine<T>
would extendIEnumerable<T>
andIStateMachine
.IStateMachine
would have a property of typeIStateMachineProvider
.Models of compiler-generated state machines might provide access to
System.Linq.Expressions.Expression
or Roslyn tree expression nodes representing the transformed program logic inside of the state machines. With these sorts of features, one can start to imagine exploring how to provide developers with runtime optimizations.We could create extension methods on these interfaces, on
IStateMachine
andIStateMachine<T>
, resembling LINQ. These extension methods would be used, in particular, when runtime optimizations were desired.I am in particular interested in optimizations with respect to use cases like YieldProlog where iterator blocks and compiler-generated state machines are utilized extensively.
These topics are interesting to me and hopefully are of some interest to you. Has anyone else explored these topics? What do you think of these ideas?
Beta Was this translation helpful? Give feedback.
All reactions