1

There are a lot of questions that are similar\duplicates on SO but, all of them are incomplete or invalid:

  1. Performance differences between debug and release builds - incomplete, and the post is outdated. (4 years since last edit.)
  2. Debug vs. Release performance - saying Edit: Full list of optimizations here courtesy of Eric Lippert but, just two optimizations specified in the link.
  3. ...

I am concerned more about hard optimizations. I programmed 1,000 lines of code, in release mode performance improved by 15%. I rewrote it in C++, and in release mode it had better performance by 17 times or 1700%. (Even the debug mode of C++ had better performance by 2 times versus C#'s release mode)

Is there a full list, kept up to date by Microsoft or another authoritative source, listing all the the optimizations performed by the compiler or JIT in release mode?

Community
  • 1
  • 1
LyingOnTheSky
  • 2,844
  • 1
  • 14
  • 33
  • 1
    It is a bit unclear what is acutally being asked. To my understanding, it is not surprising that a C++ implementation outperforms a C# implementation. – Codor Nov 11 '14 at 09:31
  • @Codor I am asking for a full list of optimization, I am not asking why C++ outperforms C# in performance. I added it because I am not really concerned about trivial optimizations like dead code and etc. – LyingOnTheSky Nov 11 '14 at 09:33
  • @LyingOnTheSky apart from satisfying your curiosity, what insights would you gain from knowing the optimizations? – thumbmunkeys Nov 11 '14 at 09:37
  • @thumbmunkeys I need to decide whatever to do my project in C# or not (Or C++), because I need performance but productivity too. – LyingOnTheSky Nov 11 '14 at 09:39
  • 1
    @LyingOnTheSky that's exactly my point, the list of the optimizations will tell you nothing about the performance you will observe – thumbmunkeys Nov 11 '14 at 09:40
  • 3
    The list of optimizations performed by the compiler would hardly be a good determiner for whether to use C# or C++. Even if you knew the compiler and JITter backwards and forwards, you'd still not know how the performance would be without knowing what *your* code looks like. – Avner Shahar-Kashtan Nov 11 '14 at 09:41
  • 3
    All you'll get from a list is the ability to say "Oh, there are some fancy sounding optimizations going on here, so I'll use C# without worries". But it'll be meaningless. – Avner Shahar-Kashtan Nov 11 '14 at 09:42
  • @AvnerShahar-Kashtan Surprisingly I am compiler programmer, I can understand those. I have 1000 lines of code, which approximately will tell how the rest of the code will look like. I just want to know if it's worth it. – LyingOnTheSky Nov 11 '14 at 09:47
  • I've found an article, but it's outdated: http://www.codeproject.com/Articles/25801/JIT-Optimizations – ale Nov 11 '14 at 09:48
  • I think your question must be a duplicate http://stackoverflow.com/questions/4043821/performance-differences-between-debug-and-release-builds – Jodrell Nov 11 '14 at 09:49
  • @Jodrell This is one of the links I posted in the question... It's outdated, and it's the list he thinks there is. (Which are trivial, and they are almost in any compiler) – LyingOnTheSky Nov 11 '14 at 09:50
  • @InvernoMuto It's focused on inlining, but thanks anyway. – LyingOnTheSky Nov 11 '14 at 09:55
  • I think the answer is probably no. – Jodrell Nov 11 '14 at 09:56
  • This is so totally not the approach to take when trying to determine what programming language to use. I also cringe a little when people say stuff like "it's ten times faster", it is likely anecdotal (assuming the two sets of code were even equivalent to begin with). – Adam Houldsworth Nov 11 '14 at 09:57
  • It is also a little farcical to rely on the compiler to provide the "optimisations" required to make your code perform how you like it. I tend to rely on the design and implementation of my code to do that bit (when I worry about performance at all, which isn't very often). – Adam Houldsworth Nov 11 '14 at 10:00
  • @AdamHouldsworth I can agree that I am not taking the optimal course to choose what I will base my project on, didn't found better course. They are equivalent, I used LINQ and IEnumerators, and I remade them in C++ myself, the rest looks similar. (I wrote C++ while C# in the other side of the screen) It is farcical when you are concerned about it when you don't need it. My project is real-time. I optimized my C# code for 10 hours, before it the C++ was a lot faster (the debug at least, more than 10 times) – LyingOnTheSky Nov 11 '14 at 10:08
  • @LyingOnTheSky If your project is "real time", then C#, or any other managed application, is already the wrong choice regardless of optimisations because of non-deterministic memory management. I would not rely on compiler optimisations that are liable to change for critical parts of your code, you should have ownership of that, not the compiler. I remain unconvinced about how equivalent the code is, but that is irrelevant to the question so it doesn't matter. – Adam Houldsworth Nov 11 '14 at 10:09
  • @AdamHouldsworth I will agree with you one more time, but we are way out of the question. Thanks for the discussion. I hope it will change their mind when I will show this discussion. But still I will stick to this question to find an answer. (Curiousity too) – LyingOnTheSky Nov 11 '14 at 10:18

1 Answers1

2

This is not documented. The list is long, and it changes with every release of the compiler.

And it would make little sense to document the optimizations. Documentation is only useful for things that you can depend on. Optimizations change so frequently that it would be silly to depend on them, so the time spent documenting them would just be time wasted.

We'll all be better off if the people who would be responsible for that documentation just spend their time coming up with better optimizations instead.

NSFW
  • 557
  • 4
  • 12