Return to Video

CppCon 2014: Chandler Carruth "Efficiency with Algorithms, Performance with Data Structures"

  • Not Synced
    So hi there, everyone.
  • Not Synced
    My name is Chandler Carruth.
  • Not Synced
    I work for Google
  • Not Synced
    I work on our C++ language platform
  • Not Synced
    I work on our C++ compilers
  • Not Synced
    specifically the Clang and LLVM teams at Google
  • Not Synced
    And I'm here to talk to you a little about performance.
  • Not Synced
    and efficiency, and making code fast,
  • Not Synced
    and all the different things that go into that.
  • Not Synced
    But before I do too much
  • Not Synced
    I want to give actually give you guys a little bit of
  • Not Synced
    one might say are expectations.
  • Not Synced
    Because I have been reading the twitter feed
  • Not Synced
    from all these folks, that talk about
  • Not Synced
    all these crazy good questions
  • Not Synced
    I just want you guys to essentially know
  • Not Synced
    this is my view
  • Not Synced
    of what Performance 101 should be.
  • Not Synced
    Okay? This is going to be kind of an intro talk.
  • Not Synced
    You guys are hard core, really deep performance nuts.
  • Not Synced
    You may be a little bit bored, and please be kind,
  • Not Synced
    because I'm going to gloss over some things
  • Not Synced
    you could heckle me thoroughly if you really want to
  • Not Synced
    We're going to talk about efficiency, performance,
  • Not Synced
    algorithms and data structures.
  • Not Synced
    And the first thing we are going to do is we're not going to talk about them.
  • Not Synced
    We're going to talk about why anyone cares about them.
  • Not Synced
    How many folks here think it's really important
  • Not Synced
    to have high performance in C++?
  • Not Synced
    Raise your hand if think that it's super important.
  • Not Synced
    Everyone thinks it's important!
  • Not Synced
    And the folks here who have a really clear idea why performance is important.
  • Not Synced
    Now, all the people who didn't raise their hands the second time,
  • Not Synced
    Please reconsider raising your hand the first time.
  • Not Synced
    We actually need to understand why performance is important in C++,
  • Not Synced
    before we actually decide it's important, we're going to care a lot about it.
  • Not Synced
    I'm going to tell you why I care about performance in C++.
  • Not Synced
    Most of it comes down to a quote from Nicolas Werth.
  • Not Synced
    Which I will try to pronounce correctly but fail miserably.
  • Not Synced
    I actually really like a lot of our stuff,
  • Not Synced
    I think he encapsulates a lot of my thoughts,
  • Not Synced
    what's core to my philosophy here.
  • Not Synced
    The software is getting slower more rapidly than
  • Not Synced
    hardware becomes faster.
  • Not Synced
    This is particularly in contrast to
  • Not Synced
    the kind of normal Moore's Law approach:
  • Not Synced
    Hardware's getting faster, all the time
  • Not Synced
    it's okay, we don't need to make software faster,
  • Not Synced
    because the hardware will catch up.
  • Not Synced
    And it turns out that's not really true.
  • Not Synced
    We're really good at writing slow software.
  • Not Synced
    Even in C++, we're really good at writing slow software.
  • Not Synced
    It's hard to write fast software,
  • Not Synced
    and it takes a lot of effort.
  • Not Synced
    And so it's important to think about
  • Not Synced
    why that might matter no matter how fast
  • Not Synced
    the processors get.
  • Not Synced
    And to give you an idea of just how much
  • Not Synced
    I think Nicholas Werth is on the same page
  • Not Synced
    I just have to mention he actually wrote a book
  • Not Synced
    entitled Algorithms + Data Structures = Programs.
  • Not Synced
    I did not realize this as I was picking
  • Not Synced
    the title of the topic.
  • Not Synced
    Anyways, we're going to come back
  • Not Synced
    to the title of this book.
  • Not Synced
    Because he predicted some whole elements
  • Not Synced
    of this talk in this book.
  • Not Synced
    So how many folks here have read this book?
  • Not Synced
    Anyone? All right! A long time ago.
  • Not Synced
    It's a good book. It's a good book.
  • Not Synced
    Okay, so I actually think the idea that
  • Not Synced
    software is getting slower too quickly, right?
  • Not Synced
    is really getting slower at an astonishing
  • Not Synced
    rate is even more important than before.
  • Not Synced
    And for pretty specific reasons.
  • Not Synced
    There was a very seminal event that
  • Not Synced
    happened in the technology world some time ago
  • Not Synced
    that changed, in my opinion and a lot of
  • Not Synced
    other peoples' opinion, how we look at
  • Not Synced
    computing devices, the performance of
  • Not Synced
    computing devices, the challenges we face
  • Not Synced
    running software for computing devices.
  • Not Synced
    And this event was the iPhone. Okay?
  • Not Synced
    And when Steve Jobs introduced the iPhone,
  • Not Synced
    he was not doing anything particular to C++
  • Not Synced
    but he was changing how we
  • Not Synced
    think about computing.
  • Not Synced
    Mobile was now a first class compute citizen.
  • Not Synced
    It took the world a little while to even
  • Not Synced
    realize that that was what had happened that day.
  • Not Synced
    But that's what happened.
  • Not Synced
    We now have to care about mobile.
  • Not Synced
    We have to care about things that are small.
  • Not Synced
    Right? things that are hard and challenging
  • Not Synced
    to fit big bulky systems into.
  • Not Synced
    And we essentially get into this annoying
  • Not Synced
    situation of, we have small, we have fast
  • Not Synced
    machines. We have to choose one.
  • Not Synced
    We don't get to choose though.
  • Not Synced
    We're going to choose small almost every time.
  • Not Synced
    But it gets worse.
  • Not Synced
    Because the other problem that the iPhone
  • Not Synced
    introduced that people weren't
  • Not Synced
    really focused on at the time
  • Not Synced
    was the problem of a battery.
  • Not Synced
    What do we do about the battery in your phone?
  • Not Synced
    You phone's battery, I mean my phone's
  • Not Synced
    battery is about dead. Right?
  • Not Synced
    How many folks here have charged their
  • Not Synced
    phone today? (Laughter from audience) Okay?
  • Not Synced
    That's a problem. That's not a feature.
  • Not Synced
    That's a bug. (Laughter from audience) Okay?
  • Not Synced
    Yes, How many folks are charging their phone now?
  • Not Synced
    (Laughter from audience) Okay so we kind of
  • Not Synced
    entered this new problem domain, suddenly
  • Not Synced
    power became relevant.
  • Not Synced
    There's some kind of shady research I want
  • Not Synced
    to push back against.
  • Not Synced
    There's some research into power efficient
  • Not Synced
    instructions. If you ever read about power
  • Not Synced
    efficient instructions or optimizing
  • Not Synced
    power usage, you should become very suspicious.
  • Not Synced
    And you should probably run the other direction.
  • Not Synced
    Because this is mostly total junk science. Okay?
  • Not Synced
    Here's the number one leading theory
  • Not Synced
    about how to save this, how to save
  • Not Synced
    battery life. Finish running the program.
  • Not Synced
    (Audience laughter) Seriously, race to sleep.
  • Not Synced
    That's the actual technical term, race to sleep.
  • Not Synced
    The faster your software runs, the less
  • Not Synced
    power it consumes. Now people get really
  • Not Synced
    upset about this. No, no if I run
  • Not Synced
    software really fast, then it heats up my
  • Not Synced
    processor, all that excess heat, that's the
  • Not Synced
    wasted power. But it's not, okay? Here's
  • Not Synced
    the thing, we've never really figured out
  • Not Synced
    how to run processors and do work
  • Not Synced
    on processors in a
  • Not Synced
    power efficient way. Do you know what we
  • Not Synced
    have figured out how to do with processors
  • Not Synced
    that has made our battery lives improve
  • Not Synced
    over time? We figured out how to turn them off.
  • Not Synced
    This is literally how your phone, your
  • Not Synced
    laptop, like if you have your computer
  • Not Synced
    on your desk. Every single
  • Not Synced
    microprocessor, general purpose
  • Not Synced
    microprocessors you can get today.
  • Not Synced
    The way it conserves power is by
  • Not Synced
    turning itself off as rapidly and as
  • Not Synced
    frequently as possible for as long a
  • Not Synced
    period time as possible. The more
  • Not Synced
    your processor turns on, the less this
  • Not Synced
    little green goes yellow and then red.
  • Not Synced
    Bad stuff right? So we actually want to
  • Not Synced
    make code faster in order to save battery
  • Not Synced
    life. Universally, this is true.
  • Not Synced
    There are some extreme exceptions to it
  • Not Synced
    There'e some really weird stuff around
  • Not Synced
    out on the fringe. But 99.999999% of the time
  • Not Synced
    You want to run code faster to save
  • Not Synced
    battery. But batteries aren't the only
  • Not Synced
    story when it comes to saving power.
  • Not Synced
    This is one of Google's data centers.
  • Not Synced
    You'll note that this is a very large building
  • Not Synced
    and the only thing it is doing is taking
  • Not Synced
    electricity and turning it into heat.
  • Not Synced
    That is it's job. And it's really good
  • Not Synced
    at it's job. And unfortunately,
  • Not Synced
    electricity costs a lot of money.
  • Not Synced
    And in fact, it's a finite resource.
  • Not Synced
    There's a certain point at which the cost
  • Not Synced
    goes away, you simply cannot have any
  • Not Synced
    more electricity at a particular point
  • Not Synced
    in time. And so power becomes very, very
  • Not Synced
    important in a data center as well.
  • Not Synced
    And I find it interesting that it's on the
  • Not Synced
    two extremes of computing platforms that
  • Not Synced
    we find convergence. Right? When you drop
  • Not Synced
    to a phone, or you go up to a data center
  • Not Synced
    all of a sudden power dominates. Right?
  • Not Synced
    We'll talk about compute per watt.
  • Not Synced
    This is another picture of the data center
  • Not Synced
    by the way. I just want to clarify what
  • Not Synced
    this is. This is one of my favorite pictures
  • Not Synced
    Those are enormous vents blowing out stem vapor.
  • Not Synced
    I don't know much about this but
  • Not Synced
    apparently when you can see the water vapor
  • Not Synced
    the data center is operating at peak
  • Not Synced
    efficiency because it means it's not too hot,
  • Not Synced
    its not too cool, its actually efficiently
  • Not Synced
    cooling the ?. Anyway this is trivia.
  • Not Synced
    So the compute per watt tends to
  • Not Synced
    dominate in the data canter and this is
  • Not Synced
    actually kind of the same thing we're trying
  • Not Synced
    to pull off on a phone or anything else.
  • Not Synced
    We want to maximize how much compute
  • Not Synced
    we can get out of the watts we're going
  • Not Synced
    to burn when the chip is turned on.
  • Not Synced
    Makes sense? Alright? Now I say raw speed
  • Not Synced
    isn't everything because when we talk
  • Not Synced
    about performance is really important
  • Not Synced
    you'll get some mixed messages from people.
  • Not Synced
    How many folks have heard this adage:
  • Not Synced
    After all, Java is faster than C++
  • Not Synced
    how many folks have heard it?
  • Not Synced
    Oh, you can be honest, I've heard it!
  • Not Synced
    All right, I had James Gosling sit across
  • Not Synced
    from the table and tell me
  • Not Synced
    I was a complete moron because I didn't
  • Not Synced
    believe Java that was faster than C++.
  • Not Synced
    And at the time he was right.
  • Not Synced
    And I learned better.
  • Not Synced
    So it turns out that Java is faster than C++
  • Not Synced
    in certain areas and scenarios.
  • Not Synced
    For example if you have a specific application
  • Not Synced
    and your specific application is going to
  • Not Synced
    run for a long period of time
  • Not Synced
    and you're concerned about the ?
  • Not Synced
    of the application and you have a
  • Not Synced
    very well tuned virtual machine
  • Not Synced
    for your Java, and you've tuned
  • Not Synced
    the garbage collector to precisely match
  • Not Synced
    the desired kind of garbage collection
  • Not Synced
    interruption frequency for your application
  • Not Synced
    If you get all of that, Java will
  • Not Synced
    very often ? perform to C++. 9:26
Title:
CppCon 2014: Chandler Carruth "Efficiency with Algorithms, Performance with Data Structures"
Description:

more » « less
Video Language:
English
Team:
Captions Requested

English subtitles

Incomplete

Revisions Compare revisions