Async Techniques and Examples in Python Transcripts
Chapter: Welcome to the course
Lecture: Async for taking full advantage of modern CPUs
0:00 Here's a graph we're going to come back to
0:01 and analyze at great depth later in the course.
0:05 It came from a presentation by Jeffrey Funk.
0:07 You can see the SlideShare link there
0:09 if you want to go check it out.
0:10 It's actually 172 slides.
0:12 I want to just call your attention to this graph around 2005.
0:16 If you look at, most importantly, the dark blue line
0:20 that is single-threaded performance over time.
0:24 Note, it's going up and up and up
0:25 following Moore's law, that's the top line
0:27 and then it flattens out
0:28 and it actually is trending downward.
0:31 What is going on here?
0:32 Well, look at the black line.
0:34 We have the number of cores
0:35 going from one up to many
0:38 right around 2005 and continuing on today.
0:41 To take full advantage of modern hardware
0:44 you have to target more than one CPU core.
0:48 The only way to target more than one CPU core
0:50 is to do stuff in parallel.
0:52 If we write a regular while loop
0:54 or some sort of computational thing in regular Python
0:57 that is serial and it's only going to run on one core
0:59 and that means it's following that blue downward line.
1:02 But if we can follow the number
1:04 of cores growing, well, we can multiply
1:05 that performance massively, as we'll see.
1:09 One of the reasons you care about asynchronous programming
1:12 is if you have anything computational to do
1:15 that depends on getting done fast
1:17 not like I'm calling a database
1:19 or I'm calling a web service and I'm waiting.
1:20 That's a different type of situation we'll address.
1:23 But no, I have this math problem
1:25 or this data analysis problem
1:26 and I want to do it as fast as possible in modern hardware.
1:29 You're going to see some of the techniques
1:31 that we talk about in this course
1:32 allow us to target the new modern hardware
1:35 with as much concurrency as needed
1:37 to take full advantage of all the cores of that hardware.
1:40 So like I said, we're going to dig way more into this later
1:43 I just want to set the stage that if you have
1:45 anything computational and you want to take full advantage
1:48 of modern hardware, you need asynchronous programming.