You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are at least two cases when I found it necessary to eliminate conditional checks from a function.
Case 1 was a game engine, where the main loop had to be streamlined as much as possible, so instead of checking the same settings sixty times per second (is raw input enabled, is custom message loop enabled, etc) the delegate was recompiled every time a setting was changed.
Case 2 was a banking software where each specific product got its own streamlined implementation of the business logic (both for performance and troubleshooting reasons).
Case 1 was written in C# and required using expression trees. The loop was small enough that it could be done.
Case 2 was written in PL/SQL, so it could utilize dynamic compilation. It was an error-prone mess for the same reasons C macros are, but I have no idea how this would have been done in C#.
To make something like Case 2 feasible in C#, I would need to be able to create expression trees from a multi-line lambdas. Building a tree-walker that eliminates conditionals from it would be simple enough.
Another option would be to give us an API that actually optimized compiled code (that worked with CIL, not Expressions) by fixing specific values and eliminating redundant checks. This would require first-class classes, so I guess it's something too big to ask.
The text was updated successfully, but these errors were encountered:
There are at least two cases when I found it necessary to eliminate conditional checks from a function.
Case 1 was a game engine, where the main loop had to be streamlined as much as possible, so instead of checking the same settings sixty times per second (is raw input enabled, is custom message loop enabled, etc) the delegate was recompiled every time a setting was changed.
Case 2 was a banking software where each specific product got its own streamlined implementation of the business logic (both for performance and troubleshooting reasons).
Case 1 was written in C# and required using expression trees. The loop was small enough that it could be done.
Case 2 was written in PL/SQL, so it could utilize dynamic compilation. It was an error-prone mess for the same reasons C macros are, but I have no idea how this would have been done in C#.
To make something like Case 2 feasible in C#, I would need to be able to create expression trees from a multi-line lambdas. Building a tree-walker that eliminates conditionals from it would be simple enough.
Another option would be to give us an API that actually optimized compiled code (that worked with CIL, not Expressions) by fixing specific values and eliminating redundant checks. This would require first-class classes, so I guess it's something too big to ask.
The text was updated successfully, but these errors were encountered: