[CS61C FA20] Lecture 36.1 - MapReduce, Spark: Amdahl's Law — Transcript
Full transcript
- 0:00and welcome back in this series of
- 0:03lectures we're going to teach you a new
- 0:05abstraction called mapreduce and an
- 0:07implementation of it in many languages
- 0:09but in particular python
- 0:11called spark very exciting but first
- 0:14what we're going to do is teach you this
- 0:15fundamental principle that
- 0:16actually we should have taught you a
- 0:17couple of lecture lectures ago called
- 0:20amdahl's law and actually it's called
- 0:22amdahl's heartbreaking law
- 0:25and part of it is as much as you try you
- 0:27can't get past this law so that's
- 0:29heartbreaking that you can't get above
- 0:30that but let's even tell you what it is
- 0:32so the model is the following you have
- 0:34some enhancement you want to
- 0:36upgrade your gpu upgrade your memory
- 0:38upgrade some part of your computer
- 0:40upgrade some part of some system it
- 0:41actually isn't even
- 0:42this law applies to anything that's
- 0:44actually even limited to computers
- 0:47so the model is the following you have
- 0:49some enhancement let's call it e
- 0:51and you want to measure how much your
- 0:53speed up is is it two times faster
- 0:55overall overall three 5 10 times faster
- 0:58100 times faster
- 0:59based on this enhancement and there's a
- 1:01very simple equation
- 1:02that we highlight how to calculate that
- 1:05so the speed up with e is the execution
- 1:08time
- 1:09without e divided by the execution time
- 1:12with e and you can imagine that right if
- 1:14the time is halved
- 1:16then the speed up would be a factor of
- 1:18two imagine that right the time with the
- 1:19expansion oh my gosh it's half time to
- 1:21do this thing
- 1:22oh it's a new kind of shovel dig a hole
- 1:24okay well it's half the time that it
- 1:26used to take
- 1:26so some time at the bottom half the time
- 1:28on the top if you
- 1:29figure that out the time will be a half
- 1:31then that one half goes over here and
- 1:33the two flips it
- 1:34becomes a factor of two speed up that
- 1:37makes sense 2x
- 1:38so we don't we often we in fact we
- 1:40encourage our 61c students and all
- 1:41students
- 1:42not to use a percentage speed up because
- 1:44people just get that math wrong or it's
- 1:46150
- 1:46speed up now you want to use 1.5 x it's
- 1:49just much easier to understand what that
- 1:51is
- 1:51okay let's understand how we came up
- 1:54with that
- 1:56so let's think about the problem the
- 1:59every every challenge you have and this
- 2:01is particularly true with
- 2:03code that has maybe a part that can be
- 2:05paralyzed like in openmp here's a
- 2:07parallel section and a part that
- 2:09isn't a critical section or part that's
- 2:10the serial part maybe the setup part and
- 2:12the gather part at the end the joint
- 2:14part there's the forking the join but
- 2:15the parallel parts different from that
- 2:18so here's what we're going to say we're
- 2:19going to say the enhancement e
- 2:21doesn't affect a portion s
- 2:24so a fortune s like a fraction so s is a
- 2:26fraction these are all fractional parts
- 2:28s of a task okay again this is this is
- 2:31larger than just computer science and
- 2:32computer engineering
- 2:34but it does accelerate the remaining
- 2:36part which is one minus s that's why s
- 2:38is a fraction that's a percentage
- 2:39one minus this is a percentage so one
- 2:41minus s is the parallel paralyzable part
- 2:44and or whatever enhancementable
- 2:46enhancement
- 2:47uh improvementable part that's the one
- 2:49minus s percentage
- 2:50a fraction and s is the fraction that
- 2:52doesn't get changed
- 2:53and it's going to accelerate by a factor
- 2:55of p
- 2:57p is bigger than one okay that's the
- 2:59hope here so now
- 3:00let's take a look at what that looks
- 3:02like then so here is this you notice
- 3:04that s doesn't change so this s
- 3:06here is my s that doesn't change okay
- 3:09but the one minus s part is smaller
- 3:13by a factor of p okay
- 3:17so what we get is the execution time
- 3:20with
- 3:20e is the execution time
- 3:24without e this is kind of times s so
- 3:27this since s didn't change since this s
- 3:29is still here
- 3:31that didn't change so that s this is i
- 3:35this has kind of been distributed if you
- 3:36multiply this out let's distribute this
- 3:38let's distribute this into this sum
- 3:40you get execution time without e times s
- 3:43which is
- 3:43that part didn't change see that part
- 3:45didn't change
- 3:47and then it was the the old execution
- 3:48time
- 3:50the paralyzable part is this fraction
- 3:52it's the old time it's whatever this
- 3:53time was
- 3:54which is the execution time of there
- 3:57times
- 3:58the smaller fraction which is one minus
- 4:00s
- 4:01over p
- 4:04this therefore the speed up with e is
- 4:07simply
- 4:08that fraction one divided by because
- 4:10that's kind of the
- 4:11novel the the normal time we normalize
- 4:14that the one divided by
- 4:17s plus one over s over p that's the
- 4:20fundamental equation that drives
- 4:22amdahl's law
- 4:25so now let's pull that out the same same
- 4:26equation equations ruled it a little bit
- 4:27differently
- 4:28and you get the speed up time is 1 over
- 4:31s is the fraction not sped up 1 minus s
- 4:35over p is the fraction that is sped up
- 4:37and in the perfect world as the speed up
- 4:40factor goes to infinity if i have a
- 4:43million cores
- 4:44a trillion cores a trillion helpers
- 4:46working on this
- 4:47that term goes to zero and you're left
- 4:50with one over s
- 4:51and that's it so the speed up can be no
- 4:55bigger
- 4:56and in fact in the perfect world is
- 4:57equal to 1 over s
- 5:00that's it where s remember s is the
- 5:03fraction that's the serial part
- 5:05all right let's do this together for
- 5:06example the execution time of
- 5:08four-fifths of a program can be
- 5:10accelerated by a factor of 16.
- 5:12that's pretty good 80 percent of 80 of
- 5:15the code
- 5:16is paralyzable think about that can be
- 5:18accelerated by a factor of 16.
- 5:20that's awesome what's the overall speed
- 5:23up am i at 16
- 5:24am i 50 can't be bigger than 16 am i 15
- 5:26what's the kind of hit
- 5:27what's the hit i took in that i didn't
- 5:29speed up the whole program
- 5:31so let's work it out well it's one over
- 5:34what's the fraction that is
- 5:35serial well that's 20
- 5:38or 0.2 what's the vector that's parallel
- 5:410.8
- 5:42well that 0.8 is going to be 16 times
- 5:44faster so that's now 0.05
- 5:47so 0.2 plus 0.05 is 0.25 1 over 0.25 is
- 5:514.
- 5:52you put all this money into a 16 time
- 5:55improvement
- 5:56but at the end of the day you only had a
- 5:58four times improvement
- 6:00heartbreaking that's the reason we call
- 6:02it amdahl's heartbreaking law
- 6:04so as we look at this here again here's
- 6:06a piece of code here's
- 6:07again s is s and p
- 6:10s and one minus s or the parallel part
- 6:13well
- 6:14yeah part other part is all are always
- 6:16fractions okay
- 6:17so here i look at this original time i
- 6:19have a piece of code that's mostly
- 6:21parallel
- 6:22we're doing pretty well and every time i
- 6:24add more
- 6:25cores to this there's the number of
- 6:27cores i'm going to have here
- 6:30every time i add more cores i'm going to
- 6:33shrink this parallel part by that factor
- 6:35so now
- 6:36this yellow guy is half as high and this
- 6:39yellow guy is a third as high
- 6:41and this is a quarter as high i try to
- 6:42do the graphic that way but that's the
- 6:44idea
- 6:45so as i look into the number of
- 6:47processors
- 6:50what i see is depending on the parallel
- 6:54portion
- 6:54i have different curves for how you know
- 6:57in the perfect world
- 6:58how much speed up i can get so if the
- 7:00parallel portion is
- 7:02only 50 of the code
- 7:05well then the serial part is a half and
- 7:07therefore i only have
- 7:09two times speed up so i could have an
- 7:11infinite number of processors that only
- 7:13have double speed up
- 7:14that's amazing of course well how about
- 7:1875 if 75 is parallel then a quarter
- 7:21think about that then a quarter
- 7:22is serial that means only a four times
- 7:24speed up the next curve says how about
- 7:2790
- 7:27parallel well that means a tenth and
- 7:29therefore 10x speed up
- 7:31how about 95 percent well that's only
- 7:33that's only
- 7:34uh one 120th uh is cereal therefore it's
- 7:38only 20 times
- 7:40so 20 times is pretty good but you have
- 7:42to almost get to 95
- 7:44parallel before you can even get 20
- 7:46times speed up much less
- 7:48i mean look at the number of cores we
- 7:49got 65 000 64k
- 7:51helpers yeah it was only a factor of 20
- 7:54faster
- 7:54and that is amdahl's heartbreaking law
- 7:57so moral of the story is
- 7:59do all the work you can to have very
- 8:02little serial code
- 8:04a very little setup code go parallel for
- 8:06the whole thing if you can
- 8:08and then very little kind of gather and
- 8:10and join at the end
- 8:12to be able to release your results
- 8:13that's the idea if you want to really
- 8:15maximize it
- 8:16that it's kind of the overhead it's
- 8:18almost like the overhead you paid i got
- 8:19a business and i have to pay the rent
- 8:20that's the overhead all the profit i
- 8:22make
- 8:23the overhead factors in so whatever you
- 8:25do
- 8:26try to reduce the overhead the serial
- 8:28overhead of your code so that you're
- 8:30almost all
- 8:31in a parallel stage try to get to the
- 8:32embarrassingly parallel problem where
- 8:34very little setup initially maybe like
- 8:36example initialize all the
- 8:38and all the sums remember how we were
- 8:39adding to pi together initialize them
- 8:41all to zero
- 8:42that wasn't done in parallel but
- 8:43although maybe it could be but that was
- 8:44done in serially
- 8:45and then compute all the pies that's the
- 8:48big chunk of the work
- 8:49and then some small fraction to gather
- 8:51together and sum it together at the end
- 8:53all right all right
- 8:54amdahl's heartbreaking loss sorry sorry
- 8:56to be the one to be the bearer of brad
- 8:57bad news but
- 8:58you got to know about you got to learn
- 8:59about it all right and that's probably
- 9:00in the perfect case
- 9:01with an infinite number of processes
- 9:03imagine the other elements of it well
- 9:04one was slower than the other and this
- 9:06one failed and
- 9:07we'll talk about all that we'll get to
- 9:08the topic of uh get the topic of cloud
- 9:11computing and how we have to deal with
- 9:12those failures we'll do that later
- 9:13all right see the next video
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 36.1 - MapReduce, Spark: Amdahl's Law by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,757 words across 291 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.