Native Code Performance and Memory: The Elephant in the CPU

Download this episode

Download Video

Description

C and C++ developers know that memory caching is critical to the performance of native code. But there is much more to the story when it comes to performance on modern CPUs. This talk will examine the pitfalls of poor memory usage in C and C++, and will offer practical guidance for taking advantage of all the memory a CPU has to offer. Memory is the elephant in the CPU. Come learn why.

Tags:

Performance, C++, C

Day:

3

Level:

400

Session Type:

Breakout

Code:

4-329

Room:

South Hall: East Mezzanine 202

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      ScottBruno

      Good talk, Eric. I'm surprised no one has commented on this and I'd hate for folks at MS to think this sort of thing is unappreciated. As a console & PC game dev this subject is near and dear to my heart. And all native code folks should be interested in hearing from the compiler team.

      In fact, as an extension to the VC blog, I would love to see a regular series of short, pointed videos by the compiler team addressing whatever topics they're hot to talk about, and perhaps even answering questions from the "wild" in that format. And yes, I understand perfectly if said team is now cursing my name and lineage after reading that suggestion.

       

       

    • User profile image
      alluringtaco
    • User profile image
      Ion Todirel

      really cool talk

    • User profile image
      Matt_PD

      @ScottBruno: "I would love to see a regular series of short, pointed videos by the compiler team addressing whatever topics they're hot to talk about, and perhaps even answering questions from the "wild" in that format."

      Can I give this +infinity? Well, I can settle for +DBL_MAXBig Smile

      Very informative (& useful in practice!) session, thanks!

    • User profile image
      Eul3r

      Great talk, i like the style of eric. He totally qualified for a going native talk in september, i hope to hear more from you! Details matter, not expected stuff is even cooler Wink.

      If could highlight also some reading sources (useful books, specific blog posts,...) would be great++.

      I hope Charles is reading this, and he can get you on the speaker list for going native. Haven't seen a page to recommend ppl:-).

      *dreaming* Even cooler would be a Talk voting page  */dreaming*.

       

    • User profile image
      maxime caron

      +1

    • User profile image
      rapodder

      It was too cool.

    • User profile image
      Charles

      , Eul3r wrote

      Great talk, i like the style of eric. He totally qualified for a going native talk in september, i hope to hear more from you! Details matter, not expected stuff is even cooler Wink.

      If could highlight also some reading sources (useful books, specific blog posts,...) would be great++.

      I hope Charles is reading this, and he can get you on the speaker list for going native. Haven't seen a page to recommend ppl:-).

      *dreaming* Even cooler would be a Talk voting page  */dreaming*.

       

      Indeed, there will be compiler sessions at GoingNative 2013 and my hope is that Eric will be presenting one of them Smiley

      C

    • User profile image
      Bruce Dawson

      In your backup slides you recommend using /Oy. I think that is really dangerous advice. /Oy typically gives miniscule performance improvements, if any, and it means that most profilers (xperf at least) can no longer get call stacks. Valve (and Microsoft!) routinely do profiling of full retail code, including profiling code running on customer machines. This lets us diagnose huge performance problems. Shutting down that possibility for a possible 1-2% gain is a terrible tradeoff.

      /Oy doesn't harm debugging, but it does harm profiling. Just say no. The VC++ default changed from /Oy to /Oy- for a reason.

    • User profile image
      zxtt

      A brilliant session by a brilliant presenter Smiley
      Maybe only the name of the session can overshadow the session itself Smiley


      Go Leafs Go! Smiley

      Alex

      p.s. I do look at the assembly code - though not as often as I did 20 years ago Smiley

    • User profile image
      Ashish

      Nice talk. I would love to get to know more about this. Probably a short series.

    • User profile image
      Eul3r

      @Charles: Fantastic!!! Very Exciting!! It's like Christmas! Thanks man!

      Wishlist:1. a talk on multicore, with a deep dive.
      2. more information on the Network Lib and Filesystem Lib.

    • User profile image
      fidlerro

      Eric, your session was outstanding!  I am a C# developer and thinking of things from a native code's perspective was eye opening.  Can a C# developer take advantage of the performance tips you'd outlined: keeping data close in memory and memory alignment.  I am not sure if the CLR is optimized to handle these memory optimizations or if the C# compiler does this when the optimization flag is set.  Any information, resources, and/or links where I can learn more on the topic as it pertains to a C# developer would be much appreciated.

    • User profile image
      Matt_PD

      @fidlerro: Sasha Goldshtein has some writings on these topics: http://blogs.microsoft.co.il/blogs/sasha/

      In particular, see:

      There's (a lot) more under the "Performance" and "Performance Book" tags:

      That being said, it's my impression (possibly biased, I'm mostly a C++ programmer as far as hi-perf. applications are concerned) that, in addition to being able to exercise more control yourself when you're writing from the scratch (where you can get some part of the way in C# with unsafe and value semantics), perhaps more importantly the existing (and reusable) C++ ecosystem built around optimization (like memory alignment, etc.) is much richer (including, for instance, libraries like Intel's TBB which offer allocators with alignment support -- that you can relatively seamlessly integrate with your existing C++ codebase).

    • User profile image
      ruiRmelo

      Great talk!!

      Subject super interesting and good presentation skills!

    • User profile image
      hl3mukkel

      Very interesting talk! Would definitely like to see & hear more about this Smiley!

    • User profile image
      bumpe

      What?!
      A C++ talk with only C++ code in it!
      No crappy locked in C++/cx or C#.

      I'd love to see more of this. In more depth.

    • User profile image
      Shyamal

      Great Talk Eric, it was really insightful to understand the way memory is used under the hoods.

    • User profile image
      dragonlipz

      Eric had one of the best talks at Build as far as truly knowing his topic and being able to express is intelligently. Also he's a very energetic speaker. I'd recommend catching his sessions whenever possible.

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.