-
Notifications
You must be signed in to change notification settings - Fork 45
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
Performance vs postsharp #97
Comments
Hi Alexey, anything is possible, especially when there is a challenge 😄 Let's keep this issue open and use it to share ideas. Pascal. |
Well, I think you have made so much for this project that it gonna be a good idea to make the implementation perfect. For such library optimization is vital. For my dev. team, getting rid of the PostSharp as an AOP flagman and substitute it with something fast and open is a gift! |
Some more optimization thoughts (may be it's already possible, but I don't know how to achieve that). In my scenario the advice is applied on the complete assembly. I have only one IMethod advice, but it's applied to all methods, properties and .actors after weaving (it is correct). Mentioned method (with dropped down performance) has a loop inside that creates 1000 objects of one type. This type is a POCO class with 20 properties and a constructor. Properties are quite simple, something like "public bool MyProperty {get; set;}" and I am ready to declare them as safe. |
Dude! Please open other issues (I see two in your message: a question about excluding properties and a suggestion about referenceless advising). |
Done! |
I just released a version 2.4.8 where calls have been optimized by a factor of 2.5. |
I believe IL supports invoking Method Handles in a way that doesn't translate to C# well, but is functionally equivalent to using a known function pointer instead of a managed delegate or other late bound invocation (as in Reflection). It has been a long time since I looked at the IL spec so I forget exactly how it's done, but it might be a key optimization for that |
There is no
Edit: some performance comparison here: http://www.abhisheksur.com/2010/11/reflection-slow-or-faster-demonstration.html |
@hhblaze did you test the latest version? Some performance improvements were made. |
Thank you, will test ASAP |
Ok, the same function middle execution time: Now, may be, you can in popular way to explain me, how should I exclude [CompilerGenerated] on the level of Aspect and MrAdvice will definitely beat postsharp |
Great! We will burn them once invocation with delegates is implemented (instead of |
Very well, ....waiting for improvements and implementations... |
I just released a 2.5 version of Mr. Advice which includes the final optimization I could think of: using delegates instead of reflection to invoke advised method. |
Very well, ASAP |
Ok. In a set of tests Postsharp needs 107 ms MrAdvice needs - 80 ms. Thank you very much! |
I love the smell of PostSharp humiliation ✌️ |
Hi, our team uses postsharp already about 8 years (free version) to wrap any method/property into try-catch and measure quantity of calls, execution time and not finished calls, inside of our modules.
Now Postsharp tends to be not exactly free, so I am investigation new approaches like Mr.Advice.
I have re-weaved one of the modules from Postsharp to Mr.Advice and execution speed of specific measured methods has dropped down to 4-5 times (from 100ms to 500ms). Investigation brought me to the understanding, that the Mr.Advice generated byte code is a problem.
Postsharp integrates new byte code directly into the method, when Mr.Advice makes a 2 call chain and also makes extra type casting. When it's necessary to create many objects (e.g. 1000 with 20 properties each) inside of a method (where every object is under control) Mr.Advice makes 1000 * 20 * 3 calls + type casting, when for the Postsharp it' is enough only 1000 * 20 calls and no type casting.
Please, check examples down in the text.
Question is it possible to make optimization there?
Example:
Postsharp weaved property
https://gist.github.com/hhblaze/01b7e4caf49c56f992c865d1b6829330
Mr.Advice call chain
https://gist.github.com/hhblaze/8671da67e362bcf775f2a7dbdef64976
https://gist.github.com/hhblaze/5c3f03a0d37dde2f2526794f3d239319
https://gist.github.com/hhblaze/8b81af75f8d225f231282bd622ba34f8
The text was updated successfully, but these errors were encountered: