-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline literal delegates passed to functions #6498
Comments
cc @AndyAyersMS @dotnet/jit-contrib |
See my long and rambling series of notes over in #4584 for some context. There is quite a bit of up front work needed to support this, even in very simple / obvious cases. |
Hi there, I arrived here from #34634 through #4584. Someone rightly pointed out that discussion/information about inlining delegates is more at home here, even if the two issues are deeply related, so here I am. I though it might be useful to add my scenario both for you guys (to have more use cases if you are going to implement the feature) and for me, to understand if my scenario could benefit from this feature, if it is something even more complicated, and/or if I could/should do something to make the code "easier" on the JITer. I code mainly in C#, but (like Mike_E in the other thread) my team and I found that we are using a kind of "functional" programming style, rich in delegates. We have experimented various approaches on how to build the pipeline in the most efficient way; in some parts we use dynamically compiled expressions (Expression.Compile), but for the most it is a mix of 2 delegate-heavy techniques. The first is, we use a lot of continuations, were we pass to a operation what we want to do next:
We even have some cases where this is nested, like:
The other case is in building the operations themselves. Since the choices depend on type and input, are multiple, and they are expanding over the releases but are fixed for a well defined period, we want to avoid to end up with code that is a nightmare of "if", based mostly on conditions that we know are not going to change. For example We could have composed operations using interfaces and classes with an Invoke method, but this looks a lot like a delegate, so we build a delegate
which is stored and later used with the other ones. I have read @AndyAyersMS comments on the other issue, and it seems that full inlining is a long way. Also, if I got it correctly, this case (returning a simple delegate with no local captures) would not even benefit from it as it is not invoked immediately, but is it returned and invoked elsewhere. |
This is a feature request to inline literal delegates passed to functions, so that the IL generated by
or its C# equivalent has no indirect dispatch.
category:cq
theme:inlining
skill-level:expert
cost:large
The text was updated successfully, but these errors were encountered: