Latest / Talk Python To Me / #565: Tachyon, Python 3.15's Built-in Sampling Profiler
Transcript
- 0:00Pablo Galindo Salgado: Do you know what's actually slow in your Python app?
- 0:02Pablo Galindo Salgado: Or are you just guessing?
- 0:03Pablo Galindo Salgado: Until now,
- 0:04Pablo Galindo Salgado: profiling Python meant a tracing profiler
- 0:07Pablo Galindo Salgado: that made your code two to three times slower,
- 0:10Pablo Galindo Salgado: or a third-party tool that broke
- 0:12Pablo Galindo Salgado: with every new release of the Python runtime.
- 0:15Pablo Galindo Salgado: Python 3.15 fixes that.
- 0:17Pablo Galindo Salgado: It ships with Tachyon, a sampling profiler
- 0:20Pablo Galindo Salgado: built into the standard library.
- 0:22Pablo Galindo Salgado: It attaches to live production apps
- 0:23Pablo Galindo Salgado: with almost zero overhead.
- 0:26Pablo Galindo Salgado: My guests are Pablo Galindo Salgado,
- 0:28Pablo Galindo Salgado: a CPython core developer and steering council member,
- 0:31Pablo Galindo Salgado: and Laszlo Kiskoller from Bloomberg's Python infrastructure team.
- 0:35Pablo Galindo Salgado: Their first prototype ran at two samples a second.
- 0:39Pablo Galindo Salgado: Now it can do over a million hertz sampling.
- 0:42Pablo Galindo Salgado: The best news is this lands in Python 3.15 today.
- 0:47Pablo Galindo Salgado: This is Talk Python To Me,
- 0:48Pablo Galindo Salgado: episode 565,
- 0:51Pablo Galindo Salgado: recorded September 16th,
- 0:53Pablo Galindo Salgado: 2026.
- 1:11Pablo Galindo Salgado: Welcome to Talk Python To Me, the number one Python podcast for developers and data scientists.
- 1:16Pablo Galindo Salgado: This is your host,
- 1:17Pablo Galindo Salgado: Michael Kennedy.
- 1:18Pablo Galindo Salgado: I'm a PSF fellow who's been coding for over 25 years.
- 1:22Pablo Galindo Salgado: Let's connect on social media.
- 1:24Pablo Galindo Salgado: You'll find me and Talk Python on Mastodon, Bluesky,
- 1:26Pablo Galindo Salgado: and X.
- 1:27Pablo Galindo Salgado: The social links are all in your show notes.
- 1:30Pablo Galindo Salgado: You can find over 10 years of past episodes at talkpython.fm.
- 1:33Pablo Galindo Salgado: And if you want to be part of the show, you can join our recording live streams.
- 1:37Pablo Galindo Salgado: That's right.
- 1:38Pablo Galindo Salgado: We live stream the raw uncut version of each episode on YouTube.
- 1:41Pablo Galindo Salgado: Just visit talkpython.fm/youtube to see the schedule of upcoming events.
- 1:46Pablo Galindo Salgado: Be sure to subscribe there and press the bell so you'll get notified anytime we're recording.
- 1:50Pablo Galindo Salgado: This episode is brought to you by Sentry.
- 1:52Pablo Galindo Salgado: Sentry's new MCP server connects your error reports straight to your coding agent.
- 1:56Pablo Galindo Salgado: Claude Code reads the errors,
- 1:58Pablo Galindo Salgado: finds the bugs,
- 1:59Pablo Galindo Salgado: and fixes them.
- 2:00Pablo Galindo Salgado: Get started at talkpython.fm/sentry.
- 2:03Pablo Galindo Salgado: Pablo Laszlo, welcome to Talk Python Week.
- 2:06Pablo Galindo Salgado: Pablo,
- 2:06Pablo Galindo Salgado: welcome back.
- 2:07Pablo Galindo Salgado: Always good to have you on the show.
- 2:08Pablo Galindo Salgado: Laszlo, hello.
- 2:09Speaker 2: Yeah, thank you very much.
- 2:11Pablo Galindo Salgado: Yeah, it's good to see you both.
- 2:12Pablo Galindo Salgado: I'm really excited to talk about profilers.
- 2:14Pablo Galindo Salgado: I've had very extreme examples.
- 2:18Speaker 2: Extreme examples.
- 2:19Pablo Galindo Salgado: Extreme experiences with profiling.
- 2:21Pablo Galindo Salgado: experiences. Because I was certain, Pablo, I was certain something was happening with my program,
- 2:28Pablo Galindo Salgado: making it slow.
- 2:29Pablo Galindo Salgado: And then I attached a profiler and it wasn't even closely related. It was just
- 2:35Pablo Galindo Salgado: something completely else.
- 2:36Pablo Galindo Salgado: I was using the wrong data structure instead of the 6,000 lines of
- 2:40Pablo Galindo Salgado: complex mathematical stuff that I thought was slow. And it's really saved the day because I would
- 2:46Pablo Galindo Salgado: have tried to rewrite stuff that was super complicated. And really all I needed to do
- 2:50Pablo Galindo Salgado: with something silly like switch from a dictionary or a list to a set or a list to a dictionary,
- 2:54Pablo Galindo Salgado: something like this, right?
- 2:55Pablo Galindo Salgado: And it's like,
- 2:55Pablo Galindo Salgado: wow,
- 2:56Pablo Galindo Salgado: it's just like list find or list index sort of thing.
- 2:59Pablo Galindo Salgado: Oh, my gosh.
- 3:00Pablo Galindo Salgado: Yeah, many such cases.
- 3:03Speaker 2: Yes,
- 3:03Speaker 2: yes,
- 3:03Speaker 2: yes.
- 3:05Speaker 2: I think it's more common than you will think,
- 3:07Speaker 2: right?
- 3:07Speaker 2: Like,
- 3:08Speaker 2: I know that when this happens,
- 3:09Speaker 2: it's going to feel a bit bad because it's like,
- 3:11Speaker 2: oh,
- 3:11Speaker 2: man, I'm stupid.
- 3:12Speaker 2: But like,
- 3:12Speaker 2: no, it's extremely anti-intuitive in the world of modern software
- 3:16Speaker 2: when there is a bazillion layers of things
- 3:18Speaker 2: and now it's very much unclear what is costing things.
- 3:22Speaker 2: And that happens everywhere.
- 3:24Speaker 2: That happens in the smallest shops and the biggest shops.
- 3:27Speaker 2: So the tools are very important.
- 3:30Pablo Galindo Salgado: Yeah, they absolutely are.
- 3:31Pablo Galindo Salgado: And you all are behind some really cool new profiling capabilities
- 3:36Pablo Galindo Salgado: coming into Python.
- 3:37Speaker 2: Yes, yes.
- 3:38Pablo Galindo Salgado: Looking forward to diving into that with you.
- 3:40Pablo Galindo Salgado: So let's just do a quick reintroduction for you,
- 3:43Pablo Galindo Salgado: Pablo.
- 3:44Pablo Galindo Salgado: Just tell people about yourself a little bit,
- 3:45Pablo Galindo Salgado: what you've been up to.
- 3:46Pablo Galindo Salgado: It's been a while since you've been on the show.
- 3:48Speaker 2: Yes,
- 3:49Speaker 2: but always,
- 3:49Speaker 2: always been a lot of fun to be here.
- 3:51Speaker 2: So like, let's do more, let's do more.
- 3:52Speaker 2: But let me keep going and do more profilers
- 3:55Speaker 2: so we can come here even more time.
- 3:58Speaker 2: That's my goal,
- 3:59Speaker 2: just doing more profilers to come here.
- 4:02Speaker 2: So yes,
- 4:03Speaker 2: I think last time we talked about
- 4:04Speaker 2: perhaps PyStack or Membray, one of the two.
- 4:06Speaker 2: I don't remember the last one.
- 4:08Pablo Galindo Salgado: We spoke about both.
- 4:08Pablo Galindo Salgado: I don't remember the order.
- 4:10Speaker 2: Yeah, exactly.
- 4:11Speaker 2: Yeah,
- 4:11Speaker 2: but yeah.
- 4:12Speaker 2: So yeah, since then, I think,
- 4:14Speaker 2: Yeah, a bunch of things have changed.
- 4:15Speaker 2: I think, you know, a bunch of Python releases since then.
- 4:19Speaker 2: We are now in very close to 3.15.
- 4:22Speaker 2: It's very hard.
- 4:23Speaker 2: You will think, like, people know it is the last version,
- 4:25Speaker 2: but in my mind, 3.15 is all news
- 4:27Speaker 2: because the main branch is 3.16.
- 4:29Speaker 2: So, like, it's like all stuff.
- 4:30Speaker 2: It's like, oh, is that released already?
- 4:32Speaker 2: Anyway, no, 3.15 on October.
- 4:34Speaker 2: I'm sure you will do a very good episode about that
- 4:36Speaker 2: so,
- 4:37Speaker 2: you know, people should listen to it.
- 4:38Pablo Galindo Salgado: Yeah,
- 4:38Pablo Galindo Salgado: yeah.
- 4:39Pablo Galindo Salgado: We've done before,
- 4:40Pablo Galindo Salgado: like,
- 4:41Pablo Galindo Salgado: kind of a launch event thing
- 4:43Pablo Galindo Salgado: around Python.
- 4:44Pablo Galindo Salgado: I think it was 3.13, 3.12.
- 4:47Pablo Galindo Salgado: I can't remember which one, but that was a lot of fun.
- 4:48Pablo Galindo Salgado: Are you involved in the release this year?
- 4:51Speaker 2: I mean, from the sidelines, I still release my versions,
- 4:53Speaker 2: 3.10 and 3.11,
- 4:54Speaker 2: but the release manager right now is Hugo Pankeminade,
- 4:57Speaker 2: and the next is going to be Savannah,
- 5:01Speaker 2: which is going to be the new release manager for 3.16 and 3.17.
- 5:05Speaker 2: So I just help in.
- 5:06Speaker 2: I mean, there's always,
- 5:07Speaker 2: like,
- 5:07Speaker 2: things to fix,
- 5:08Speaker 2: and certainly since I'm the author of a bunch of stabbing 3.15,
- 5:13Speaker 2: quite a lot of stuff actually,
- 5:14Speaker 2: like, you know, lazy imports and the profiler.
- 5:16Speaker 2: So like there's a bunch of broken stuff.
- 5:19Speaker 2: So yeah, that does, that's,
- 5:21Speaker 2: you know, I'll help it.
- 5:22Speaker 2: Yeah.
- 5:22Speaker 2: Yeah.
- 5:23Speaker 2: So apart from that, I don't know,
- 5:24Speaker 2: I,
- 5:24Speaker 2: you know, same things.
- 5:25Speaker 2: I think the last time are still true,
- 5:27Speaker 2: you know, core developer.
- 5:28Speaker 2: I was still in the stream console.
- 5:30Speaker 2: I think I'm furniture at this point.
- 5:31Speaker 2: I feel like I've been there for like six years already.
- 5:33Speaker 2: So I don't know.
- 5:34Speaker 2: Maybe it's time to, to, to, to reconsider.
- 5:38Speaker 2: But yeah, I think the only thing is new is that I changed employers.
- 5:41Speaker 2: I used to work for Bloomberg,
- 5:42Speaker 2: which is with Laszlo.
- 5:43Speaker 2: I used to work there.
- 5:45Speaker 2: And this actually,
- 5:45Speaker 2: the provider work started when I was at Bloomberg.
- 5:48Speaker 2: But now I'm, I betrayed Bloomberg.
- 5:50Speaker 2: And now I'm in Hudson River trading.
- 5:53Speaker 2: Hudson River trading.
- 5:54Speaker 2: Bam.
- 5:55Speaker 2: Doing like fast trading.
- 5:57Speaker 2: Lots of money.
- 5:58Speaker 2: Yes, yes.
- 5:59Pablo Galindo Salgado: And that's very exciting.
- 6:00Pablo Galindo Salgado: Also,
- 6:00Pablo Galindo Salgado: probably a little high stress,
- 6:01Pablo Galindo Salgado: but that's okay.
- 6:02Speaker 2: No, I'm chill.
- 6:03Speaker 2: Like, you know, they let me record this podcast.
- 6:06Pablo Galindo Salgado: Well,
- 6:06Pablo Galindo Salgado: I'm just meaning like, if you remove a lot of money,
- 6:08Pablo Galindo Salgado: that is a nerve wracking thing.
- 6:10Speaker 2: It's more like the stress I think is more like what happens when you screw up because like a bloomer I think you screw up and you know maybe your manager says bad bad bad developer you know but like it's fine and I can talk about bloomer this way because I'm not worried anymore.
- 6:25Speaker 2: But sorry guys.
- 6:26László Kiss Kollár: You're going to make this interesting for me Pablo.
- 6:28László Kiss Kollár: Yes.
- 6:28Speaker 2: Sorry Chime.
- 6:30Speaker 2: This guy.
- 6:31Speaker 2: Anyway.
- 6:33Speaker 2: But yeah here is like when you screw up there is a very scary number that comes with the build you know.
- 6:38Speaker 2: and like your little deployment failure
- 6:41Speaker 2: caused like sort of big numbers.
- 6:44Speaker 2: So you're like, shit,
- 6:46Speaker 2: damn.
- 6:47Speaker 2: So when that number,
- 6:48Speaker 2: you know, it's very high,
- 6:49Speaker 2: then,
- 6:50Speaker 2: you know, so it's scary.
- 6:51Speaker 2: So,
- 6:51Speaker 2: yeah, I don't know.
- 6:52Speaker 2: It keeps interesting.
- 6:53Speaker 2: I find it.
- 6:53Speaker 2: Yeah,
- 6:54Pablo Galindo Salgado: but after you release Python
- 6:56Pablo Galindo Salgado: to how many tens of millions or more people
- 6:59Pablo Galindo Salgado: and platforms and it's low state.
- 7:02Pablo Galindo Salgado: I mean,
- 7:03Pablo Galindo Salgado: that's also a big deal.
- 7:04Speaker 2: I'm used to it.
- 7:04Speaker 2: I'm used to it.
- 7:05Speaker 2: This is just like high speed.
- 7:08Speaker 2: high speed.
- 7:09Speaker 2: Like in Python,
- 7:10Speaker 2: when you screw up,
- 7:11Speaker 2: you know, it's after a year that people use your thing
- 7:13Speaker 2: and they say, oh,
- 7:14Speaker 2: you know,
- 7:14Speaker 2: lazy imports is bad. And then you say, damn.
- 7:17Pablo Galindo Salgado: They're not going to say
- 7:18Pablo Galindo Salgado: that. Lazy imports are going to be awesome.
- 7:19Pablo Galindo Salgado: I'm for it.
- 7:20Speaker 2: That's it. That's it.
- 7:22Speaker 2: One of us. One of us.
- 7:24Speaker 2: But here,
- 7:24Speaker 2: you know, like,
- 7:25Speaker 2: they will tell you the millisecond it fails.
- 7:27Speaker 2: So you will know.
- 7:28Speaker 2: But yeah,
- 7:29Speaker 2: last look. And,
- 7:30Pablo Galindo Salgado: you know,
- 7:30Pablo Galindo Salgado: also,
- 7:32Pablo Galindo Salgado: quick shout out to core.py. That's a fun. Oh, thank you. I forgot.
- 7:34Pablo Galindo Salgado: I only have one job.
- 7:36Speaker 2: I only have one job.
- 7:37Speaker 2: I failed at the job.
- 7:38Speaker 2: Sorry,
- 7:38Speaker 2: Lucas.
- 7:38Speaker 2: Sorry,
- 7:39Speaker 2: Lucas.
- 7:40Pablo Galindo Salgado: Yeah, Lucas,
- 7:40Pablo Galindo Salgado: run that.
- 7:41Pablo Galindo Salgado: That's a great, that's a fun deep dive.
- 7:43Pablo Galindo Salgado: Like core developer internals.
- 7:45Speaker 2: Yes,
- 7:45Speaker 2: yes.
- 7:45Speaker 2: Listen to us.
- 7:46Speaker 2: We're still alive.
- 7:47Speaker 2: Lucas just like joined Meta and Mark Zuckerberg himself doesn't allow him to record that often.
- 7:53Speaker 2: Like that, when he joined Meta, Mark called him and was like, you cannot just, you cannot
- 7:57Speaker 2: just do this podcast often.
- 7:58Speaker 2: So like now we cannot do it.
- 7:59Pablo Galindo Salgado: It's like, if you're not going to have me on the show to talk about AI,
- 8:02Pablo Galindo Salgado: we can do it.
- 8:03Speaker 2: Yeah,
- 8:03Speaker 2: exactly.
- 8:03Speaker 2: So, but we have integrity.
- 8:04Speaker 2: We say, no, Mark, you cannot be on Corel.py
- 8:07Speaker 2: because you don't talk about Python.
- 8:09Pablo Galindo Salgado: It's not a PHP show, man.
- 8:11Pablo Galindo Salgado: Come on.
- 8:11Speaker 2: Exactly.
- 8:12Speaker 2: Yeah,
- 8:12Speaker 2: yeah.
- 8:13Speaker 2: Those guys.
- 8:14Speaker 2: So, yeah, yeah.
- 8:15Speaker 2: So we're still alive,
- 8:17Speaker 2: just slower.
- 8:18Speaker 2: But listen to Corel.py in all platforms.
- 8:21Pablo Galindo Salgado: Solid.
- 8:22Pablo Galindo Salgado: Lazlo, welcome to the show.
- 8:23Pablo Galindo Salgado: Tell us about yourself.
- 8:24László Kiss Kollár: Thanks.
- 8:24László Kiss Kollár: Happy to be here.
- 8:25László Kiss Kollár: So,
- 8:27László Kiss Kollár: yeah, so we've been working.
- 8:29László Kiss Kollár: I have worked with Pablo for quite a few years.
- 8:31László Kiss Kollár: Originally,
- 8:33László Kiss Kollár: I think since 2018,
- 8:34László Kiss Kollár: we started in the Python team together in Lundberg.
- 8:38László Kiss Kollár: And up until the end of last year, we've worked together.
- 8:43László Kiss Kollár: I actually participated in some of the projects like PyStack and Memory internally,
- 8:49László Kiss Kollár: not nearly as much to the extent as in Tachyon.
- 8:52László Kiss Kollár: But then we started collaborating with Pablo last year.
- 8:56László Kiss Kollár: And I remember this because,
- 8:57László Kiss Kollár: you know, probably just mentioned, like, it seems like 315 years old.
- 9:01László Kiss Kollár: I remember that we started working on this in the Sprint last year.
- 9:04Speaker 2: Picon last year.
- 9:05Speaker 2: Yeah, yeah.
- 9:06Speaker 2: Crazy.
- 9:06László Kiss Kollár: April,
- 9:07László Kiss Kollár: May.
- 9:08László Kiss Kollár: And it just seems like so far away.
- 9:11László Kiss Kollár: And it's crazy that it's still not out.
- 9:14László Kiss Kollár: But yeah, so that's where everything started.
- 9:16Speaker 2: But now that you have this thing fresh,
- 9:18Speaker 2: like now, right?
- 9:19Speaker 2: Like the last year,
- 9:20Speaker 2: you know, we were young and full of hope.
- 9:21Speaker 2: But like imagine the time when Python releases were every two years.
- 9:26László Kiss Kollár: Oh, yeah.
- 9:26Speaker 2: Damn.
- 9:27Speaker 2: Damn.
- 9:28Speaker 2: Because you think, oh,
- 9:29Speaker 2: man,
- 9:29Speaker 2: 312,
- 9:29Speaker 2: 313.
- 9:30Speaker 2: No,
- 9:30Speaker 2: man.
- 9:31Speaker 2: from 3.8 to 3.9.
- 9:33Speaker 2: Well, 3.8 was the first one,
- 9:34Speaker 2: but 3.7 to 3.8 was two years.
- 9:36László Kiss Kollár: You forget everything about the feature.
- 9:38László Kiss Kollár: You introduced ramp by the time it's released.
- 9:42Speaker 2: Exactly.
- 9:43Pablo Galindo Salgado: Do you guys think it should go faster?
- 9:44Pablo Galindo Salgado: Yeah.
- 9:45Pablo Galindo Salgado: Do you think there should be a six months
- 9:47Pablo Galindo Salgado: or every three months version of Python that comes out?
- 9:50Pablo Galindo Salgado: Or is it not?
- 9:51Speaker 2: I think from the usability thing,
- 9:55Speaker 2: I think I will do rolling releases if I could,
- 9:57Speaker 2: but the problem is that CPython is too big
- 10:00Speaker 2: to like do that.
- 10:01Speaker 2: In the sense that stability is really hard.
- 10:04Speaker 2: In the sense that ideally in the ideal world,
- 10:06Speaker 2: you merge things that aren't ready,
- 10:07Speaker 2: right?
- 10:07Speaker 2: And then you don't like,
- 10:08Speaker 2: you know, merge half bike stuff.
- 10:10Speaker 2: But like,
- 10:11Speaker 2: you know,
- 10:12Speaker 2: for a software this complex,
- 10:13Speaker 2: I like that affects so much things
- 10:15Speaker 2: and like so many people depend on it.
- 10:16Speaker 2: Of course, like people are going to run
- 10:17Speaker 2: on the latest one, right?
- 10:19Speaker 2: But like, it's very unfortunate.
- 10:21Speaker 2: And from this thought that is obviously wrong
- 10:23Speaker 2: to like the one year, two year release,
- 10:25Speaker 2: there is a continuum,
- 10:26Speaker 2: right?
- 10:26Speaker 2: So like, where do you put the line?
- 10:28Speaker 2: But in our experience in the core team so far is that one year is already like running to the edges of,
- 10:35Speaker 2: you know, how much we can ensure.
- 10:38Speaker 2: Because like there's always some last time scare.
- 10:41Speaker 2: You know,
- 10:42Speaker 2: there's always like, oh,
- 10:43Speaker 2: you know, for example, in Python 3.12,
- 10:46Speaker 2: we have to revert an entire new GC implementation.
- 10:50Speaker 2: Right.
- 10:51Speaker 2: And now in Python 3.14,
- 10:54Speaker 2: sorry, that was 3.13.
- 10:55Speaker 2: In Python 3.14,
- 10:56Speaker 2: we have to revert it again.
- 10:57Speaker 2: So like, because it was like having a huge amount of memory impact and that was only
- 11:02Speaker 2: known after people started to use it.
- 11:04Speaker 2: So that gave us like some information that perhaps we are, or either way we need to look
- 11:09Speaker 2: at the process,
- 11:10Speaker 2: which we are of course,
- 11:11Speaker 2: but like, or one year is already like on the line
- 11:14Speaker 2: of what is responsible.
- 11:15Speaker 2: So,
- 11:16Speaker 2: you know, it would be amazing if it's like rolling release and then you can get like
- 11:19Speaker 2: the features the next day, but not a possibility.
- 11:23Pablo Galindo Salgado: Yeah.
- 11:23Pablo Galindo Salgado: And I guess it doesn't change.
- 11:25Pablo Galindo Salgado: One of the things that's really nice about Python,
- 11:27Pablo Galindo Salgado: honestly,
- 11:28Pablo Galindo Salgado: is there's almost never a reason not to run on the new lease.
- 11:32Pablo Galindo Salgado: It's very,
- 11:34Pablo Galindo Salgado: very stable.
- 11:34Pablo Galindo Salgado: Only once have I had a major release of Python break any of my apps.
- 11:40Pablo Galindo Salgado: And the reason was the async coroutine decorator was removed
- 11:45Pablo Galindo Salgado: in lieu of async and await only for async funks, something like that.
- 11:50Pablo Galindo Salgado: Oh, I also didn't look at it.
- 11:51Pablo Galindo Salgado: Yeah.
- 11:52Pablo Galindo Salgado: And one of the libraries I was using for the database way deep down still used that.
- 11:58Pablo Galindo Salgado: And I didn't know.
- 11:59Pablo Galindo Salgado: But when I rolled out the new version,
- 12:00Pablo Galindo Salgado: it's like, what are you talking about, decorator
- 12:03Pablo Galindo Salgado: async code routine?
- 12:03Speaker 2: I'm like, it just doesn't run.
- 12:05Pablo Galindo Salgado: I don't know.
- 12:05Pablo Galindo Salgado: This isn't great.
- 12:07Pablo Galindo Salgado: But that's not what happens.
- 12:08Pablo Galindo Salgado: And I guess the faster you go, the more likely that is to happen, right?
- 12:10Speaker 2: Yeah.
- 12:11Speaker 2: I think you're also lucky.
- 12:12Speaker 2: I think like for,
- 12:13Speaker 2: I mean, I don't know.
- 12:14Speaker 2: I don't want to assume.
- 12:15Speaker 2: But I suppose my experience,
- 12:17Speaker 2: for instance,
- 12:17Speaker 2: working at Bloomberg and also here is not
- 12:20Speaker 2: really the same.
- 12:21Speaker 2: when your software is big enough,
- 12:22Speaker 2: you will run into the sync decorators all the time.
- 12:26Speaker 2: You know what I mean?
- 12:27Speaker 2: And in the weirdest cases,
- 12:29Speaker 2: normally it's not even just Python.
- 12:31Speaker 2: It's like, oh,
- 12:32Speaker 2: this Python 3.15 requires you to upgrade your Pandas data science stack
- 12:37Speaker 2: because the NumPy only supports 3.15 in version 2.5, right?
- 12:41Speaker 2: So if you're running version 2,
- 12:43Speaker 2: that forces you to move 0.5,
- 12:45Speaker 2: sorry, five versions of NumPy or whatever it is.
- 12:48Speaker 2: And then, I don't know, you run into all sorts of things,
- 12:50Speaker 2: right?
- 12:50Speaker 2: Like here,
- 12:51Speaker 2: the work I do right now in HRT, we have a lot of numeric work, for instance.
- 12:56Speaker 2: And there is times when we upgrade the interpreter and nothing breaks in the sense that,
- 13:01Speaker 2: you know, this function doesn't exist or this doesn't work.
- 13:04Speaker 2: It's like, no,
- 13:05Speaker 2: like the floating points are slightly off,
- 13:07Speaker 2: you know, like so the simulation is slightly off.
- 13:11Speaker 2: And,
- 13:11Speaker 2: you know, you chase that down and it's like pandas changed slightly the algorithm and like nothing,
- 13:17Speaker 2: you know.
- 13:19Pablo Galindo Salgado: like maybe the compiler is slightly different or something or like a compiler optimization flag
- 13:26Speaker 2: so people you know they still are relatively major events even if in the core team we've been working
- 13:32Speaker 2: with for instance numpy and pandas to ensure that they have wheels now on release so when you you
- 13:37Speaker 2: know when you start 315 uh and they won we won for can use no buy and it used to be not true right
- 13:43Pablo Galindo Salgado: 3.8 that was not a thing but now it is yeah it's certainly that uh the deploying of packages is
- 13:49Pablo Galindo Salgado: I want to talk about a couple things as a way to kind of introduce,
- 13:52Pablo Galindo Salgado: work our way into performance and profiling and so on.
- 13:57Pablo Galindo Salgado: And since you brought it up, let's talk real quick about lazy imports,
- 14:00Pablo Galindo Salgado: explicit lazy imports.
- 14:03Speaker 2: Explicit.
- 14:03Pablo Galindo Salgado: Yeah.
- 14:04Pablo Galindo Salgado: Well, by the way, did you consider not explicit?
- 14:07Speaker 2: Of course, yeah.
- 14:07Speaker 2: And that was rejected.
- 14:09Pablo Galindo Salgado: I wonder why.
- 14:11Pablo Galindo Salgado: So what does the syntax even look like?
- 14:13Speaker 2: Yeah, yeah.
- 14:13Speaker 2: So you just put lazy import to your import and bam,
- 14:16Speaker 2: your problem is faster.
- 14:17Speaker 2: Isn't that cool?
- 14:18Speaker 2: Well,
- 14:19Speaker 2: asterisk,
- 14:19Speaker 2: no, but that's the selling point.
- 14:23Speaker 2: Well,
- 14:23Speaker 2: okay.
- 14:23Speaker 2: The guess is that, you know,
- 14:26Speaker 2: so Python,
- 14:26Speaker 2: one of the powers of Python is very unsurprising
- 14:29Speaker 2: is packaging,
- 14:30Speaker 2: right?
- 14:30Speaker 2: Like you have a package for everything,
- 14:32Speaker 2: but guess what?
- 14:34Speaker 2: Those packages also use packages for everything and so on and so forth until you download is
- 14:40Speaker 2: even,
- 14:40Speaker 2: you know, and like just to check if a number is even, you just download a package
- 14:43Speaker 2: or something.
- 14:44Speaker 2: So what happens is that because this library is packaged a bunch of functionality,
- 14:48Speaker 2: sometimes when you only want to reach for a tiny function in some package,
- 14:51Speaker 2: you end importing the entire thing, right?
- 14:54Speaker 2: And the entire thing will end importing the entire thing of other packages and so on and so forth.
- 14:59Speaker 2: So it's very common that just by importing a tiny function,
- 15:02Speaker 2: you end paying for the entire world.
- 15:05Speaker 2: And some of those imports are really slow,
- 15:07Speaker 2: unfortunately,
- 15:07Speaker 2: because like they need to load big files or anyone that has dealt with Torch knows how chunky the video wheels are and whatnot.
- 15:15Speaker 2: So,
- 15:15Speaker 2: you know, that's bad because you should only pay for what you use.
- 15:17Speaker 2: So the idea of explicit lazy imports is that, you know,
- 15:21Speaker 2: if people start to mark the imports as lazy,
- 15:23Speaker 2: that you will only pay for the imports that you really need.
- 15:26Speaker 2: So only when you actually need that thing,
- 15:28Speaker 2: then it will be imported.
- 15:29Speaker 2: And that transforms your mega graph of imports of things that you don't really need into only the ones that you need.
- 15:35Speaker 2: And that saves you a lot of time and memory,
- 15:37Speaker 2: right?
- 15:37Speaker 2: Because loading those things is not free.
- 15:40Speaker 2: Not only in time,
- 15:40Speaker 2: right?
- 15:40Speaker 2: It's in memory as well.
- 15:41Pablo Galindo Salgado: Yeah.
- 15:42Pablo Galindo Salgado: Honestly,
- 15:43Pablo Galindo Salgado: I think, I mean, there are,
- 15:45Pablo Galindo Salgado: speaking of profilers,
- 15:46Pablo Galindo Salgado: there are some tools.
- 15:47Pablo Galindo Salgado: Now, this is not a very popular one.
- 15:49Pablo Galindo Salgado: It's very old.
- 15:49Pablo Galindo Salgado: I don't know if it even works.
- 15:50Pablo Galindo Salgado: But there are some tools to do things like profile import time and so on.
- 15:55Pablo Galindo Salgado: Certainly the time can matter.
- 15:57Pablo Galindo Salgado: I guess it matters.
- 15:58Pablo Galindo Salgado: It depends on what you're doing.
- 16:00Pablo Galindo Salgado: If you're doing serverless,
- 16:01Pablo Galindo Salgado: if you're doing CLIs, if you're doing subprocessing,
- 16:04Pablo Galindo Salgado: those
- 16:05Pablo Galindo Salgado: kinds of things really matter because it's spin up the thing, do a little bit of work
- 16:08Pablo Galindo Salgado: and go away.
- 16:09Pablo Galindo Salgado: If it's a web app,
- 16:10Pablo Galindo Salgado: you know, startup and then it just chills,
- 16:12Pablo Galindo Salgado: right?
- 16:13Pablo Galindo Salgado: It doesn't really matter in terms of time.
- 16:14Pablo Galindo Salgado: But I'll tell you where it does matter a lot is memory.
- 16:17Pablo Galindo Salgado: Right,
- 16:18Pablo Galindo Salgado: right.
- 16:18Pablo Galindo Salgado: I was on a mission to reduce how much memory it takes to run like the Talk Python courses
- 16:23Pablo Galindo Salgado: site and all the different things.
- 16:24Pablo Galindo Salgado: And I was surprised a couple hundred megabytes were ports that were rarely used.
- 16:30Pablo Galindo Salgado: So maybe if I run some back-end admin,
- 16:34Pablo Galindo Salgado: it would pull up NumPy, Matplotlib, and other types of stuff, right?
- 16:38Pablo Galindo Salgado: But otherwise it wouldn't.
- 16:39Pablo Galindo Salgado: And that added at least 100 megabytes to the runtime.
- 16:42Pablo Galindo Salgado: And because the way the imports worked, everything was eager.
- 16:45Pablo Galindo Salgado: It basically imported everything at startup.
- 16:47Pablo Galindo Salgado: So just by having those import statements there,
- 16:49Pablo Galindo Salgado: the app was using 100 megabytes more than it needed.
- 16:53Pablo Galindo Salgado: I changed them to the best I could of lazy imports,
- 16:55Pablo Galindo Salgado: where you just import in the function instead of the top of the file.
- 16:59Speaker 2: Lazy imports at home.
- 17:00Speaker 2: Yeah,
- 17:01Pablo Galindo Salgado: like homegrown,
- 17:02Pablo Galindo Salgado: homebrew lazy imports.
- 17:04Pablo Galindo Salgado: And it really dropped the memory by 100 megabytes.
- 17:07Pablo Galindo Salgado: And on the server, that's one of the most expensive things is RAM,
- 17:11Pablo Galindo Salgado: not compute.
- 17:12László Kiss Kollár: I was going to say that there's one more, I think, super cool area
- 17:15László Kiss Kollár: where lazy imports help a lot,
- 17:18László Kiss Kollár: which is CLI tools,
- 17:19László Kiss Kollár: which typically can be, and we've seen a lot of this,
- 17:22László Kiss Kollár: And I know with Pablo, we actually even looked at some stuff at work in the past where once
- 17:26László Kiss Kollár: you have a complex enough application,
- 17:29László Kiss Kollár: but you literally just want to see the help page
- 17:31László Kiss Kollár: or just spin something up and it can take seconds.
- 17:35László Kiss Kollár: And lazy imports can make a massive difference in that sort of the responsiveness of that
- 17:39László Kiss Kollár: CLI tool.
- 17:40Speaker 2: Right.
- 17:40Speaker 2: I was going to just add that there is also second and third order effects that people
- 17:45Speaker 2: think about,
- 17:46Speaker 2: but depending on the size of your thing can be quite dire.
- 17:49Speaker 2: Like one story, for instance,
- 17:50Speaker 2: for my current employer is that even if you don't care about memory,
- 17:55Speaker 2: let's say you have all the memory in the world, right?
- 17:57Speaker 2: And let's say you don't care about the startup tag,
- 17:59Speaker 2: because like you said, like,
- 18:01Speaker 2: you know, you have a web app,
- 18:02Speaker 2: right?
- 18:02Speaker 2: And like, you just start your thing and that's fine.
- 18:05Speaker 2: What can happen still is that if you import a lot of stuff that you don't use, all those imports will bring into existence a bunch of like a lot of Python objects.
- 18:14Speaker 2: And those objects can be classes,
- 18:15Speaker 2: functions,
- 18:17Speaker 2: constants,
- 18:19Speaker 2: and, you know, like all sorts of things.
- 18:21Speaker 2: And those things will be more and more and more and more.
- 18:23Speaker 2: And so you end with a lot of Python objects in your,
- 18:26Speaker 2: you know, in your program that you don't use, right?
- 18:29Speaker 2: And those things have non-zero costs because every time the garbage collector runs,
- 18:33Speaker 2: it will, like, look at all those things and then every run of the garbage collector will be slower.
- 18:38Speaker 2: Of course, like, you know, you have a web app that is a solution like the Instagram GC Freeze
- 18:43Speaker 2: that they implemented,
- 18:44Speaker 2: but this will happen also, you don't have web apps.
- 18:46Speaker 2: Like you have like even like the case of my employee, like scientific computing,
- 18:51Speaker 2: and you are crunching out of numbers just by importing stuff that you don't use,
- 18:54Speaker 2: those numbers will be crunched slower.
- 18:55Speaker 2: And you cannot just DC freeze because you don't have like a fork model
- 19:00Speaker 2: that then you run your workers,
- 19:02Speaker 2: right?
- 19:03Speaker 2: So importing less will make these objects not exist,
- 19:08Speaker 2: and therefore the app will run more linear.
- 19:10Speaker 2: That's the key, right?
- 19:11Speaker 2: So there is like very interesting second and third order effects to this.
- 19:15Pablo Galindo Salgado: This portion of Talk Python is brought to you by Sentry.
- 19:18Pablo Galindo Salgado: Now, I've told you about Sentry many times on the show,
- 19:21Pablo Galindo Salgado: but this time I have something new that should be very exciting to you.
- 19:25Pablo Galindo Salgado: Sentry has recently released their MCP server.
- 19:28Pablo Galindo Salgado: And for me personally,
- 19:29Pablo Galindo Salgado: this has truly unlocked a new level of integration
- 19:32Pablo Galindo Salgado: and workflow with Sentry.
- 19:33Pablo Galindo Salgado: You see,
- 19:34Pablo Galindo Salgado: Sentry is integrated into Talk Python,
- 19:37Pablo Galindo Salgado: courses,
- 19:38Pablo Galindo Salgado: website,
- 19:38Pablo Galindo Salgado: the mobile app,
- 19:39Pablo Galindo Salgado: and a whole bunch of things behind the scenes no one ever sees.
- 19:43Pablo Galindo Salgado: When something goes wrong in any of these apps,
- 19:45Pablo Galindo Salgado: I'm alerted immediately over email,
- 19:46Pablo Galindo Salgado: and I can log into Sentry and see all the details of what happened,
- 19:49Pablo Galindo Salgado: the parameters that were passed to functions,
- 19:51Pablo Galindo Salgado: what user encountered this error, and much more.
- 19:54Pablo Galindo Salgado: Traditionally,
- 19:55Pablo Galindo Salgado: what I would do is I would read the stack trace,
- 19:58Pablo Galindo Salgado: open up the source code,
- 19:59Pablo Galindo Salgado: try to piece together the detective story
- 20:01Pablo Galindo Salgado: that would solve what was wrong with my code.
- 20:03Pablo Galindo Salgado: Once I figured it out,
- 20:04Pablo Galindo Salgado: I would fix the code and push out a new version.
- 20:07Pablo Galindo Salgado: But you know what's coming,
- 20:08Pablo Galindo Salgado: right?
- 20:08Pablo Galindo Salgado: It's 2026.
- 20:09Pablo Galindo Salgado: This is the kind of work that AI is spectacularly good at.
- 20:14Pablo Galindo Salgado: Now when there's an error, I simply open up Claude Code with the project that had the error,
- 20:18Pablo Galindo Salgado: and I tell Claude, we have new errors in Sentry.
- 20:21Pablo Galindo Salgado: Please investigate them, and if you can,
- 20:23Pablo Galindo Salgado: solve them.
- 20:24Pablo Galindo Salgado: Claude immediately knows to use Sentry's MCP server because I connected it to
- 20:28Pablo Galindo Salgado: Claude Code.
- 20:29Pablo Galindo Salgado: It investigates all the errors,
- 20:31Pablo Galindo Salgado: uses the information I discussed,
- 20:33Pablo Galindo Salgado: and much more,
- 20:33Pablo Galindo Salgado: as well as the code base it's working in.
- 20:36Pablo Galindo Salgado: And 99% of the time, it fixes this without another instruction from me.
- 20:41Pablo Galindo Salgado: The magic of Sentry's MCP server is that it gives you full Sentry error reporting
- 20:46Pablo Galindo Salgado: and management directly connected to Frontier models running inside your code base.
- 20:51Pablo Galindo Salgado: If you use Agentic AI for your code at all,
- 20:53Pablo Galindo Salgado: you definitely need to check out Sentry and connect Sentry's MCP server
- 20:57Pablo Galindo Salgado: straight to your favorite coding agent.
- 20:59Pablo Galindo Salgado: Get started today at Sentry.
- 21:00Pablo Galindo Salgado: Be sure to use our link and discount code.
- 21:03Pablo Galindo Salgado: It's talkpython.fm/sentry,
- 21:05Pablo Galindo Salgado: code talkpython26.
- 21:08Pablo Galindo Salgado: That's talkpython.fm/sentry.
- 21:10Pablo Galindo Salgado: It gives you extra credits,
- 21:12Pablo Galindo Salgado: but more importantly,
- 21:12Pablo Galindo Salgado: it lets Sentry know you came from us.
- 21:14Pablo Galindo Salgado: Thank you to Sentry for supporting Talk Python To Me.
- 21:17Pablo Galindo Salgado: Python does a bunch to try to keep the memory together,
- 21:21Pablo Galindo Salgado: arenas and blocks and all that kind of business.
- 21:23Pablo Galindo Salgado: But yeah, if you allocate a whole bunch of pointers,
- 21:26Pablo Galindo Salgado: all of a sudden the GC has to count them, right?
- 21:28Pablo Galindo Salgado: Right.
- 21:28Pablo Galindo Salgado: The Gen 2 collections, yeah.
- 21:30Pablo Galindo Salgado: Okay.
- 21:31Pablo Galindo Salgado: Well, I'm excited for it.
- 21:32Pablo Galindo Salgado: So everyone get ready to write lazy import module instead of just import module and see where it takes you.
- 21:38Speaker 2: Yes.
- 21:39Speaker 2: All right.
- 21:39Pablo Galindo Salgado: Also,
- 21:40Pablo Galindo Salgado: let's talk faster CPython a little bit.
- 21:43Speaker 2: All right.
- 21:44Pablo Galindo Salgado: I mean, we're talking profiling.
- 21:46Pablo Galindo Salgado: We're talking about making code faster.
- 21:48Pablo Galindo Salgado: The Faster CPython initiative,
- 21:50Pablo Galindo Salgado: even though it's gone through a little bit of organizational challenges.
- 21:54Pablo Galindo Salgado: Drop my life,
- 21:54Pablo Galindo Salgado: yeah.
- 21:55Pablo Galindo Salgado: Yeah,
- 21:55Pablo Galindo Salgado: like with the Microsoft pulling the support or the people off of the project or whatever.
- 22:00Pablo Galindo Salgado: I think it's been a huge success.
- 22:02Pablo Galindo Salgado: I think Python is so much faster in a lot of ways.
- 22:05Pablo Galindo Salgado: And yeah,
- 22:06Pablo Galindo Salgado: what are your thoughts?
- 22:07Pablo Galindo Salgado: Either of you.
- 22:08Speaker 2: Yeah, I think,
- 22:09Speaker 2: I mean,
- 22:10Speaker 2: it's pretty obvious
- 22:11Speaker 2: if you look at like the performance of like,
- 22:13Speaker 2: let's say 39,
- 22:14Speaker 2: that was when this started,
- 22:15Speaker 2: or like 310 perhaps,
- 22:17Speaker 2: like on the performance of today's Python,
- 22:19Speaker 2: like that has been a clear success.
- 22:21Speaker 2: And this kind of continues.
- 22:22Speaker 2: It's just that like we just run out of like obvious things.
- 22:26Speaker 2: Obvious doesn't mean easy,
- 22:27Speaker 2: right?
- 22:27Speaker 2: But like obvious things to look at.
- 22:29Speaker 2: And right now,
- 22:29Speaker 2: the biggest efforts are into big chunks of this work,
- 22:33Speaker 2: like JIT, which is like, you know, a big piece of software.
- 22:35Speaker 2: I think you got Brandon in the show,
- 22:37Speaker 2: perhaps,
- 22:38Speaker 2: in the past,
- 22:39Speaker 2: to talk about it.
- 22:40Speaker 2: So now,
- 22:41Speaker 2: you know, that's something that you cannot just commit in a couple of months.
- 22:45Speaker 2: Pips are needed and all sorts of things.
- 22:47Speaker 2: So right now,
- 22:48Speaker 2: you know,
- 22:48Speaker 2: the successor of that project is still happening.
- 22:51Speaker 2: It's just that now those optimizations are much harder and require more careful consideration.
- 22:56Speaker 2: And as you very well know, we are also very deep into the weeds of free threading and free thread Python dropping the GIL.
- 23:04Speaker 2: And, you know, it turns out that those things kind of like don't play necessarily well together.
- 23:08Speaker 2: So there is also like, you know, a lot of considerations there.
- 23:12Speaker 2: And going to the topic at hand,
- 23:15Speaker 2: profiling is really important to ensure that like none of this gets wrong.
- 23:18Speaker 2: Right.
- 23:18Speaker 2: And to also know that indeed your application became faster.
- 23:23Speaker 2: Why?
- 23:23Speaker 2: Because,
- 23:24Speaker 2: like,
- 23:24Speaker 2: you know,
- 23:25Speaker 2: is this because Python 3.15 is going to be faster or is it because, like, NumPy is faster?
- 23:29Speaker 2: Like, how do you know?
- 23:30Speaker 2: Well, you need to use one of these tools,
- 23:31Speaker 2: right?
- 23:32Pablo Galindo Salgado: Yeah.
- 23:32Pablo Galindo Salgado: Vaslo?
- 23:33László Kiss Kollár: Yeah,
- 23:33László Kiss Kollár: I mean, I watched the sort of the fastest SuperTor project from the sidewings for the past couple of years.
- 23:41László Kiss Kollár: And I think the,
- 23:42László Kiss Kollár: I actually remember,
- 23:43László Kiss Kollár: I think the biggest jump,
- 23:44László Kiss Kollár: was it 3.12?
- 23:46László Kiss Kollár: there was a very significant jump there.
- 23:48László Kiss Kollár: And it was very exciting because when we introduced that version,
- 23:53László Kiss Kollár: there was such a significant jump that whereas,
- 23:55László Kiss Kollár: you know,
- 23:57László Kiss Kollár: oftentimes you would have to convince folks,
- 23:58László Kiss Kollár: like you need to upgrade your Python versions,
- 24:00László Kiss Kollár: right?
- 24:01László Kiss Kollár: But when you have this carrot,
- 24:02László Kiss Kollár: where you have literally a 30-40% performance jump just for free,
- 24:06László Kiss Kollár: basically,
- 24:07László Kiss Kollár: that just made it a lot more appealing.
- 24:08László Kiss Kollár: And I think it opened up a lot more areas
- 24:11László Kiss Kollár: where Python became competitive and more appealing.
- 24:14László Kiss Kollár: So I think,
- 24:15László Kiss Kollár: yeah, I mean, I shared sort of what Paul mentioned about the complexity,
- 24:22László Kiss Kollár: sort of the JIT coming in,
- 24:25László Kiss Kollár: no-gil Python.
- 24:26László Kiss Kollár: I think it's quite a bit challenging now,
- 24:29László Kiss Kollár: I think, to look at these performance improvements.
- 24:32László Kiss Kollár: I mean, I have a lot of faith in the JIT compiler,
- 24:35László Kiss Kollár: you know, making significant performance improvements.
- 24:39László Kiss Kollár: I'm not sure exactly how exactly it's going to work.
- 24:44Pablo Galindo Salgado: I have a lot of compilers as well, I think.
- 24:46Pablo Galindo Salgado: Compilers are pretty awesome.
- 24:47Pablo Galindo Salgado: Some stuff out of the C eval,
- 24:50Pablo Galindo Salgado: which for statement,
- 24:52Pablo Galindo Salgado: that would be good, you know?
- 24:53Pablo Galindo Salgado: Yep.
- 24:53Pablo Galindo Salgado: Yeah, and I think at the same time,
- 24:55László Kiss Kollár: it's also not forgetting that free trading Python has the potential to provide very significant speedups,
- 25:03László Kiss Kollár: right?
- 25:03László Kiss Kollár: It really depends on the application and the domain.
- 25:07László Kiss Kollár: But I think we can actually see very significant speedups and we can see like certain extensions and performance sensitive libraries can produce very significant speedups.
- 25:18László Kiss Kollár: And I think that's like sort of, I guess what we're seeing is now it's going into in multiple different directions,
- 25:22László Kiss Kollár: depending on your application.
- 25:24László Kiss Kollár: You can benefit from free threading potentially a lot more than,
- 25:28László Kiss Kollár: for example, waiting for a JIT profiler to go further.
- 25:31Pablo Galindo Salgado: Yeah,
- 25:32Pablo Galindo Salgado: I'm really excited about the free threading stuff.
- 25:33Pablo Galindo Salgado: I think it has tons of potential,
- 25:35Pablo Galindo Salgado: but I'm also concerned.
- 25:37Pablo Galindo Salgado: I feel like a lot of the people building libraries and packages for Python have not deeply thought about race conditions.
- 25:44Pablo Galindo Salgado: And I think just because they've assumed, well, the gil and generally single threaded,
- 25:48Pablo Galindo Salgado: at least effectively,
- 25:50Pablo Galindo Salgado: even if they have threads, so whatever.
- 25:52Pablo Galindo Salgado: And then they're going to say, oh,
- 25:53Pablo Galindo Salgado: it's free.
- 25:54Pablo Galindo Salgado: We got these bug reports from free threading.
- 25:56Pablo Galindo Salgado: So we're going to add locks.
- 25:57Pablo Galindo Salgado: And then you're going to have deadlocks in your application.
- 25:59Pablo Galindo Salgado: I just, I feel like there's going to be a couple of waves of growing pains and I don't know.
- 26:04Pablo Galindo Salgado: Yeah.
- 26:05Speaker 2: Yeah.
- 26:05Speaker 2: And part of that is like intrinsic to the porn in particular,
- 26:09Speaker 2: you know, there is a lot
- 26:10Speaker 2: of jokes in the internet about like threads being complicated.
- 26:13Speaker 2: And I think people in the Python ecosystem have not been exposed to what that really
- 26:17Speaker 2: means because sure.
- 26:19Speaker 2: Yeah.
- 26:19Speaker 2: I mean, you, you, you have some problems with threads in Python, but like most of the real
- 26:22Speaker 2: problems are not really exposed to you.
- 26:24Speaker 2: While now,
- 26:25Speaker 2: you know, there is two problems that you need to suffer.
- 26:27Speaker 2: One of them is like,
- 26:28Speaker 2: you know,
- 26:29Speaker 2: you are not tall enough to do multiple threading, which was the joke,
- 26:33Speaker 2: right?
- 26:33Speaker 2: And then the other one is that, you know, free thread may be buggy just because there's bugs in the interpreter,
- 26:39Speaker 2: hopefully not,
- 26:40Speaker 2: but also maybe bugs in the packages,
- 26:42Speaker 2: right?
- 26:43Speaker 2: Or like the other problem that we can see a lot of people running into sometimes is that it doesn't scale linearly.
- 26:51Speaker 2: Like it's not magic.
- 26:52Speaker 2: Again,
- 26:52Speaker 2: this is a matter of threading, it's not easy.
- 26:54Speaker 2: and sometimes you know the cost of not crashing and the multiple threads is that extra checks
- 27:00Speaker 2: need to be done and those extra checks make your use of multiple threading not work and
- 27:05Speaker 2: people are not getting used to profile that thing as well so you know like it's very hard to
- 27:11Speaker 2: understand why your algorithm that should be scaling with number of threads is not scaling
- 27:16Speaker 2: because now you need different tools and not even the tool that we're going to talk about today
- 27:20Speaker 2: works in that case right so you need to like people people need to be really careful with that i like
- 27:25Pablo Galindo Salgado: your analogy of like yeah you're using threadings but you've kind of been sheltered it's like oh yeah
- 27:30Pablo Galindo Salgado: i i traversed the desert car versus on a bicycle right it's yeah you it's not the same experience
- 27:37Pablo Galindo Salgado: of going through the desert in a car like oh it is hot exactly exactly yeah yeah yeah and people
- 27:43Speaker 2: don't know you know they don't know how fresh that the car was when they were towards in the desert
- 27:48László Kiss Kollár: right uh but the deal it made so everything so easy right with uh right is your ac ac in your uh
- 27:59Pablo Galindo Salgado: onda you know desert on that all right exactly yeah all right so so then let's talk profiling so
- 28:06Pablo Galindo Salgado: i think maybe a quick history of profilers in python we've got the more advanced sort of external ones
- 28:13Pablo Galindo Salgado: like memory and so on but let's let's just focus on what i always thought was a little bit of a
- 28:17Pablo Galindo Salgado: weird distinction that there's two profilers,
- 28:20Pablo Galindo Salgado: the C profile and the just profile in Python.
- 28:23Pablo Galindo Salgado: Yeah.
- 28:24Pablo Galindo Salgado: I just pick one, but tell us,
- 28:26Pablo Galindo Salgado: this is what we've had for quite a while.
- 28:28Pablo Galindo Salgado: I've done a lot with these.
- 28:30Pablo Galindo Salgado: So,
- 28:31Speaker 2: yeah, this is like, it's kind of weird to say today where like,
- 28:35Speaker 2: you know,
- 28:35Speaker 2: so many
- 28:36Speaker 2: people are using Python and Python is so big that what we're going to explain here is a
- 28:39Speaker 2: bit like,
- 28:40Speaker 2: you know,
- 28:41Speaker 2: it sounds strange,
- 28:42Speaker 2: but so it used to be a time where like,
- 28:44Speaker 2: you know,
- 28:44Speaker 2: the bar for the modules was much lower.
- 28:48Speaker 2: So the profile module,
- 28:50Speaker 2: I mean, you know, it's a different
- 28:52Speaker 2: time.
- 28:52Speaker 2: I'm not saying I will not do that,
- 28:54Speaker 2: right? But like the quality of the tools that we're using
- 28:56Speaker 2: today,
- 28:56Speaker 2: not just profilers in general,
- 28:58Speaker 2: it's under much more scrutiny because,
- 29:01Speaker 2: you know, it serves
- 29:01Speaker 2: more people and those people have like more demanding workflows.
- 29:04Speaker 2: And this is true,
- 29:05Speaker 2: right?
- 29:05Speaker 2: The software that was written long, long ago had less complexity to deal with because,
- 29:09Speaker 2: you know,
- 29:10Speaker 2: computers were not that, you know, powerful and like the stack was like saluer,
- 29:14Speaker 2: right?
- 29:14Speaker 2: So the profile module was the first attempt that people tried to do profiling in Python.
- 29:19Speaker 2: It's a very good attempt, so like, oh, it's actually good.
- 29:21Speaker 2: The problem is architecturally speaking,
- 29:23Speaker 2: it's not really a good profiler in general.
- 29:25Speaker 2: The reason is because it's written in Python and it runs inside application that is being profiled.
- 29:30Speaker 2: So you don't need to be a profiler expert to know that you're doing extra work to measure the work that is going to skew the results, right?
- 29:37Speaker 2: Because now you're not measuring your application.
- 29:39Speaker 2: You're measuring your application and the profiler at the same time,
- 29:42Speaker 2: right?
- 29:42Speaker 2: So that was bad.
- 29:44Speaker 2: And then this profiler module kind of like does a bunch of tricks to try to measure how much itself is contributing to the problem.
- 29:50Speaker 2: But like you can imagine how flaky that is.
- 29:54Speaker 2: And then the other problem is that it makes your application much slower because it's being measured, right?
- 29:59Speaker 2: And the other slowness was like huge.
- 30:01Speaker 2: Like we're talking about like 20 times slower and things like that.
- 30:04Speaker 2: Or like,
- 30:04Speaker 2: you know,
- 30:05Speaker 2: depending on what you're doing.
- 30:06Speaker 2: So part of the reason as well, again,
- 30:08Speaker 2: is because the profiler itself was written in Python.
- 30:10Speaker 2: So perhaps,
- 30:11Speaker 2: you know,
- 30:12Speaker 2: that was not a great experience.
- 30:16Speaker 2: So the C profile module,
- 30:18Speaker 2: which,
- 30:19Speaker 2: you know, is very explicit about what is a trick,
- 30:21Speaker 2: but like,
- 30:21Speaker 2: unfortunately,
- 30:22Speaker 2: it's a leaky name because like the C in the C profile is the C language, right?
- 30:27Speaker 2: And also,
- 30:29Speaker 2: it has one of the biggest problems that I don't like this module is that the C is lowercase and the P is uppercase.
- 30:34Speaker 2: And the name of the stupid module is like this.
- 30:36Speaker 2: So writing the thing is very annoying.
- 30:39Speaker 2: I always forget which one is uppercase and lowercase.
- 30:41Speaker 2: Anyway,
- 30:42Speaker 2: so the C profile is basically a re-implementation of the profile module in C,
- 30:46Speaker 2: the illegal language.
- 30:47Speaker 2: And then many people don't know why I say this.
- 30:50Speaker 2: This is because the White House released this hyper thing that C was now dangerous because,
- 30:55Speaker 2: you know, it's like memory unsafe.
- 30:57Speaker 2: So I find very funny that the White House said that C is illegal and CPython is,
- 31:04Speaker 2: we are all,
- 31:05Speaker 2: you know, like bandits writing in the illegal language.
- 31:08Speaker 2: Exactly.
- 31:09Speaker 2: Yeah, yeah.
- 31:10Speaker 2: Okay,
- 31:10Speaker 2: so-
- 31:10Pablo Galindo Salgado: Living underground,
- 31:12Pablo Galindo Salgado: hiding from everything with your GCC and your clang.
- 31:17Speaker 2: Exactly.
- 31:17Speaker 2: Give food to your core developer underground.
- 31:19Speaker 2: Yeah, yeah.
- 31:20Pablo Galindo Salgado: At least Seth and team were able to get Python on the good list.
- 31:25Speaker 2: Oh, yeah, yeah, yeah.
- 31:26Speaker 2: We both like that also.
- 31:28Speaker 2: Memory-safe.
- 31:29Speaker 2: And I was like, everybody's like, yeah, yeah, of course, Python is memory-safe.
- 31:32Speaker 2: And I was like thinking,
- 31:33Speaker 2: is it?
- 31:33Speaker 2: They're like, I don't know, man.
- 31:35Speaker 2: I see a lot of bugs, but like, okay,
- 31:37Speaker 2: okay, we are allowed to have bugs,
- 31:39Speaker 2: you know, like Rust as well can have bugs and crash,
- 31:41Speaker 2: maybe less,
- 31:42Speaker 2: but,
- 31:42Speaker 2: you know,
- 31:43Speaker 2: in theory, the language is very safe if you assume that there's no bugs.
- 31:46Speaker 2: Anyway,
- 31:47Speaker 2: so C profile is this like implementation of the whole tree bank in C.
- 31:52Speaker 2: So it's faster than profile,
- 31:54Speaker 2: actually,
- 31:55Speaker 2: it's 10 times faster or so.
- 31:56Speaker 2: But it still,
- 31:57Speaker 2: again,
- 31:57Speaker 2: has the same problem,
- 31:59Speaker 2: just less. So it makes your application still two or three times slower,
- 32:02Speaker 2: something like that, which is already huge, right?
- 32:04Speaker 2: Like thinking that your application takes five minutes,
- 32:07Speaker 2: now it takes 15 minutes, right?
- 32:08Speaker 2: So not great.
- 32:09Speaker 2: And also the problem is that it also runs in the process.
- 32:13Speaker 2: So I don't want to get the impression
- 32:15Speaker 2: that this is just negative.
- 32:17Speaker 2: So because now Cprofile is actually,
- 32:19Speaker 2: it's well architecture,
- 32:21Speaker 2: it's now in C,
- 32:22Speaker 2: so it's all good.
- 32:23Speaker 2: And now the problems in the slowdowns
- 32:26Speaker 2: are an inherited property of these kind of tools,
- 32:28Speaker 2: right?
- 32:28Speaker 2: Because that run inside the profiler.
- 32:30Speaker 2: These are called tracing profilers.
- 32:32Speaker 2: The reason they are called tracing profilers
- 32:34Speaker 2: because they see every single call that is happening,
- 32:37Speaker 2: right?
- 32:37Speaker 2: So every time you call a function, they see that
- 32:39Speaker 2: and they need to record that.
- 32:40Speaker 2: So it's a lot of work to do,
- 32:42Speaker 2: but also because they run in the process,
- 32:45Speaker 2: every time you call a function,
- 32:46Speaker 2: now you do this extra work
- 32:47Speaker 2: and then therefore your thing is worse.
- 32:49Speaker 2: The bright side, of course,
- 32:51Speaker 2: is that you collect everything.
- 32:53Speaker 2: So if you want to know how many times
- 32:54Speaker 2: your progress is calling,
- 32:56Speaker 2: send money to employees,
- 32:57Speaker 2: you will know how much money are you selling to employees.
- 32:59Speaker 2: You are not missing it.
- 33:01Pablo Galindo Salgado: If it says seven times, it was called seven times.
- 33:03Pablo Galindo Salgado: Yeah, it wasn't just a statistical analysis,
- 33:06Pablo Galindo Salgado: yeah.
- 33:06Speaker 2: Exactly,
- 33:07Speaker 2: exactly.
- 33:07Speaker 2: So you can tell your employees that were not paid
- 33:09Speaker 2: that that was not the reason,
- 33:10Speaker 2: right?
- 33:10Speaker 2: So in that case, then,
- 33:13Speaker 2: it's really good for that.
- 33:13Speaker 2: The same way Membray, for example,
- 33:15Speaker 2: if you recall,
- 33:16Speaker 2: Membray is also a tracing profiler
- 33:18Speaker 2: because, you know, imagine that you lose a one gigabyte allocation.
- 33:21Speaker 2: Can you imagine that, oh,
- 33:23Speaker 2: well, we just lose that one.
- 33:24Speaker 2: And, like,
- 33:24Speaker 2: you know, I suppose your application is fine.
- 33:26Speaker 2: Like, you don't want that, right?
- 33:27Speaker 2: Like, you want Membray to tell you exactly everything that happened.
- 33:30Speaker 2: In time, it's different, right?
- 33:31Speaker 2: because like we will talk about that in a second,
- 33:33Speaker 2: Laszlo will explain,
- 33:34Speaker 2: but, you know,
- 33:35Speaker 2: here,
- 33:36Speaker 2: that's the advantage of Zprofile still even today
- 33:39Speaker 2: because,
- 33:39Speaker 2: you know,
- 33:40Speaker 2: perhaps people will hear today's episode
- 33:41Speaker 2: and say,
- 33:42Speaker 2: well, Zprofile is not good anymore.
- 33:43Speaker 2: We should throw it away,
- 33:44Speaker 2: but it still has its own use cases.
- 33:47Speaker 2: So that is, I think, a brief story
- 33:48Speaker 2: of like why we have to...
- 33:50Pablo Galindo Salgado: Laszlo, what do you want to add to that?
- 33:52László Kiss Kollár: Yeah, so I think it's definitely,
- 33:54László Kiss Kollár: I think, a problem with the ergonomics as well.
- 33:57László Kiss Kollár: And if you're a developer
- 33:58László Kiss Kollár: and you want to provide a Python application,
- 34:00László Kiss Kollár: And I think if you look at the documentation,
- 34:03László Kiss Kollár: I,
- 34:03László Kiss Kollár: when I first looked at this,
- 34:04László Kiss Kollár: found it very confusing.
- 34:06László Kiss Kollár: How do I decide whether it's Cprofile or Profile, right?
- 34:08László Kiss Kollár: And then I think it just became sort of the defacto standard.
- 34:12László Kiss Kollár: You just always use Cprofile, right?
- 34:14László Kiss Kollár: Why exactly it's unclear,
- 34:15László Kiss Kollár: right?
- 34:16László Kiss Kollár: So I think, but I also think that there haven't been,
- 34:20László Kiss Kollár: like CPI didn't have obviously something profiling
- 34:23László Kiss Kollár: and it didn't have powerful profiling tools.
- 34:25László Kiss Kollár: So you always had to look for external tools
- 34:28László Kiss Kollár: to get actually like higher quality sort of profiling results.
- 34:32László Kiss Kollár: And of course,
- 34:33László Kiss Kollár: there's an entire family of situations
- 34:37László Kiss Kollár: where you cannot use a tracing profiler
- 34:39László Kiss Kollár: because effectively for a tracing profiler,
- 34:41László Kiss Kollár: you have to reconstruct a small sample test.
- 34:44László Kiss Kollár: You cannot run that on your application,
- 34:47László Kiss Kollár: right?
- 34:47László Kiss Kollár: Because it would just be too slow.
- 34:50László Kiss Kollár: It's too time consuming.
- 34:51László Kiss Kollár: So generally you would just have a test case or something
- 34:53László Kiss Kollár: and run it on that.
- 34:55Pablo Galindo Salgado: Yeah, the worst of that is
- 34:56Pablo Galindo Salgado: It doesn't work great in production,
- 34:58Pablo Galindo Salgado: but I profiled it locally and it seems okay.
- 35:02Pablo Galindo Salgado: So what's going on, right?
- 35:03Pablo Galindo Salgado: Exactly.
- 35:04László Kiss Kollár: You can't really reproduce the exact same situation oftentimes.
- 35:07László Kiss Kollár: And then you're basically left with no options or you have to start downloading,
- 35:12László Kiss Kollár: finding some third-party option.
- 35:14Pablo Galindo Salgado: I can't, Pablo, I got to circle back to this a little bit because I think it's really interesting.
- 35:20Pablo Galindo Salgado: So you talked about the tracing profilers, which C profile and profile is,
- 35:25Pablo Galindo Salgado: and how it makes,
- 35:26Pablo Galindo Salgado: they're very accurate, but they make a big impact on basically what is happening with your code.
- 35:32Pablo Galindo Salgado: And it reminds me of quantum mechanics a little bit.
- 35:35Pablo Galindo Salgado: Wow.
- 35:35Pablo Galindo Salgado: Let's go.
- 35:36Speaker 2: Let's go.
- 35:37Pablo Galindo Salgado: It's like there might've been a function.
- 35:39Pablo Galindo Salgado: Let's take two functions.
- 35:40Pablo Galindo Salgado: They each take half a second in practice on their own,
- 35:43Pablo Galindo Salgado: right?
- 35:43Pablo Galindo Salgado: One of them has to do something with a file system a million times in a loop.
- 35:48Pablo Galindo Salgado: Another one of them calls an API,
- 35:50Pablo Galindo Salgado: which takes half a second to return.
- 35:52Pablo Galindo Salgado: You run that in a tracing profiler.
- 35:54Pablo Galindo Salgado: The one that calls the API is barely changed.
- 35:57Pablo Galindo Salgado: It's tracing one call,
- 35:58Pablo Galindo Salgado: sort of,
- 35:58Pablo Galindo Salgado: right?
- 35:59Pablo Galindo Salgado: You do the other one.
- 36:00Pablo Galindo Salgado: It's now a million plus little intercepts of like a function call over and over and over.
- 36:05Pablo Galindo Salgado: And it makes that one that's chatty in Python seem really,
- 36:09Pablo Galindo Salgado: really slow.
- 36:10Pablo Galindo Salgado: By observing it, you've changed it.
- 36:12Pablo Galindo Salgado: You know what I mean?
- 36:12Pablo Galindo Salgado: Yeah,
- 36:13Pablo Galindo Salgado: yeah, yeah.
- 36:13Pablo Galindo Salgado: In this sense.
- 36:15Speaker 2: I'm very sad to report that, unfortunately,
- 36:18Speaker 2: because you're talking to a physicist,
- 36:19Speaker 2: I'm going to be a pain here.
- 36:21Speaker 2: Do it. Let's do it. Let's get it right.
- 36:22Speaker 2: I'm going to put my pedantic hat here.
- 36:27Speaker 2: So, yes,
- 36:27Speaker 2: you're right.
- 36:28Speaker 2: Also,
- 36:31Speaker 2: technically speaking, it's not really correct.
- 36:33Speaker 2: The reason is because,
- 36:33Speaker 2: yes, that is indeed what happens in quantum mechanics.
- 36:36Speaker 2: When you observe,
- 36:37Speaker 2: you modify the system.
- 36:38Speaker 2: That is correct. That part is correct.
- 36:39Speaker 2: But the reason the metaphor kind of like doesn't fully work is because the important part of quantum mechanics
- 36:44Speaker 2: is that before,
- 36:45Speaker 2: if this was quantum mechanics,
- 36:47Speaker 2: before you actually measure your program,
- 36:50Speaker 2: your program is both fast and slow at the same time.
- 36:52Speaker 2: But that's the key,
- 36:55Speaker 2: right?
- 36:55Pablo Galindo Salgado: We got the cat in the box as the profiler now.
- 36:58Pablo Galindo Salgado: Yeah, right, right.
- 36:59Pablo Galindo Salgado: Here,
- 36:59Speaker 2: the profiler,
- 37:01Speaker 2: sorry, your program was the cat.
- 37:02Speaker 2: So your cat is dead,
- 37:04Speaker 2: right?
- 37:04Speaker 2: And then you say, well,
- 37:06Speaker 2: you know,
- 37:06Speaker 2: I can move the box and then suddenly,
- 37:11Speaker 2: you know,
- 37:11Speaker 2: I open the box and it's dead, right?
- 37:13Speaker 2: So you say, well, you modify the system.
- 37:15Speaker 2: But here,
- 37:16Speaker 2: you know,
- 37:17Speaker 2: for being quantum mechanics,
- 37:18Speaker 2: you,
- 37:19Speaker 2: I mean, it would be a very good excuse
- 37:20Speaker 2: to tell your boss and then say, no, no, no, you don't understand.
- 37:23Speaker 2: This program is fast and slow at the same time.
- 37:25Speaker 2: If we measure, we would screw it up,
- 37:27Speaker 2: you know?
- 37:28Speaker 2: So like,
- 37:28Speaker 2: we must not measure the program.
- 37:31Speaker 2: Well, here,
- 37:31Speaker 2: of course, you can imagine that what happens here is that the program is either
- 37:35Speaker 2: fast or slow.
- 37:36Speaker 2: And what happens is that when you measure, you are making it much slower.
- 37:40Speaker 2: So,
- 37:40Speaker 2: but it was already fast or slow.
- 37:42Speaker 2: It's just you're making it worse.
- 37:44Speaker 2: So it was slow, now it's very slow.
- 37:46Speaker 2: And if it's less fast, now it's slow.
- 37:48Speaker 2: But it's not like, oh,
- 37:49Speaker 2: wow, it was in this superposition of states.
- 37:52Speaker 2: I know I'm not a fan person,
- 37:53Speaker 2: so don't feel too bad.
- 37:56Speaker 2: It's still a good metaphor.
- 37:58Pablo Galindo Salgado: My warning is that the tracing profilers make it unevenly slower.
- 38:04Pablo Galindo Salgado: Some parts get away.
- 38:06Pablo Galindo Salgado: Like parts that do a lot of internal in Python function calls are affected a lot.
- 38:11Pablo Galindo Salgado: stuff that works with external systems that don't require much execution of python but themselves
- 38:16Pablo Galindo Salgado: are slow are not very affected by tracing profilers that was my warning my my quantum mechanics
- 38:23Pablo Galindo Salgado: analogy wasn't perfect i understand so let's try this sorry sorry sorry no what about string theory
- 38:28Pablo Galindo Salgado: no no i'm just kidding let's let's talk about let's talk about the peps let's talk about what's
- 38:34Pablo Galindo Salgado: coming here.
- 38:36Pablo Galindo Salgado: Oh,
- 38:36Speaker 2: right, right.
- 38:37Pablo Galindo Salgado: And we got the PEP 799,
- 38:39Pablo Galindo Salgado: a dedicated profiling package
- 38:41Pablo Galindo Salgado: for organizing Python profiling tools by the two of you.
- 38:45Pablo Galindo Salgado: Awesome.
- 38:45Pablo Galindo Salgado: Tell us about this.
- 38:46Pablo Galindo Salgado: And then we're going to talk about 768,
- 38:48Pablo Galindo Salgado: which is some of the actual changes.
- 38:52Pablo Galindo Salgado: Yeah.
- 38:52László Kiss Kollár: So how did we start the back story,
- 38:54László Kiss Kollár: Pablo,
- 38:54László Kiss Kollár: that I think we actually were planning
- 38:56László Kiss Kollár: to put the something profiler in the profile package,
- 38:59László Kiss Kollár: right?
- 39:00László Kiss Kollár: I think that was the original conning plan.
- 39:02László Kiss Kollár: And then it turned out we cannot do that.
- 39:06László Kiss Kollár: And that led to this path.
- 39:08László Kiss Kollár: Because basically,
- 39:09László Kiss Kollár: let's do the right thing, right?
- 39:10László Kiss Kollár: Let's clean up this.
- 39:12László Kiss Kollár: I don't want to say mess, but let's clean things up.
- 39:14László Kiss Kollár: And that would mean that you're going to have a single tracing profiler.
- 39:19László Kiss Kollár: Eventually, we can talk about how that's going to go.
- 39:20László Kiss Kollár: And then you're going to have one sampling profiler.
- 39:22László Kiss Kollár: And this is all going to be grouped into the profiling package,
- 39:25László Kiss Kollár: which should provide much better sort of ergonomics.
- 39:28László Kiss Kollár: It should make it much easier for developers to decide
- 39:31László Kiss Kollár: what tool they should reach for.
- 39:32László Kiss Kollár: And it also means that there are not going to be
- 39:34László Kiss Kollár: two different tracing profilers,
- 39:36László Kiss Kollár: which makes it difficult to,
- 39:37László Kiss Kollár: again,
- 39:38László Kiss Kollár: like to choose the right thing.
- 39:39László Kiss Kollár: So profiling the tracing effectively becomes,
- 39:42László Kiss Kollár: that's basically C-profile.
- 39:45László Kiss Kollár: And C-profile is going to continue living on
- 39:47László Kiss Kollár: as the C-profile import as well for compatibility.
- 39:51László Kiss Kollár: But profile,
- 39:52László Kiss Kollár: so that the old Python-only version
- 39:54László Kiss Kollár: is effectively deprecated and will be removed eventually.
- 39:59László Kiss Kollár: And then profiling with sampling is the new profiler,
- 40:01László Kiss Kollár: Tachium.
- 40:02Pablo Galindo Salgado: It makes it super obvious.
- 40:03Pablo Galindo Salgado: You just import profiling.tracing or profiling.sampling.
- 40:08Pablo Galindo Salgado: If you understand the nomenclature of profiling,
- 40:10Pablo Galindo Salgado: it tells you exactly what you're getting, right?
- 40:11Speaker 2: Yeah, it gets a bit long with time,
- 40:14Speaker 2: right?
- 40:14Speaker 2: Because like you mostly,
- 40:16Speaker 2: as we will discuss,
- 40:16Speaker 2: mostly all the time you want profiling.sampling.
- 40:19Speaker 2: So now it's like,
- 40:20Speaker 2: damn,
- 40:21Speaker 2: profiling.sampling.
- 40:23Speaker 2: Like, this is very, very boring.
- 40:25Speaker 2: But,
- 40:25Speaker 2: you know, I propose to just call it Tachium.
- 40:28Speaker 2: Like,
- 40:28Speaker 2: you know, maybe in 3.16,
- 40:31Speaker 2: I can convince people to let me have a top level binary name.
- 40:35Speaker 2: You know, the same way when you install Python in a VAMF, you get,
- 40:39Speaker 2: so you can get Tachyon.
- 40:41Speaker 2: Like, we'll see, we'll see.
- 40:43Pablo Galindo Salgado: Maybe you should,
- 40:44László Kiss Kollár: sorry,
- 40:45László Kiss Kollár: maybe you should propose to have a C-Tachyon and a Tachyon module.
- 40:49László Kiss Kollár: Confuse everyone.
- 40:50Speaker 2: Oh, C-Tachyon.
- 40:51Speaker 2: But Tachyon is C already.
- 40:53László Kiss Kollár: And then just make a compromise to have just Tachyon,
- 40:56László Kiss Kollár: right?
- 40:56Speaker 2: No, no, no.
- 40:57Speaker 2: Because Tachyon is C, then it will be P-Python in Python.
- 41:00Speaker 2: Like a pure Python implementation of Tachyon.
- 41:02Speaker 2: P-Python.
- 41:04Pablo Galindo Salgado: I've got a fix for you, Pablo.
- 41:06Pablo Galindo Salgado: Just create a Python package called Tachyon.
- 41:09Speaker 2: Oh, already exists,
- 41:10Speaker 2: man.
- 41:10Pablo Galindo Salgado: And then all it does is import profiling,
- 41:14Pablo Galindo Salgado: tracing,
- 41:15Pablo Galindo Salgado: or sampling as Tachyon.
- 41:18Speaker 2: But apparently we cannot.
- 41:18Pablo Galindo Salgado: And then you'll be exit.
- 41:20Pablo Galindo Salgado: Yeah, you're good to go.
- 41:21Speaker 2: Okay, or I can bribe Charlie Marsh that they add UB-Tachyon.
- 41:27Speaker 2: You know, like uv profile.
- 41:29Speaker 2: UV profile?
- 41:30Speaker 2: How many megadollars, how many megadollars are needed for this?
- 41:35Speaker 2: Like, we will see.
- 41:36Speaker 2: Open AI.
- 41:37Speaker 2: Sam Alman.
- 41:38Speaker 2: Make it happen,
- 41:38Speaker 2: yes.
- 41:39Speaker 2: Allow this to happen.
- 41:40Speaker 2: Yes, yes.
- 41:41Speaker 2: You will be so much popular on the Anthropics, those guys.
- 41:44Pablo Galindo Salgado: You just need a little prompt injection.
- 41:45Pablo Galindo Salgado: You'll be good to go.
- 41:46Speaker 2: Yes, exactly, exactly.
- 41:47Pablo Galindo Salgado: All right, so,
- 41:48Pablo Galindo Salgado: Oslo, you mentioned the old Python profile module
- 41:53Pablo Galindo Salgado: is under deprecation warning.
- 41:56Pablo Galindo Salgado: And that will be in 15 and 16.
- 41:59Pablo Galindo Salgado: And actually two years from now,
- 42:00Pablo Galindo Salgado: two years from now,
- 42:01Pablo Galindo Salgado: plus a month,
- 42:02Pablo Galindo Salgado: it will be out.
- 42:03Pablo Galindo Salgado: It will be removed in 317.
- 42:05Pablo Galindo Salgado: So just heads up for people.
- 42:07Speaker 2: Obliterated.
- 42:08Pablo Galindo Salgado: That's right.
- 42:08Pablo Galindo Salgado: It will be recated into history for real.
- 42:11Speaker 2: Oblivion.
- 42:12Speaker 2: Oblivion.
- 42:12Pablo Galindo Salgado: Okay.
- 42:13Pablo Galindo Salgado: So this is really just kind of an organizational deal, right?
- 42:16Pablo Galindo Salgado: This PEP.
- 42:17Pablo Galindo Salgado: Okay.
- 42:17Pablo Galindo Salgado: And then we have PEP 768,
- 42:20Pablo Galindo Salgado: which sort of makes this possible,
- 42:21Pablo Galindo Salgado: right?
- 42:22Pablo Galindo Salgado: It makes Tachyon,
- 42:23Pablo Galindo Salgado: the new profiler,
- 42:24Pablo Galindo Salgado: accessible,
- 42:25Pablo Galindo Salgado: right?
- 42:26Speaker 2: Yes.
- 42:26Speaker 2: So the original of that PEP was to,
- 42:30Speaker 2: that's the previous work we did with my colleagues from Bloomberg,
- 42:33Speaker 2: Ivana and Matt.
- 42:34Speaker 2: And the idea here is that we were chasing this goal,
- 42:37Speaker 2: like North Star, of allowing PDB, the Python debugger,
- 42:41Speaker 2: and technically any other debugger, but also the one that we ship in the standard library.
- 42:45Speaker 2: So we wanted that to be able to attach to their programs.
- 42:48Speaker 2: So you could have a program running in production that is doing weird stuff.
- 42:51Speaker 2: And instead of having to stop it and then running under the debugger,
- 42:55Speaker 2: you could just say, hey,
- 42:57Speaker 2: you know,
- 42:57Speaker 2: touch to that program
- 42:58Speaker 2: and like, tell me what's wrong,
- 42:59Speaker 2: right?
- 43:00Speaker 2: So we wanted that.
- 43:01Speaker 2: And then we added,
- 43:01Speaker 2: therefore,
- 43:02Speaker 2: to achieve this,
- 43:03Speaker 2: we added all these capabilities to CPython
- 43:07Speaker 2: such that you could attach to a running process
- 43:09Speaker 2: and then you could inspect the running process, right?
- 43:10Speaker 2: Because the debugger needs to inspect the running process.
- 43:12Speaker 2: So we have all this machinery there.
- 43:15Speaker 2: And,
- 43:15Speaker 2: you know, that was this PEP and that's shipping 3.14.
- 43:19Speaker 2: And 3.14 has a bunch of utilities that use this machinery
- 43:22Speaker 2: and allow you to attach with PDV and much more,
- 43:25Speaker 2: right?
- 43:26Speaker 2: But then we were at PyCon US 2025,
- 43:30Speaker 2: and then I went to Laszlo,
- 43:31Speaker 2: and then I told Laszlo,
- 43:32Speaker 2: hey, Laszlo, would it be cool to call this in a loop?
- 43:35Speaker 2: And then we have a profiler,
- 43:38Speaker 2: and then Laszlo is like, yes, let's just do it.
- 43:40Speaker 2: So in the sprint,
- 43:41Speaker 2: we did this mini program
- 43:44Speaker 2: that was calling this thing in a loop,
- 43:45Speaker 2: right?
- 43:46Speaker 2: So this thing allows you to get the stack of the application,
- 43:49Speaker 2: kind of, and then at the end,
- 43:50Speaker 2: the profiler is just doing it very quickly and dump the information somewhere.
- 43:55Speaker 2: But that is at the point not important.
- 43:57Speaker 2: The most important part is how fast can you see what the program is doing, right?
- 44:01Speaker 2: That's what a sampling profiler does.
- 44:03Speaker 2: And just for reference,
- 44:05Speaker 2: because many people may not be aware of these tools,
- 44:09Speaker 2: the minimum, minimum, minimum number that you are looking at
- 44:12Speaker 2: may be something like 100 times per second,
- 44:15Speaker 2: right?
- 44:15Speaker 2: That would be on the realm of useful already.
- 44:18Speaker 2: And it goes from there to more than that,
- 44:21Speaker 2: right?
- 44:21Speaker 2: So we put the loop and then we measure, okay,
- 44:24Speaker 2: how fast is this loop here?
- 44:27Speaker 2: And it was like two times per second,
- 44:29Speaker 2: like two times per second.
- 44:31Speaker 2: That was how fast it was,
- 44:34Speaker 2: which as you can imagine is not fantastic, not fantastic.
- 44:36Speaker 2: So we sat down together and for the course of the sprint,
- 44:40Speaker 2: we basically moved from two times per second to an illegal number,
- 44:47Speaker 2: like a month of frames per second,
- 44:49Speaker 2: which I think even today is more than a million times per second.
- 44:53Speaker 2: But yeah,
- 44:53Speaker 2: how was your experience during that time, Lasslo?
- 44:56László Kiss Kollár: Well, yeah, I remember that we were chatting about this
- 44:59László Kiss Kollár: in the beginning of the sprints
- 45:00László Kiss Kollár: and Pablo laid out the plan.
- 45:02László Kiss Kollár: This is what we're going to do.
- 45:04László Kiss Kollár: I'm going to figure out how fast this thing is
- 45:07László Kiss Kollár: and then I will see if I can make it faster
- 45:08László Kiss Kollár: because it might not be that good yet.
- 45:11László Kiss Kollár: And you're going to work on building UI around this, the CLI, right?
- 45:15László Kiss Kollár: Like,
- 45:16László Kiss Kollár: let's build up all the machinery.
- 45:18László Kiss Kollár: And then we sat down and probably just said,
- 45:20László Kiss Kollár: hey, this thing is so very slow.
- 45:22László Kiss Kollár: This is, like,
- 45:22László Kiss Kollár: not useful.
- 45:23László Kiss Kollár: And then we literally spent the entire rest of the sprint working on that.
- 45:26László Kiss Kollár: I think we actually ended up with no code committed,
- 45:30László Kiss Kollár: I think,
- 45:30László Kiss Kollár: during the sprint.
- 45:31László Kiss Kollár: All of the actual commits went in later on.
- 45:35László Kiss Kollár: But the sort of going through these motions of,
- 45:38László Kiss Kollár: like,
- 45:38László Kiss Kollár: basically every single change, getting a 10x.
- 45:42László Kiss Kollár: I mean, initially, it was easy to get a 10x improvement
- 45:44László Kiss Kollár: when you have like two hertz,
- 45:47László Kiss Kollár: two samples a second, right?
- 45:49László Kiss Kollár: But then just making it faster and faster.
- 45:51László Kiss Kollár: And actually I remember that even after that,
- 45:54László Kiss Kollár: Pablo made a couple of improvements later on
- 45:57László Kiss Kollár: and maybe we can go into details later,
- 45:58László Kiss Kollár: but he made a couple of improvements
- 46:00László Kiss Kollár: which really just made it.
- 46:02László Kiss Kollár: It was already, I think around 200,000,
- 46:04László Kiss Kollár: maybe 100,000, 200,000 hertz
- 46:06László Kiss Kollár: at the end of that on the sprints
- 46:08László Kiss Kollár: and then still like a 4X,
- 46:10László Kiss Kollár: 5X improvement later on.
- 46:12László Kiss Kollár: So I think That's
- 46:12Pablo Galindo Salgado: crazy.
- 46:13László Kiss Kollár: Yeah, and I think it was a headline later on.
- 46:16László Kiss Kollár: It's the fastest sampling profiler,
- 46:20László Kiss Kollár: basically.
- 46:21Speaker 2: Yeah,
- 46:21Speaker 2: just to be clear also,
- 46:23Speaker 2: I think it's a good moment to mention this.
- 46:25Speaker 2: This is not the first sampling profiler of this kind there is by far, right?
- 46:29Speaker 2: There is a couple of them.
- 46:32Speaker 2: There's quite a lot of tooling in this space.
- 46:34Speaker 2: Perhaps the most famous existing tooling there is
- 46:36Speaker 2: is another profiler called Pyospy,
- 46:39Speaker 2: which has been for a while.
- 46:42Speaker 2: and it's a very good piece of software.
- 46:45Speaker 2: It's written in Rust.
- 46:46Speaker 2: And this is quite efficient.
- 46:49Speaker 2: The thing, so you may ask,
- 46:51Speaker 2: okay, why to have one in the standard library,
- 46:54Speaker 2: right?
- 46:54Speaker 2: So the answer to that is that, first of all,
- 46:58Speaker 2: unfortunately, PySpy and any other provider of this kind,
- 47:01Speaker 2: because it doesn't run inside your application,
- 47:03Speaker 2: the trade-off is that it needs to learn
- 47:05Speaker 2: how to analyze your application,
- 47:07Speaker 2: right?
- 47:07Speaker 2: And that is understanding the Python interpreter.
- 47:10Speaker 2: But these parts of the Python interpreter are not public,
- 47:13Speaker 2: right?
- 47:13Speaker 2: Like we don't expose that.
- 47:14Speaker 2: It needs to illegally access to them.
- 47:17Speaker 2: And that means that there is a competing set of circumstances here
- 47:22Speaker 2: because the core developers,
- 47:23Speaker 2: first of all,
- 47:24Speaker 2: we used to not care about this use case because it was not part of our APIs.
- 47:29Speaker 2: So we keep changing things in ways that make it really, really hard
- 47:32Speaker 2: for Biospy and other profiles like Austin to catch up with this.
- 47:35Speaker 2: To the point that,
- 47:36Speaker 2: for instance, it used to be the case
- 47:38Speaker 2: that profiling 3.11 was much slower than profiling 3.10
- 47:41Speaker 2: because 3.11 made changes that make this really, really hard.
- 47:45Speaker 2: And sometimes,
- 47:46Speaker 2: I was keeping an eye to help these tools,
- 47:48Speaker 2: but sometimes people were making changes
- 47:50Speaker 2: that were making it impossible to profile
- 47:52Speaker 2: because it was hiding this so much
- 47:54Speaker 2: that you couldn't have access to it.
- 47:56Speaker 2: So one advantage to have this on the standard library,
- 47:59Speaker 2: of course, is that now this is something that we offer.
- 48:03Speaker 2: And this profile is also like the reference implementation
- 48:06Speaker 2: of such a profiler.
- 48:08Speaker 2: So if we can do it, then anyone can do it, right?
- 48:10Speaker 2: So that we ensure that this is a feature
- 48:13Speaker 2: that Python offers and will never break.
- 48:15Speaker 2: And if you want to,
- 48:16Speaker 2: you know,
- 48:16Speaker 2: make your profiler externally,
- 48:19Speaker 2: then you just need to reimplement what we do,
- 48:21Speaker 2: right?
- 48:21Speaker 2: And then you always have a way.
- 48:22Speaker 2: You can look at how we do it
- 48:23Speaker 2: and then you can do it as well.
- 48:25Speaker 2: So that is very important.
- 48:26Speaker 2: The second part is that,
- 48:28Speaker 2: you know,
- 48:28Speaker 2: as many,
- 48:29Speaker 2: there's many examples
- 48:30Speaker 2: and this is a very delicate aspect of it,
- 48:32Speaker 2: is that having this tool in the standard library,
- 48:34Speaker 2: we consider now that this was like very important to have it in the set of like batteries included
- 48:39Speaker 2: right because you know you need to like learn for a external tool like is that external tool going to
- 48:44Speaker 2: be as with the quality that we expect and is going to like have all the edge cases that can have so
- 48:50Speaker 2: because we are dealing with internal soft cpython we don't know in real time all the little
- 48:55Speaker 2: intricacies intricacies of like handling these problems so we want to share that the tools
- 49:00Speaker 2: that we offer are of the utmost quality that we can provide,
- 49:03Speaker 2: right?
- 49:04Speaker 2: Which is to say that it's not that we don't trust the others,
- 49:07Speaker 2: right?
- 49:07Speaker 2: But we want to ensure that users at least have a very good reason
- 49:11Speaker 2: to use something that is built in.
- 49:15Speaker 2: And then the third reason,
- 49:16Speaker 2: which is piggybacking on what Laszlo was saying,
- 49:20Speaker 2: is that at some point, we managed to achieve the same speed
- 49:24Speaker 2: as any other tool outside,
- 49:26Speaker 2: including PySpy and Austin,
- 49:27Speaker 2: right?
- 49:27Speaker 2: But then because we have an extra trick that they don't have,
- 49:31Speaker 2: which is that we also control the interpreter,
- 49:33Speaker 2: right?
- 49:33Speaker 2: Because this is now in CPython.
- 49:34Speaker 2: So now we could do changes to the interpreter with the only purpose to ensure the profiling is faster,
- 49:40Speaker 2: right?
- 49:40Speaker 2: And also, by the way, this means that anyone can also do that,
- 49:43Speaker 2: right?
- 49:43Speaker 2: So now anyone,
- 49:45Speaker 2: like those other profilers can also,
- 49:46Speaker 2: you know, now we say that this is the faster Python profiler,
- 49:49Speaker 2: but,
- 49:50Speaker 2: you know, I'm pretty sure this is not going to be for long.
- 49:52Speaker 2: Spoilers in a second.
- 49:53Speaker 2: but like part of the reason is because anyone can use the tricks is but it's just like we did
- 49:58Speaker 2: you know we can ensure that those tricks work and those tricks are there so part of the reason we
- 50:02Speaker 2: could go past what was possible before is because we can cheat a bit and we can like change the
- 50:06Speaker 2: interpreter such that like it exposes easier information and some of those tricks are really
- 50:11Speaker 2: really cool and complicated like the way you know it can go faster is really interesting
- 50:18Speaker 2: perhaps i don't know if we can explain it here but like uh they're quite advanced but like anyone
- 50:23Speaker 2: can pull those tricks if they know how it works, right?
- 50:25Speaker 2: It's just that they need to ensure that they implement those things.
- 50:29Pablo Galindo Salgado: Yeah,
- 50:30Pablo Galindo Salgado: very interesting.
- 50:31Pablo Galindo Salgado: I don't know if we actually called out the title,
- 50:34Pablo Galindo Salgado: but PEP768 is a safe external bugger interface for CPython.
- 50:38Pablo Galindo Salgado: And debugger means like, hey, what are you doing?
- 50:41Pablo Galindo Salgado: But that's also kind of a profiling thing of your only purpose
- 50:43Pablo Galindo Salgado: just to say, what are you doing?
- 50:45Pablo Galindo Salgado: Where are you?
- 50:45Pablo Galindo Salgado: Where are you?
- 50:46Pablo Galindo Salgado: Where are you?
- 50:46Pablo Galindo Salgado: Like over and over a million times a second,
- 50:48Pablo Galindo Salgado: whatever frequency you want to run at, right?
- 50:50Speaker 2: Right.
- 50:51László Kiss Kollár: There's another interesting aspect where a built-in sampling profiler in CPython is super useful,
- 50:57László Kiss Kollár: which is that, and I ran into this myself as well, that when you're working on CPython itself,
- 51:02László Kiss Kollár: you don't have a profiler which you can use to measure performance.
- 51:05László Kiss Kollár: Because typically the third-party profilers will,
- 51:08László Kiss Kollár: when you're in an alpha phase of the changes,
- 51:12László Kiss Kollár: typically those profilers wouldn't support that version of CPython.
- 51:17László Kiss Kollár: Now you will have a something profiler which works,
- 51:21László Kiss Kollár: which is within NCPython itself.
- 51:23László Kiss Kollár: I run into this working on the profiler itself.
- 51:27László Kiss Kollár: How do you measure the performance of the profiling code,
- 51:32László Kiss Kollár: like all of those Python,
- 51:34László Kiss Kollár: fairly complex Python code?
- 51:37László Kiss Kollár: You can't really do that without having a profiler built in.
- 51:41László Kiss Kollár: So that's another nice effect of having a something
- 51:44László Kiss Kollár: profile built into the standard library itself.
- 51:47Pablo Galindo Salgado: Yeah. And as Pablo said, you can optimize for it so that now that you have a stable interface,
- 51:51Pablo Galindo Salgado: we can say, okay, this is the thing we're going to optimize with everyone else just randomly
- 51:55Pablo Galindo Salgado: poking around the bytes and my code and all that kind of stuff.
- 51:58Pablo Galindo Salgado: It's like,
- 51:58Speaker 2: well, you still need to poke around the bytes on the bytecode. It's just like,
- 52:01Speaker 2: at least now,
- 52:02Speaker 2: you know, it's possible.
- 52:03Speaker 2: You know, you can follow the trail,
- 52:04Speaker 2: you can follow the soldiers of giants kind of thing, you know?
- 52:08Speaker 2: Yeah,
- 52:09Pablo Galindo Salgado: exactly.
- 52:10Pablo Galindo Salgado: Exactly.
- 52:11Pablo Galindo Salgado: It is interesting.
- 52:12Pablo Galindo Salgado: You could use it to figure out how stuff runs on the
- 52:14Pablo Galindo Salgado: newer versions,
- 52:15Pablo Galindo Salgado: because even though maybe the shape of stuff has changed,
- 52:17Pablo Galindo Salgado: it's still the same API.
- 52:18Pablo Galindo Salgado: Oh,
- 52:19Speaker 2: actually,
- 52:20Speaker 2: yeah.
- 52:21Speaker 2: And also just to clarify another thing,
- 52:23Speaker 2: like right now, which is also
- 52:25Speaker 2: important and it's also an advantage of the other profilers is that, of course,
- 52:29Speaker 2: this is using this
- 52:30Speaker 2: extra technology that we added to 3.15,
- 52:32Speaker 2: which means that it only runs in 3.15.
- 52:34Speaker 2: So you can only
- 52:35Speaker 2: analyze 3.15 code from 3.15,
- 52:39Speaker 2: while PySpy works with any Python.
- 52:41Speaker 2: So right now you want to run
- 52:43Speaker 2: PiSpy on 3.12,
- 52:44Speaker 2: you can.
- 52:45Speaker 2: Or 3.13 or 3.14.
- 52:47Speaker 2: You know, with different performance
- 52:49Speaker 2: characteristics for sure, but you can
- 52:51Speaker 2: do that.
- 52:52Speaker 2: Or Austin or whatever
- 52:53Speaker 2: of the other ones, right?
- 52:55Speaker 2: But right now, this one
- 52:57Speaker 2: only works from 3.15 forward,
- 52:59Speaker 2: right?
- 52:59Speaker 2: And between the same version.
- 53:01Speaker 2: So that's an important
- 53:03Speaker 2: thing.
- 53:03Speaker 2: It's not a limitation for the
- 53:05Speaker 2: future.
- 53:05Speaker 2: It's possible that we can
- 53:07Speaker 2: allow 3.15 to analyze forward.
- 53:09Speaker 2: Sorry,
- 53:11Speaker 2: backward for 3.15,
- 53:12Speaker 2: so 3.16 can
- 53:13Speaker 2: 3.15 and 3.16 or
- 53:15Speaker 2: 3.17 can do 3.15, 3.16
- 53:17Speaker 2: and 3.17
- 53:19Speaker 2: but still we don't know. We don't know
- 53:21Speaker 2: if we want to get into that
- 53:24Speaker 2: but yeah, that's another advantage
- 53:26Speaker 2: but if you go to the
- 53:27Speaker 2: I don't know if you,
- 53:28Speaker 2: I can see that
- 53:29Pablo Galindo Salgado: Hold on really quick before we move on
- 53:31Pablo Galindo Salgado: what about this Python backport
- 53:33Pablo Galindo Salgado: stuff?
- 53:34Pablo Galindo Salgado: Are you familiar with this?
- 53:35Speaker 2: Python profiling?
- 53:36Pablo Galindo Salgado: Backporting the new profiling library
- 53:38Pablo Galindo Salgado: to,
- 53:39Pablo Galindo Salgado: I don't know what version goes
- 53:40Pablo Galindo Salgado: to 3.14.
- 53:41Speaker 2: Like a Clanker made version of this, like, or something like a version?
- 53:45Speaker 2: Let's see.
- 53:47Pablo Galindo Salgado: Yeah, possibly it was made over a one-week period.
- 53:50Pablo Galindo Salgado: So,
- 53:50Pablo Galindo Salgado: yeah, probably.
- 53:51Speaker 2: Yeah.
- 53:52Speaker 2: Well, I mean, it is possible because,
- 53:54Speaker 2: technically speaking,
- 53:55Speaker 2: you can,
- 53:58Speaker 2: like, you go up in this repo.
- 53:59Speaker 2: We are looking at the GitHub repo.
- 54:01Speaker 2: So, you go up in this page.
- 54:03Speaker 2: You can see that there's this underscore remote debugging.
- 54:05Speaker 2: So,
- 54:06Speaker 2: that is the C-Python folder,
- 54:08Speaker 2: right?
- 54:08Speaker 2: So probably what happened here is that they copy this code
- 54:11Speaker 2: and they strip all the new cool,
- 54:13Speaker 2: you know,
- 54:14Speaker 2: bells and whistles for 3.15.
- 54:16Speaker 2: And that still works very well for 3.14.
- 54:19Speaker 2: I don't know if it works for less.
- 54:21Speaker 2: So I will be interested.
- 54:22Speaker 2: Can you check the Python version,
- 54:23Speaker 2: perhaps,
- 54:23Speaker 2: in the set of py or something?
- 54:25Pablo Galindo Salgado: Yeah,
- 54:25Pablo Galindo Salgado: sure.
- 54:26Pablo Galindo Salgado: Py project.
- 54:27Pablo Galindo Salgado: Oh, they will set py.
- 54:28Pablo Galindo Salgado: Wow, how about that?
- 54:29Pablo Galindo Salgado: Okay.
- 54:30Speaker 2: Yeah, okay.
- 54:31Speaker 2: Well,
- 54:32Speaker 2: interesting.
- 54:32Speaker 2: Yeah, 3.14, you see?
- 54:34Speaker 2: So,
- 54:35Speaker 2: yeah, it supports 3.14 only because,
- 54:37Speaker 2: you know,
- 54:37Speaker 2: It's the 3.0 version minus the cool things.
- 54:39Speaker 2: So it's still using the debugging interface.
- 54:43Speaker 2: You can see the bag obsessed validation.h,
- 54:46Speaker 2: which is clearly the bag stuff.
- 54:49Speaker 2: So that is possible.
- 54:51Speaker 2: Unfortunately,
- 54:51Speaker 2: as you really well know,
- 54:52Speaker 2: we cannot backport features in CPython.
- 54:55Speaker 2: So this is good.
- 54:56Speaker 2: This is good.
- 54:57Speaker 2: I mean, I'm happy people are doing this.
- 54:59Pablo Galindo Salgado: So maybe it gives you a little bit of a lever of today and tomorrow.
- 55:02Speaker 2: Yeah, and this makes me happy,
- 55:06Speaker 2: right?
- 55:06Speaker 2: Like, look, man, if people are willing to like pull tricks to use our stuff in all versions,
- 55:12Speaker 2: like amazing.
- 55:13Speaker 2: You know what I mean?
- 55:13Speaker 2: Like that's success to me.
- 55:15Pablo Galindo Salgado: What's worse is they don't care and they don't pay any attention.
- 55:17Pablo Galindo Salgado: They just leave it, right?
- 55:19Speaker 2: Yeah, yeah.
- 55:19Speaker 2: Well, you know, who the bugs are going to go to?
- 55:22Speaker 2: Like that's an interesting question.
- 55:23Speaker 2: But like,
- 55:24Speaker 2: you know,
- 55:25Speaker 2: if you report a 3.14 bug in Cpython,
- 55:27Speaker 2: I may tell you, hey, man, what
- 55:28Speaker 2: are you doing?
- 55:29Speaker 2: But like,
- 55:30Speaker 2: you know,
- 55:31Speaker 2: if they are willing to bug for the bugs as well,
- 55:34Speaker 2: then let's go.
- 55:34Speaker 2: You know, like that's good to me.
- 55:36László Kiss Kollár: So I actually did this.
- 55:38László Kiss Kollár: So I tried doing this.
- 55:39László Kiss Kollár: This is not my project,
- 55:41László Kiss Kollár: of course, but I tried this because this seemed like a good idea.
- 55:45László Kiss Kollár: Hey, how can we make this work in 3.14?
- 55:47László Kiss Kollár: And that was the idea.
- 55:48László Kiss Kollár: You can just literally take the profiling package and just copy that over.
- 55:53László Kiss Kollár: But it's not that simple.
- 55:54László Kiss Kollár: So there are some changes in internal CPython structures in CLO.
- 56:03László Kiss Kollár: It's not a lot of changes, but you do get some changes there.
- 56:06László Kiss Kollár: You may be able to get away without those, but the patch is enormous.
- 56:10László Kiss Kollár: It's absolutely gigantic.
- 56:11László Kiss Kollár: I did not realize how much code there is in Tachyon until I was doing this.
- 56:16László Kiss Kollár: And that just means that every single patch version, every single change,
- 56:18László Kiss Kollár: you will have to maintain this.
- 56:20László Kiss Kollár: There may be significant maintenance.
- 56:22László Kiss Kollár: So the idea was rejected,
- 56:25László Kiss Kollár: sort of fact, to do this and maintain it as a separate package,
- 56:28László Kiss Kollár: at least for me.
- 56:29Pablo Galindo Salgado: I don't see this as a long-term,
- 56:31Pablo Galindo Salgado: this back thing as a long-term useful thing,
- 56:33Pablo Galindo Salgado: but maybe in the first year,
- 56:35Pablo Galindo Salgado: you know,
- 56:36Pablo Galindo Salgado: as people are searching for 3.15.
- 56:37Speaker 2: Of course, of course,
- 56:38Speaker 2: yeah.
- 56:39Pablo Galindo Salgado: And then in three years, you tell them,
- 56:40Pablo Galindo Salgado: like, what are you doing 3.14?
- 56:41Pablo Galindo Salgado: Get out of here.
- 56:42Speaker 2: But, but, but,
- 56:43Speaker 2: but,
- 56:44Speaker 2: ooh,
- 56:44Speaker 2: maybe we can talk about this later.
- 56:46Speaker 2: But like, one interesting thing,
- 56:48Speaker 2: well, actually, let me segue into it smoothly,
- 56:51Speaker 2: smoothly.
- 56:51Speaker 2: Let's do some smooth segue into it.
- 56:54Speaker 2: So one interesting thing that is also important to mention,
- 56:58Speaker 2: And I can see that you have the profiling.sampling documentation in the sidebar.
- 57:02Speaker 2: So let's open that for the people viewing this in YouTube or whatever.
- 57:06Speaker 2: So the documentation here is huge,
- 57:09Speaker 2: huge,
- 57:09Speaker 2: huge documentation.
- 57:10Speaker 2: Why is that?
- 57:11Speaker 2: Because this does a lot of things.
- 57:12Speaker 2: It does a lot of things, a lot of things, by the way, that only profiler can do.
- 57:16Speaker 2: So it's not just about being fast.
- 57:17Speaker 2: It does all sorts of other things.
- 57:20Speaker 2: So as opposed to like cprofile that like has like,
- 57:24Speaker 2: you know, the PSTAT format
- 57:25Speaker 2: and can tell you like basic,
- 57:27Speaker 2: you know, statistics about your program or whatever.
- 57:29Speaker 2: Like this thing is a full beast.
- 57:32Speaker 2: It comes with everything,
- 57:33Speaker 2: right?
- 57:33Speaker 2: So here Tachyon can create like, like flame graphs.
- 57:37Speaker 2: It can create all sorts of visualizations.
- 57:39Speaker 2: Like, so it has that top model.
- 57:41Speaker 2: So like, like when you do top and you see the processes life.
- 57:44Speaker 2: So Tachyon has this like, like Tachyon life.
- 57:47Speaker 2: Well, I can show you like the functions life of your application,
- 57:50Speaker 2: like almost like a top,
- 57:51Speaker 2: it can create like heat maps.
- 57:53Speaker 2: So you can see lines with different colors depending if they are more hot or cold, if they are more slow or fast.
- 58:01Speaker 2: You can do differential frame graphs, which is very cool.
- 58:05Speaker 2: You can run your program and then change a bit and run it again and then compare what became faster and slower.
- 58:13Speaker 2: So it can tell you what functions were faster and what functions got slower.
- 58:17Speaker 2: Another very cool thing that this does is that it does async audio,
- 58:20Speaker 2: which is the first
- 58:21Speaker 2: profiler right now that like can also do async audio because like, you know,
- 58:26Speaker 2: the even loop
- 58:26Speaker 2: does all sorts of weird things.
- 58:28Speaker 2: Right.
- 58:29Pablo Galindo Salgado: And it's often one thread,
- 58:31Pablo Galindo Salgado: basically kind of async call stack.
- 58:32Pablo Galindo Salgado: So it's like, what are you doing?
- 58:33Pablo Galindo Salgado: Like, well, we're dispatching.
- 58:35Pablo Galindo Salgado: Yeah,
- 58:35Pablo Galindo Salgado: exactly.
- 58:35Pablo Galindo Salgado: Exactly.
- 58:36Speaker 2: What is that?
- 58:36Speaker 2: What is that?
- 58:37Speaker 2: Exactly.
- 58:37Speaker 2: Yeah.
- 58:38Speaker 2: Or like, you know, it's like,
- 58:39Speaker 2: oh,
- 58:40Speaker 2: you know,
- 58:40Speaker 2: but it's also important because I think
- 58:42Speaker 2: I do changes a bit the, what means slow or fast.
- 58:45Speaker 2: Like, for example, imagine that you're downloading a 3GB file,
- 58:50Speaker 2: but the server is slow.
- 58:52Speaker 2: So you're spending a lot of time waiting for that 3GB file, not because you are crunching
- 58:57Speaker 2: your CPU,
- 58:58Speaker 2: it's because your server is slow.
- 58:59Speaker 2: But your application is slow because the server is slow.
- 59:02Speaker 2: So how do you know that that is happening?
- 59:04Speaker 2: Well, in the normal world, if that was the case, you would be like, I don't know, reading
- 59:09Speaker 2: or something.
- 59:10Speaker 2: Like, you will see that the profile will show you that you are reading, reading, reading,
- 59:13Speaker 2: so you can't imagine what's going on.
- 59:15Speaker 2: But in this case,
- 59:16Speaker 2: because the event loop will only be waking up when the server has something to tell you.
- 59:20Speaker 2: Meanwhile,
- 59:21Speaker 2: that will never appear.
- 59:22Speaker 2: So like if you can only see the coroutines that are running,
- 59:25Speaker 2: the fact that you are waiting for the server to send your data will never appear in your flame graph because it's not happening.
- 59:30Speaker 2: So you will never know that what is slow about your program is that your program is waiting for a three-hour file to appear,
- 59:37Speaker 2: right?
- 59:37Speaker 2: Yeah,
- 59:38Pablo Galindo Salgado: this is especially important for a sampling profiler,
- 59:41Pablo Galindo Salgado: right?
- 59:41Speaker 2: Exactly, exactly, because you are not tracing it.
- 59:43Speaker 2: Also tracing in the even loop is very weird because you keep changing for task to task, so it's very confusing.
- 59:49Speaker 2: But here in Taki has these two modes.
- 59:52Speaker 2: One of them is like tasks that are running.
- 59:55Speaker 2: So you can see only running tasks.
- 59:56Speaker 2: So in that case, for instance, if you're waiting for the 3D guy file, it will not appear.
- 1:00:00Speaker 2: But you can see that meanwhile you're doing other things.
- 1:00:02Speaker 2: But also it has this mode, which is all the tasks that I'm waiting for.
- 1:00:06Speaker 2: So every time you sample,
- 1:00:08Speaker 2: you see every single task that is going on.
- 1:00:10Speaker 2: So you can see that like,
- 1:00:12Speaker 2: oh,
- 1:00:12Speaker 2: I'm waiting for this 3G file.
- 1:00:14Speaker 2: It's just that it's not advancing.
- 1:00:15Speaker 2: So because it's not advancing, it will appear in more samples.
- 1:00:18Speaker 2: And then you will know that like that guy is like all the time being waiting for.
- 1:00:22Speaker 2: So like, you know that it's happening.
- 1:00:24Speaker 2: And then apart from that, it also has like dump mode when you can have like,
- 1:00:28Speaker 2: you know,
- 1:00:28Speaker 2: imagine that your application is frozen because you have a deadlock or perhaps,
- 1:00:32Speaker 2: you know,
- 1:00:32Speaker 2: you know, it's just waiting for IO that never arrives and you want to know where it's going.
- 1:00:37Speaker 2: so you can use profiling.sampling dump
- 1:00:41Speaker 2: and then you pass the PID of your application
- 1:00:43Speaker 2: and then it will show you what's going on.
- 1:00:46Speaker 2: It will show you the stack trace.
- 1:00:47Speaker 2: Imagine the stack trace,
- 1:00:48Speaker 2: like if an exception is thrown,
- 1:00:50Speaker 2: but instead of throwing an exception,
- 1:00:51Speaker 2: it will show you where it is.
- 1:00:53Speaker 2: And of course,
- 1:00:53Speaker 2: this works on everywhere.
- 1:00:55Speaker 2: So it works on macOS,
- 1:00:56Speaker 2: it works on Windows,
- 1:00:57Speaker 2: it works on Linux.
- 1:00:58Speaker 2: Same mechanism,
- 1:00:59Speaker 2: same guarantees,
- 1:01:00Speaker 2: same everything.
- 1:01:02Pablo Galindo Salgado: Okay, that's awesome.
- 1:01:03Pablo Galindo Salgado: Now,
- 1:01:03Pablo Galindo Salgado: you threw out a bunch of stuff there
- 1:01:05Pablo Galindo Salgado: And I think it's amazing how much is here,
- 1:01:07Pablo Galindo Salgado: but let's just go back really quick and just,
- 1:01:10Pablo Galindo Salgado: let's just focus on this.
- 1:01:11Pablo Galindo Salgado: I think this is,
- 1:01:12Pablo Galindo Salgado: this kind of game changing.
- 1:01:12Speaker 2: Yeah, there is so much.
- 1:01:13Speaker 2: There is, you need a second podcast,
- 1:01:15Speaker 2: man.
- 1:01:15Speaker 2: Like you need to invite us a second time.
- 1:01:17Pablo Galindo Salgado: What do we even do?
- 1:01:17Pablo Galindo Salgado: Like we got to just, we're going to go, we're going to go,
- 1:01:19Pablo Galindo Salgado: keep going.
- 1:01:20Pablo Galindo Salgado: So the attach,
- 1:01:22Pablo Galindo Salgado: this is,
- 1:01:22Pablo Galindo Salgado: there's something running in production.
- 1:01:24Pablo Galindo Salgado: Let me,
- 1:01:25Pablo Galindo Salgado: right now it's doing whatever it is that we're like,
- 1:01:27Pablo Galindo Salgado: uh,
- 1:01:28Pablo Galindo Salgado: what is this doing?
- 1:01:28Pablo Galindo Salgado: What's going on?
- 1:01:29Pablo Galindo Salgado: How do we fix this?
- 1:01:29Pablo Galindo Salgado: Or just what's going on?
- 1:01:30Pablo Galindo Salgado: you can attach to it,
- 1:01:32Pablo Galindo Salgado: grab a pstat file,
- 1:01:34Pablo Galindo Salgado: take that away and work on it, right?
- 1:01:36Pablo Galindo Salgado: Without,
- 1:01:36Pablo Galindo Salgado: I mean, it probably does affect the performance somehow,
- 1:01:40Speaker 2: but not nearly the same.
- 1:01:42Speaker 2: No, no, it's free.
- 1:01:43Speaker 2: It's free.
- 1:01:43Pablo Galindo Salgado: It's free.
- 1:01:44Pablo Galindo Salgado: Okay.
- 1:01:45Speaker 2: It's free.
- 1:01:45Speaker 2: The key way it's free is because,
- 1:01:47Speaker 2: well,
- 1:01:48Speaker 2: okay, sorry.
- 1:01:48Speaker 2: It's free by default.
- 1:01:49Speaker 2: There is something that you can do.
- 1:01:51Speaker 2: We can't go into detail in a second,
- 1:01:53Speaker 2: but there's something that you can do to kind of like have more exact data
- 1:01:58Speaker 2: that will slow it down a bit.
- 1:02:00Speaker 2: But still,
- 1:02:00Speaker 2: for most of the sampling rates,
- 1:02:02Speaker 2: it's mostly free.
- 1:02:03Speaker 2: So by default,
- 1:02:04Speaker 2: Acheon will never stop your application.
- 1:02:07Speaker 2: It will just always read what is going on.
- 1:02:09Speaker 2: Of course, the trade-off is that you can do partial reads.
- 1:02:12Speaker 2: So perhaps it's reading,
- 1:02:14Speaker 2: a structure that's changing, so it gets some weird stuff.
- 1:02:17Speaker 2: So Acheon,
- 1:02:18Speaker 2: most of the time, will detect that that is happening and it will throw away the sample.
- 1:02:21Speaker 2: So it will say, okay, this is a bad sample.
- 1:02:23Speaker 2: And it will not read it.
- 1:02:24Speaker 2: But of course, that means that you have less samples if that is happening a lot.
- 1:02:27Speaker 2: That can happen, for example, you have a lot of generators,
- 1:02:30Speaker 2: because generators tend to be a bit like,
- 1:02:32Speaker 2: you know, you get partial reads.
- 1:02:34Speaker 2: So sometimes it happens.
- 1:02:35Speaker 2: But by default,
- 1:02:36Speaker 2: it will only read from the application.
- 1:02:38Speaker 2: And the application,
- 1:02:38Speaker 2: first of all, the application doesn't know that this is happening.
- 1:02:41Speaker 2: And,
- 1:02:42Speaker 2: you know, unless you only have one CPU and then you are giving the CPU to both programs,
- 1:02:45Speaker 2: which in today's computers,
- 1:02:48Speaker 2: that will never happen.
- 1:02:49Speaker 2: I don't know, you're running a Docker container with only one CPU core or whatever.
- 1:02:53Speaker 2: but like,
- 1:02:53Speaker 2: you know, you run the profile in another,
- 1:02:55Speaker 2: you know, sidecar or whatever, like that would ever happen.
- 1:02:58Speaker 2: So unless that's the case,
- 1:02:59Speaker 2: like the application will never know and it will run at full speed.
- 1:03:02Speaker 2: If you want to avoid this kind of partial read situation and you want to show that every read is consistent
- 1:03:08Speaker 2: and increase the kind of like exactness and, you know,
- 1:03:12Speaker 2: trustworthiness of the data,
- 1:03:14Speaker 2: then there is this mode where you can pass does this blocking.
- 1:03:17Speaker 2: And what does this blocking will do is that before reading,
- 1:03:19Speaker 2: it will stop the application for a split millisecond,
- 1:03:22Speaker 2: very quickly,
- 1:03:23Speaker 2: it will do the read and it will restart it.
- 1:03:25Speaker 2: So,
- 1:03:26Speaker 2: of course, if you do the default sampling rate
- 1:03:28Speaker 2: or even sampling rates up to 10,000 Hz,
- 1:03:31Speaker 2: that is a very small amount of time.
- 1:03:33Speaker 2: We are talking about slowdowns of 1% to 2%.
- 1:03:36Speaker 2: So 1% to 2%, not two times.
- 1:03:38Speaker 2: It's 1% to 2%. It's nothing.
- 1:03:40Pablo Galindo Salgado: If you've done profiling before, it's much,
- 1:03:42Pablo Galindo Salgado: much lower.
- 1:03:43Pablo Galindo Salgado: It's like,
- 1:03:44Speaker 2: whatever,
- 1:03:44Speaker 2: man.
- 1:03:45Speaker 2: What are you talking about?
- 1:03:48Speaker 2: We would make Parthons 315 5% faster,
- 1:03:51Speaker 2: and then that's fine, right?
- 1:03:52Speaker 2: But like if you ramp the sample rate really high,
- 1:03:55Speaker 2: like let's say 100,000 samples per second,
- 1:03:59Speaker 2: then we are talking about like more, like 20% or 30% or 80%.
- 1:04:02Speaker 2: I think that you do it at crazy rates, like 1 million samples,
- 1:04:06Speaker 2: if your machine can do it,
- 1:04:07Speaker 2: because now it depends on your machine to be able to do that.
- 1:04:11Speaker 2: Then we are talking about two times lower or something like that.
- 1:04:14Speaker 2: But like you see, like you need to like go really, really crazy.
- 1:04:17Speaker 2: So in production, for example,
- 1:04:19Speaker 2: you can sample perfectly at 100 or 1000 hertz and have a slow
- 1:04:23Speaker 2: dance of one or two percent.
- 1:04:24Speaker 2: And it's fine. It's acceptable.
- 1:04:27Speaker 2: And this thing that we're talking
- 1:04:29Speaker 2: about,
- 1:04:29Speaker 2: this thing is so important.
- 1:04:31Speaker 2: You don't understand how important this is. Like I'm free
- 1:04:33Speaker 2: to say this is not a trade secret.
- 1:04:35Speaker 2: Like my employer used this thing all the fucking time
- 1:04:39Speaker 2: for making a lot of money.
- 1:04:40Speaker 2: So you cannot imagine how critical it is to understand why your programs
- 1:04:45Speaker 2: like are slow or how your programs can be optimized.
- 1:04:49Speaker 2: Because a lot of the time you just need to see live traffic.
- 1:04:52Speaker 2: Like if you have or like live data,
- 1:04:53Speaker 2: right?
- 1:04:54Speaker 2: If you never know how your application is really going to behave or what is slow
- 1:04:58Speaker 2: until you measure the real deal.
- 1:05:00Speaker 2: You cannot measure the fake deal.
- 1:05:02Speaker 2: Like you need to measure the real deal.
- 1:05:04Speaker 2: And for that, you need to attach because most of the times you don't have access to,
- 1:05:08Speaker 2: oh, I just want to launch my application on the lab profiler.
- 1:05:10Speaker 2: No, you need to like, you just have it there and it's doing something weird.
- 1:05:14Speaker 2: And then you attach and then you look a bit.
- 1:05:15Speaker 2: and then you detach,
- 1:05:16Speaker 2: right?
- 1:05:16Speaker 2: Even this,
- 1:05:17Speaker 2: let's say for example,
- 1:05:19Speaker 2: that blocking was 50% slowdown.
- 1:05:22Speaker 2: You could do it for like a bunch of seconds
- 1:05:23Speaker 2: and then detach and you know,
- 1:05:25Speaker 2: here is all good.
- 1:05:26Speaker 2: And then you got the information
- 1:05:27Speaker 2: and then you can reason about it.
- 1:05:29Speaker 2: And then you can manage - That
- 1:05:29Pablo Galindo Salgado: information is so good,
- 1:05:31Pablo Galindo Salgado: Pablo.
- 1:05:32Pablo Galindo Salgado: The in
- 1:05:32Pablo Galindo Salgado: -production information is so much different.
- 1:05:34Pablo Galindo Salgado: It's
- 1:05:34Speaker 2: key, it's key, it's key.
- 1:05:36Speaker 2: Like for this
- 1:05:38Speaker 2: year, I mean, this is kind of the segue
- 1:05:39Speaker 2: and the secret
- 1:05:40Speaker 2: and whatever,
- 1:05:40Speaker 2: but like one
- 1:05:41Speaker 2: of the things I've been working on here,
- 1:05:44Speaker 2: had solar training for like this past year is precisely all about getting,
- 1:05:49Speaker 2: well, not all about,
- 1:05:50Speaker 2: but like, like,
- 1:05:50Speaker 2: but a lot of my work here has been to ensure that getting that information and much
- 1:05:55Speaker 2: more from light data is what you do.
- 1:05:57Speaker 2: And we can go into why it's insane here. But like,
- 1:06:00Speaker 2: part of the
- 1:06:00Speaker 2: reason is because this information is gold,
- 1:06:04Speaker 2: like, it's just the best thing that you can do,
- 1:06:06Speaker 2: because
- 1:06:06Speaker 2: it's telling you literally what you need to change.
- 1:06:09Speaker 2: It's almost cheating.
- 1:06:10Speaker 2: You know what I mean?
- 1:06:14Speaker 2: You
- 1:06:14Speaker 2: bad change this thing and then you go and like literally today today right we activated a mega
- 1:06:21Speaker 2: version of this which is not tacky only something else but we activated a version of this at work
- 1:06:26Speaker 2: in one of the machines that the data scientists used to like the supercomputers that we have here
- 1:06:30Speaker 2: so here we have a lot of supercomputers and then like people do their their you know the experiments
- 1:06:35Speaker 2: or things with trading and you know that's like i don't know it's war like it's huge machines
- 1:06:41Speaker 2: like hundreds and hundreds of gigabytes of memory,
- 1:06:44Speaker 2: like hundreds of cores.
- 1:06:45Speaker 2: So it's like war, right?
- 1:06:47Speaker 2: And then for the first time,
- 1:06:48Speaker 2: because this is so ridiculously complicated
- 1:06:50Speaker 2: and these machines are so big that like it's so different to do this thing at scale,
- 1:06:54Speaker 2: we managed to have a version of this that is tracing all programs.
- 1:06:57Speaker 2: So not just one, all of them,
- 1:06:59Speaker 2: right?
- 1:06:59Speaker 2: And using this live data, literally today,
- 1:07:02Speaker 2: we saw one of these applications that was doing something slightly odd.
- 1:07:06Speaker 2: It's like,
- 1:07:06Speaker 2: why is this application taking like an entire core of the machine
- 1:07:10Speaker 2: when it should be doing nothing.
- 1:07:12Speaker 2: And I was like, hmm.
- 1:07:13Speaker 2: And we look at that and it turns out that in some specific case
- 1:07:17Speaker 2: that was happening a lot, but nobody thought that this was going to happen,
- 1:07:20Speaker 2: one of the algorithms was underperforming slightly
- 1:07:24Speaker 2: because it was accidentally quadratic in one way, right?
- 1:07:27Speaker 2: Which is like, again, it's very difficult to see.
- 1:07:28Speaker 2: If I show you the code, no person on the planet will see it.
- 1:07:31Speaker 2: It is so ridiculously complicated to see.
- 1:07:34Speaker 2: But we could see it as clear as day on the data.
- 1:07:36Speaker 2: It was so obvious,
- 1:07:37Speaker 2: so obvious,
- 1:07:38Speaker 2: so obvious.
- 1:07:39Speaker 2: And bam, we remove it and ba-da-boom,
- 1:07:41Speaker 2: we have a core on every single machine of our supercomputer free now.
- 1:07:45Speaker 2: That's awesome.
- 1:07:46Speaker 2: This is ridiculous.
- 1:07:47Speaker 2: You know how this is like a huge amount of money saved.
- 1:07:51Speaker 2: So getting this data is the best thing that you can do.
- 1:07:54Speaker 2: Listen, everyone listening to this,
- 1:07:55Speaker 2: just grab this thing,
- 1:07:56Speaker 2: put it to your application and your manager will be happy forever.
- 1:08:00Speaker 2: Like it's just the easiest way to make your manager happy.
- 1:08:03Speaker 2: Just go measure the shit and fix the thing and don't tell anyone the trick.
- 1:08:07Speaker 2: And they're like, damn,
- 1:08:08Speaker 2: you just fix it.
- 1:08:09Speaker 2: You can do it to other teams.
- 1:08:11Speaker 2: You're a performance wizard is what you've become.
- 1:08:13Speaker 2: Look at you.
- 1:08:14Speaker 2: Exactly, exactly.
- 1:08:14Speaker 2: Just attach it to other people's programs.
- 1:08:17Speaker 2: And then you see what's low.
- 1:08:18Speaker 2: And suddenly you have a change in their code.
- 1:08:20Speaker 2: And they say, wow,
- 1:08:21Speaker 2: how did you do?
- 1:08:22Speaker 2: And like,
- 1:08:23Speaker 2: damn.
- 1:08:24Pablo Galindo Salgado: Incredible.
- 1:08:25László Kiss Kollár: Just do it before everyone knows how to do it.
- 1:08:28László Kiss Kollár: What the secret is.
- 1:08:28Speaker 2: No, like you knew from this podcast.
- 1:08:31Speaker 2: You knew it because you're here.
- 1:08:32Pablo Galindo Salgado: Don't worry, I'll delete the episode really soon.
- 1:08:35Speaker 2: Oh, damn,
- 1:08:35Speaker 2: damn.
- 1:08:36Pablo Galindo Salgado: That way the secret will be safe.
- 1:08:38Pablo Galindo Salgado: No.
- 1:08:39Pablo Galindo Salgado: Yes.
- 1:08:41Pablo Galindo Salgado: And this is just part of Python.
- 1:08:42Pablo Galindo Salgado: It's just free stuff.
- 1:08:43Pablo Galindo Salgado: I mean, the stuff that you're doing,
- 1:08:44Pablo Galindo Salgado: the multi was obviously extending this,
- 1:08:47Pablo Galindo Salgado: but this just comes with Python 3.15,
- 1:08:49Pablo Galindo Salgado: right?
- 1:08:49Speaker 2: Yes, this comes with Python 3.15.
- 1:08:51Speaker 2: Sorry.
- 1:08:52László Kiss Kollár: I think it's really important to emphasize
- 1:08:55László Kiss Kollár: how, what a superpower this is,
- 1:08:57László Kiss Kollár: because I think in my experience,
- 1:08:59László Kiss Kollár: even if you have some tooling available
- 1:09:02László Kiss Kollár: for this sort of production profiling,
- 1:09:04László Kiss Kollár: it's not always the case that you have access
- 1:09:06László Kiss Kollár: that in the worst possible time
- 1:09:08László Kiss Kollár: when things are blowing up
- 1:09:10László Kiss Kollár: and you need something like that.
- 1:09:12László Kiss Kollár: It's the opposite.
- 1:09:13László Kiss Kollár: You don't have these tools ready
- 1:09:15László Kiss Kollár: when you realize that you need it, right?
- 1:09:17László Kiss Kollár: And what's amazing about this
- 1:09:17László Kiss Kollár: is that all you need
- 1:09:19László Kiss Kollár: is to have 3.15 installed
- 1:09:20László Kiss Kollár: and running in your application.
- 1:09:22László Kiss Kollár: And this opens up all sorts of possibilities.
- 1:09:24László Kiss Kollár: Like you can just go there
- 1:09:26László Kiss Kollár: and grab,
- 1:09:26László Kiss Kollár: you know,
- 1:09:27László Kiss Kollár: when things are happening,
- 1:09:29László Kiss Kollár: you can go there
- 1:09:30László Kiss Kollár: and sort of grab
- 1:09:31László Kiss Kollár: some sort of profile out of that.
- 1:09:33László Kiss Kollár: But I think it also opens up
- 1:09:34László Kiss Kollár: a lot of possibilities
- 1:09:35László Kiss Kollár: for the future.
- 1:09:37László Kiss Kollár: I mean, you can even implement
- 1:09:39László Kiss Kollár: continuous profiling with this thing
- 1:09:41László Kiss Kollár: if you wanted to,
- 1:09:42László Kiss Kollár: where you do this as a long-term thing
- 1:09:45László Kiss Kollár: on a lower sort of sampling frequency.
- 1:09:47László Kiss Kollár: But I think it's also important
- 1:09:48László Kiss Kollár: to emphasize here that
- 1:09:50László Kiss Kollár: Tachyon is not just a production profiler.
- 1:09:52László Kiss Kollár: So it has several modes
- 1:09:54László Kiss Kollár: where you attach to your process,
- 1:09:55László Kiss Kollár: to your live process,
- 1:09:56László Kiss Kollár: and that's super powerful
- 1:09:57László Kiss Kollár: and that's useful in many cases.
- 1:09:59László Kiss Kollár: But you can also load up
- 1:10:00László Kiss Kollár: your sort of application.
- 1:10:02László Kiss Kollár: It has a mode where
- 1:10:03László Kiss Kollár: you can just load up an application
- 1:10:04László Kiss Kollár: and then you start profiling as the program starts
- 1:10:08László Kiss Kollár: and it finishes at some duration
- 1:10:11László Kiss Kollár: and then you look at that data.
- 1:10:12László Kiss Kollár: So this is also very useful potentially
- 1:10:15László Kiss Kollár: in your development environment.
- 1:10:16László Kiss Kollár: Different reporters which are designed
- 1:10:19László Kiss Kollár: for development sort of processes,
- 1:10:21László Kiss Kollár: for example,
- 1:10:22László Kiss Kollár: you're looking for,
- 1:10:23László Kiss Kollár: you want to compare two different profiling snapshots.
- 1:10:27László Kiss Kollár: You know, like you make code changes
- 1:10:28László Kiss Kollár: and you want to compare how well those changes are,
- 1:10:32László Kiss Kollár: how much faster, how much slower
- 1:10:34László Kiss Kollár: are making your application.
- 1:10:35László Kiss Kollár: So I definitely wouldn't sort of
- 1:10:37László Kiss Kollár: lock it back in and like, you use this
- 1:10:39László Kiss Kollár: when you have performance issues in production.
- 1:10:42László Kiss Kollár: You can use it
- 1:10:43László Kiss Kollár: absolutely for any sort of
- 1:10:45László Kiss Kollár: profiling situation.
- 1:10:46Pablo Galindo Salgado: Yeah,
- 1:10:47Pablo Galindo Salgado: like a CLI sort of situation like you're talking about, maybe.
- 1:10:49László Kiss Kollár: Exactly.
- 1:10:50László Kiss Kollár: So you can use it
- 1:10:52László Kiss Kollár: actually
- 1:10:53László Kiss Kollár: we have the run here on the
- 1:10:55László Kiss Kollár: screen. So you can run a script or you can import
- 1:10:57László Kiss Kollár: a module with it and then you basically go from there.
- 1:10:59László Kiss Kollár: And there you can have, that can be
- 1:11:01László Kiss Kollár: your test suite or it can be a sample
- 1:11:03László Kiss Kollár: thing or it can be a CLI which you're looking at sort of improving the performance.
- 1:11:08Speaker 2: By the way,
- 1:11:08Speaker 2: since you were talking about quantum mechanics before.
- 1:11:11Pablo Galindo Salgado: We're on the string theory now.
- 1:11:12Pablo Galindo Salgado: No, just kidding.
- 1:11:13Pablo Galindo Salgado: Go ahead.
- 1:11:13Speaker 2: Yeah.
- 1:11:14Speaker 2: No, no.
- 1:11:14Speaker 2: Well, well,
- 1:11:14Speaker 2: well, well, well, well, well, well.
- 1:11:16Speaker 2: We're in relativity now.
- 1:11:17Speaker 2: Do you know why it's called tachyon?
- 1:11:19Pablo Galindo Salgado: I was wondering, but I haven't asked yet.
- 1:11:20Pablo Galindo Salgado: No, why?
- 1:11:21Pablo Galindo Salgado: I don't know.
- 1:11:22Speaker 2: So a tachyon is the name of hypothetical particles that go faster than light.
- 1:11:27Speaker 2: So like a photon is a particle that goes at the speed of light because,
- 1:11:31Speaker 2: you know, it's
- 1:11:31Speaker 2: the particles that made up light.
- 1:11:33Speaker 2: So,
- 1:11:33Speaker 2: you know, that's a photon.
- 1:11:35Speaker 2: And, you know, special relativity doesn't say that this is not possible.
- 1:11:39Speaker 2: It just says,
- 1:11:40Speaker 2: like, if you're a photon, you cannot go faster than the speed of light or slower than the speed of light because you are light.
- 1:11:45Speaker 2: And if you are,
- 1:11:45Speaker 2: you know, you have mass,
- 1:11:47Speaker 2: like a normal thing, you cannot go faster than the speed of light or at the speed of light.
- 1:11:51Speaker 2: So the speed of light is like a limit, but you can also don't achieve it.
- 1:11:54Speaker 2: But then special relativity also says, well, you could also be faster than the speed of light.
- 1:11:59Speaker 2: And what happens if that is true,
- 1:12:01Speaker 2: you cannot go at or lower than the speed of light.
- 1:12:03Speaker 2: And of course, we have not seen such a thing.
- 1:12:05Speaker 2: So that is very likely not true because among other things,
- 1:12:09Speaker 2: tachyons will travel back in time,
- 1:12:11Speaker 2: which is like perhaps a bit crazy.
- 1:12:12Speaker 2: But in theory,
- 1:12:14Speaker 2: you know, we have to talk about those possibilities and to investigate them.
- 1:12:18Speaker 2: So we have to name them.
- 1:12:19Speaker 2: And then the name for those particles is called tachyons,
- 1:12:23Speaker 2: which is tachy, which is fast in Greek.
- 1:12:25Speaker 2: So that's where it comes from.
- 1:12:28Pablo Galindo Salgado: That's awesome. And it has its own logo as well.
- 1:12:31Speaker 2: Oh yeah,
- 1:12:31Speaker 2: Mike Jimenez did that.
- 1:12:33Speaker 2: So Mike has been the person who has done some of the logos for the releases.
- 1:12:37Speaker 2: So she did the 310 and 311.
- 1:12:40Speaker 2: She's an ML researcher at World DeepMind.
- 1:12:44Speaker 2: And she's also a very good artist.
- 1:12:47Speaker 2: And she does a bunch of these logos.
- 1:12:49Speaker 2: So she created the Tachyon logo.
- 1:12:50Pablo Galindo Salgado: Very cool.
- 1:12:51Pablo Galindo Salgado: I do want to say one more thing about the attach.
- 1:12:54Pablo Galindo Salgado: Something that has always bothered me about profiling.
- 1:12:56Pablo Galindo Salgado: and I've sort of solved it by writing code,
- 1:12:59Pablo Galindo Salgado: like disable the profile or it start
- 1:13:01Pablo Galindo Salgado: and then enable it for certain things I'm interested in.
- 1:13:04Pablo Galindo Salgado: But there's just so much overhead about the startup
- 1:13:07Pablo Galindo Salgado: of your app that's just noise,
- 1:13:09Pablo Galindo Salgado: right?
- 1:13:09Pablo Galindo Salgado: Like all the imports,
- 1:13:11Pablo Galindo Salgado: all the other,
- 1:13:12Pablo Galindo Salgado: you're like, I don't care about that.
- 1:13:13Pablo Galindo Salgado: I just want to know once it's up and running,
- 1:13:15Pablo Galindo Salgado: what does this take?
- 1:13:16Pablo Galindo Salgado: You know what I mean?
- 1:13:17Pablo Galindo Salgado: And for an app that's sort of up and running for a while,
- 1:13:20Pablo Galindo Salgado: just attach to it,
- 1:13:22Pablo Galindo Salgado: do the couple of things you're going to do
- 1:13:23Pablo Galindo Salgado: that invoke that and then detach,
- 1:13:25Pablo Galindo Salgado: gets a really focused view, I would imagine.
- 1:13:27Speaker 2: Right. Yes,
- 1:13:28Speaker 2: absolutely.
- 1:13:29Pablo Galindo Salgado: So getting a little bit short on time,
- 1:13:32Pablo Galindo Salgado: but one more thing I want to ask you about,
- 1:13:34Pablo Galindo Salgado: because there's this profiling mode,
- 1:13:35Pablo Galindo Salgado: which I don't fully understand.
- 1:13:37Pablo Galindo Salgado: I know you guys can tell me we have wall clock mode,
- 1:13:39Pablo Galindo Salgado: CPU mode, we have GIL mode,
- 1:13:42Pablo Galindo Salgado: and we have exception mode.
- 1:13:43Pablo Galindo Salgado: They all sound useful.
- 1:13:44Pablo Galindo Salgado: But what are these?
- 1:13:45Pablo Galindo Salgado: What are these?
- 1:13:46Speaker 2: Yeah,
- 1:13:46Speaker 2: yeah, yeah.
- 1:13:47Speaker 2: So,
- 1:13:48Speaker 2: you know,
- 1:13:48Speaker 2: okay,
- 1:13:49Speaker 2: interesting.
- 1:13:50Speaker 2: So the idea here is that,
- 1:13:52Speaker 2: you know,
- 1:13:53Speaker 2: the profiler will look at your application
- 1:13:55Speaker 2: time to time, I will say like, okay, what's going on?
- 1:13:58Speaker 2: And it will basically take notes of what
- 1:14:00Speaker 2: application is doing,
- 1:14:01Speaker 2: right? So that's the basics.
- 1:14:03Speaker 2: Okay, so these modes are basically filters or the
- 1:14:06Speaker 2: samples.
- 1:14:06Speaker 2: The reason is the following.
- 1:14:07Speaker 2: Imagine that this is very common. Okay, I will tell you an
- 1:14:10Speaker 2: actual case that happened here, right?
- 1:14:12Speaker 2: So let's say you have two threads.
- 1:14:15Speaker 2: Let's say one of those
- 1:14:16Speaker 2: threads is waiting for the network.
- 1:14:18Speaker 2: So it's blocking on select or listen or whatever,
- 1:14:20Speaker 2: right?
- 1:14:21Speaker 2: And then the other thread is doing,
- 1:14:24Speaker 2: I don't know,
- 1:14:24Speaker 2: calculations or whatever it is,
- 1:14:26Speaker 2: right?
- 1:14:26Speaker 2: And then you profile those threads.
- 1:14:28Speaker 2: And then if you can look individually at every thread, but if you look at the whole thing
- 1:14:32Speaker 2: together, it will tell you, okay, half of the time you're spending listening on the
- 1:14:35Speaker 2: network and half of the time you're calculating pi, right?
- 1:14:38Speaker 2: So in this case,
- 1:14:40Speaker 2: the network is noise.
- 1:14:41Speaker 2: I don't care about that because I cannot improve the network.
- 1:14:44Speaker 2: You know what I mean?
- 1:14:45Speaker 2: I cannot just make it fast.
- 1:14:46Speaker 2: Or let's say I'm sleeping.
- 1:14:47Speaker 2: I call sleep, sleep five.
- 1:14:49Speaker 2: then the provider will correctly tell you,
- 1:14:51Speaker 2: you are waiting five seconds on Sleep 5.
- 1:14:53Speaker 2: But like, okay, but that's not very useful.
- 1:14:55Speaker 2: You know what I mean?
- 1:14:56Speaker 2: Like that, I cannot fix that,
- 1:14:57Speaker 2: right?
- 1:14:57Speaker 2: As part of the,
- 1:14:58Speaker 2: and that can be written in a file
- 1:15:00Speaker 2: or like,
- 1:15:00Speaker 2: you know, IO in general.
- 1:15:02Speaker 2: So, but that is through the steel,
- 1:15:04Speaker 2: right?
- 1:15:04Speaker 2: Because if you wait five seconds,
- 1:15:05Speaker 2: your program will take five seconds.
- 1:15:06Speaker 2: So if you want to know why is my program
- 1:15:08Speaker 2: waiting five seconds,
- 1:15:10Speaker 2: it's because it's sleeping for five seconds.
- 1:15:11Speaker 2: So that's the correct answer.
- 1:15:12Speaker 2: It's sometimes it's a good answer, sometimes it's not.
- 1:15:14Speaker 2: So by default, it will tell you that's called wall clock.
- 1:15:18Speaker 2: It's called wall clock because if you look at a clock in the wall, it will tell you that your application took five seconds,
- 1:15:23Speaker 2: right?
- 1:15:23Speaker 2: Even if it wasn't sleeping.
- 1:15:25Speaker 2: But of course,
- 1:15:25Speaker 2: sometimes we don't want to look at that.
- 1:15:27Speaker 2: We want to know when my application is doing something,
- 1:15:31Speaker 2: you know, because here it's just waiting,
- 1:15:32Speaker 2: right?
- 1:15:32Speaker 2: Waiting for data,
- 1:15:34Speaker 2: waiting to read disk.
- 1:15:36Speaker 2: Maybe your disk is slow.
- 1:15:38Speaker 2: Maybe the network's slow.
- 1:15:39Speaker 2: Maybe you're sleeping.
- 1:15:40Speaker 2: So you want to know when your application is doing something.
- 1:15:43Speaker 2: That is called CPU time.
- 1:15:44Speaker 2: So it's not time that you will measure.
- 1:15:46Speaker 2: like how much time is actually your application running in the CPU.
- 1:15:50Speaker 2: So when you run it in mode CPU,
- 1:15:52Speaker 2: you are filtering all those things that your application is waiting.
- 1:15:55Speaker 2: So you're filtering all the samples when you're sleeping or waiting for network.
- 1:16:00Speaker 2: And then you only get the samples when your application is doing something,
- 1:16:04Speaker 2: which are the ones that you can actually improve,
- 1:16:06Speaker 2: right?
- 1:16:06Speaker 2: Because like now I can look at a better algorithm or I can look at better module
- 1:16:10Speaker 2: or,
- 1:16:11Speaker 2: you know,
- 1:16:11Speaker 2: I'm parsing JSON.
- 1:16:12Speaker 2: So,
- 1:16:13Speaker 2: you know,
- 1:16:13Speaker 2: that both are interesting because for instance,
- 1:16:16Speaker 2: let's say you're parsing JSON,
- 1:16:17Speaker 2: you need to read the JSON.
- 1:16:18Speaker 2: And for that, you need to wait for your drive
- 1:16:20Speaker 2: or the network to give you the JSON.
- 1:16:22Speaker 2: That might be interesting to know
- 1:16:23Speaker 2: that 30% of the whole time is you waiting
- 1:16:26Speaker 2: for the JSON to be given to you.
- 1:16:28Speaker 2: So that is all useful information.
- 1:16:30Speaker 2: Now,
- 1:16:31Speaker 2: once you know that, you cannot improve that
- 1:16:33Speaker 2: because that is, you know,
- 1:16:34Speaker 2: you tear or the file system,
- 1:16:36Speaker 2: but you can know that you're parsing JSON and that's slow.
- 1:16:39Speaker 2: So you can say, okay, I can use a better JSON parser, right?
- 1:16:41Pablo Galindo Salgado: Right, or JSON or RISM rather than built in JSON
- 1:16:45Pablo Galindo Salgado: and see how that works.
- 1:16:45Pablo Galindo Salgado: Yeah.
- 1:16:46Speaker 2: Exactly, exactly.
- 1:16:47Speaker 2: So that is wall and CPU.
- 1:16:48Speaker 2: And then we have like the most exotic ones,
- 1:16:50Speaker 2: which is like GIL mode.
- 1:16:52Speaker 2: So GIL mode tells you how much time
- 1:16:54Speaker 2: are you spending on the GIL.
- 1:16:56Speaker 2: And this is a bit of a different,
- 1:16:58Speaker 2: is a bit of the same idea.
- 1:17:00Speaker 2: The idea here is that if you have,
- 1:17:03Speaker 2: for instance,
- 1:17:03Speaker 2: some program that is spending time
- 1:17:05Speaker 2: without the gill, like for example,
- 1:17:07Speaker 2: NumPy,
- 1:17:07Speaker 2: right?
- 1:17:08Speaker 2: You cannot optimize NumPy because that's a SQL,
- 1:17:11Speaker 2: right?
- 1:17:11Speaker 2: Like you cannot even see what's going on there normally.
- 1:17:13Speaker 2: Spoilers in a second.
- 1:17:14Speaker 2: But like you cannot see inside that because no Python code.
- 1:17:18Speaker 2: So what happens is that because you, you,
- 1:17:20Speaker 2: you,
- 1:17:21Speaker 2: that thing is running without the
- 1:17:22Speaker 2: guild, you don't have access to it.
- 1:17:23Speaker 2: So by default,
- 1:17:24Speaker 2: it will tell you who is calling that code and it will associate
- 1:17:27Speaker 2: all the time that you're spending in NumPy to a caller.
- 1:17:29Speaker 2: Right?
- 1:17:30Speaker 2: So let's say the function calling NumPy is called call NumPy.
- 1:17:33Speaker 2: So it will tell you that call NumPy is 10 seconds.
- 1:17:36Speaker 2: Right.
- 1:17:36Speaker 2: But let's say that for 10 of those, for nine of those seconds,
- 1:17:40Speaker 2: the guild is not
- 1:17:41Speaker 2: held,
- 1:17:41Speaker 2: of course that is on CPU, so it's doing actual work.
- 1:17:44Speaker 2: But because the GIL is not held, some other thread could do something,
- 1:17:47Speaker 2: right?
- 1:17:47Speaker 2: So you may have a situation where you have many threads and then you want to know who
- 1:17:52Speaker 2: is holding the GIL to know what is preventing other threads to run.
- 1:17:57Speaker 2: Because if you filter all the samples by only the samples that happen with the gill,
- 1:18:02Speaker 2: you
- 1:18:02Speaker 2: know that that thing, as long as it's running,
- 1:18:04Speaker 2: nothing else is running,
- 1:18:06Speaker 2: right?
- 1:18:06Speaker 2: So that's interesting.
- 1:18:08Speaker 2: So that's another way to cut.
- 1:18:09Speaker 2: You may say, well,
- 1:18:10Speaker 2: that sounds very complicated.
- 1:18:11Speaker 2: Well, it's more complicated than CPU or wall.
- 1:18:13Speaker 2: is harder to understand.
- 1:18:15Speaker 2: But if you are, you know, already very deep into the weeds
- 1:18:18Speaker 2: and like you are very advanced,
- 1:18:20Speaker 2: and this is a bit of,
- 1:18:21Speaker 2: I want to say this very explicitly,
- 1:18:23Speaker 2: like something that we try to do with Tachyon
- 1:18:25Speaker 2: is that it tries to be useful
- 1:18:28Speaker 2: to a very big range of developers.
- 1:18:31Speaker 2: Tachyon,
- 1:18:31Speaker 2: if you just want a quick answer,
- 1:18:33Speaker 2: you just want to know what is going on,
- 1:18:35Speaker 2: just tell me what is wrong.
- 1:18:36Speaker 2: Like it will give you that.
- 1:18:37Speaker 2: You don't need to know flame graphs.
- 1:18:38Speaker 2: You don't need to know,
- 1:18:40Speaker 2: like to read this thing.
- 1:18:41Speaker 2: It will tell you like, bam, bam, bam.
- 1:18:42Speaker 2: These are the five functions that are slower.
- 1:18:44Speaker 2: Bam.
- 1:18:44Speaker 2: And then you go and look,
- 1:18:45Speaker 2: right?
- 1:18:45Speaker 2: If you are a bit more advanced, you can start asking for frame graphs or heat maps or,
- 1:18:50Speaker 2: you
- 1:18:50Speaker 2: know,
- 1:18:50Speaker 2: read a bit of these things.
- 1:18:52Speaker 2: And if you're really an expert,
- 1:18:54Speaker 2: there is like extremely complicated things that you can ask
- 1:18:56Speaker 2: this profiler.
- 1:18:57Speaker 2: Like, for instance,
- 1:18:58Speaker 2: the exception mode is the same thing, but it's asking the question,
- 1:19:01Speaker 2: how much time I spend handling exceptions?
- 1:19:03Speaker 2: So like errors,
- 1:19:04Speaker 2: how much error handling is costing me?
- 1:19:06Speaker 2: Of course, you will say, well,
- 1:19:07Speaker 2: that probably is nothing.
- 1:19:09Speaker 2: But,
- 1:19:09Speaker 2: you know,
- 1:19:09Speaker 2: if you are already like...
- 1:19:10Pablo Galindo Salgado: It can be a lot.
- 1:19:11Speaker 2: Yeah,
- 1:19:11Speaker 2: exactly.
- 1:19:11Speaker 2: You don't know if you are fine tuning.
- 1:19:13Speaker 2: And also exceptions are used for much more than exceptions.
- 1:19:16Speaker 2: For instance,
- 1:19:17Speaker 2: as you very well know,
- 1:19:18Speaker 2: the iterator protocol raises,
- 1:19:20Speaker 2: you know, a stop iteration
- 1:19:22Speaker 2: as exception control.
- 1:19:23Speaker 2: So that can be,
- 1:19:24Speaker 2: you know.
- 1:19:24Speaker 2: And then there is also opcode mode where you can look at individual opcodes.
- 1:19:28Speaker 2: So there is very complicated questions that you can ask your program.
- 1:19:32Speaker 2: And in particular,
- 1:19:33Speaker 2: CPU wall exception and GIL are filters over the samples such that you
- 1:19:39Speaker 2: can like know what is your application exactly doing and what is not doing.
- 1:19:43Pablo Galindo Salgado: Yeah.
- 1:19:43Pablo Galindo Salgado: Very interesting.
- 1:19:44Pablo Galindo Salgado: I mean, it's super simple example of exceptions costing is I'm parsing a CRV,
- 1:19:48Pablo Galindo Salgado: a CSV,
- 1:19:49Pablo Galindo Salgado: and it's
- 1:19:49Pablo Galindo Salgado: coming in as text.
- 1:19:51Pablo Galindo Salgado: And I think it's a number.
- 1:19:51Pablo Galindo Salgado: So we do try this thing.
- 1:19:54Pablo Galindo Salgado: Excellent.
- 1:19:55Pablo Galindo Salgado: Well, I guess it's,
- 1:19:56Pablo Galindo Salgado: you know, set it to none, right?
- 1:19:58Pablo Galindo Salgado: You could regex check that or some, you could do something else instead of an exception in
- 1:20:02Pablo Galindo Salgado: a tight loop.
- 1:20:03Pablo Galindo Salgado: Exactly.
- 1:20:03Pablo Galindo Salgado: You get a big bonus.
- 1:20:04Speaker 2: Absolutely.
- 1:20:05Speaker 2: Absolutely.
- 1:20:06Speaker 2: That's exactly it.
- 1:20:06Speaker 2: Right.
- 1:20:07Speaker 2: And there's some modes when you don't filter by it, like there's a secret mode that only runs when you use one of the outputs,
- 1:20:13Speaker 2: which is Gecko.
- 1:20:15Speaker 2: So we don't advertise the mode because it only makes sense to this mode,
- 1:20:18Speaker 2: to this format,
- 1:20:19Speaker 2: which is Gecko.
- 1:20:20Speaker 2: But it's called All.
- 1:20:22Speaker 2: And what All does is that it records all the samples,
- 1:20:25Speaker 2: but it kind of like colors the sample with what was going on there.
- 1:20:29Speaker 2: So if the sample is on CPU, it says CPU.
- 1:20:31Speaker 2: If it's not.
- 1:20:32Speaker 2: So in that way, you can see kind of like a bunch of lanes of what every thread was doing.
- 1:20:37Speaker 2: So for example, if you have two threads and the threads are both calculating CPU,
- 1:20:41Speaker 2: they will fight for the guild.
- 1:20:43Speaker 2: So they will kind of move the guild back and forward.
- 1:20:45Speaker 2: And then you can see in the timeline what thread has the guild and for how much.
- 1:20:49Speaker 2: So that you can see, oh,
- 1:20:50Speaker 2: you know,
- 1:20:51Speaker 2: this thread ran for like 20 milliseconds.
- 1:20:53Speaker 2: And then this other thread ran for like 10 milliseconds.
- 1:20:54Speaker 2: And you can see how it's been bounced.
- 1:20:57Speaker 2: So you can like calculate maximum throughput and things like that.
- 1:21:01Pablo Galindo Salgado: Yeah, that contention is a big challenge of multi-threading.
- 1:21:04Pablo Galindo Salgado: Exactly.
- 1:21:04Pablo Galindo Salgado: You said that stuff doesn't scale linearly,
- 1:21:06Pablo Galindo Salgado: like 10 threads don't give you 10x performance,
- 1:21:08Pablo Galindo Salgado: and that's a good reason right there.
- 1:21:10Speaker 2: Exactly,
- 1:21:10Speaker 2: and this can give you a more or less good answer for that,
- 1:21:13Speaker 2: perhaps not perfect,
- 1:21:14Speaker 2: but...
- 1:21:14Pablo Galindo Salgado: You guys, there is so much here.
- 1:21:16Pablo Galindo Salgado: There is so much here.
- 1:21:17Pablo Galindo Salgado: But we're also so much out of time, I think.
- 1:21:19Pablo Galindo Salgado: I mean, people should check this out.
- 1:21:21Pablo Galindo Salgado: There's really a lot that you can...
- 1:21:23Pablo Galindo Salgado: I'm super impressed with this,
- 1:21:24Pablo Galindo Salgado: Pablo and Laszlo.
- 1:21:25Speaker 2: Well, thank you.
- 1:21:26Speaker 2: Thank you very much.
- 1:21:27László Kiss Kollár: Thank you.
- 1:21:28László Kiss Kollár: There was a really good presentation on PyCon this year,
- 1:21:32László Kiss Kollár: which has a little bit more info.
- 1:21:34László Kiss Kollár: I also remember because you mentioned how much there is here.
- 1:21:36László Kiss Kollár: And I remember working on the slide and I was just panicking how we're going to get all this information into this half an hour talk.
- 1:21:43Pablo Galindo Salgado: What's our talk?
- 1:21:44Pablo Galindo Salgado: 30 minutes?
- 1:21:45Pablo Galindo Salgado: Oh, uh-oh.
- 1:21:46Speaker 2: No, no,
- 1:21:47Speaker 2: it's impossible.
- 1:21:49Speaker 2: Yeah,
- 1:21:50László Kiss Kollár: that presentation.
- 1:21:51László Kiss Kollár: But I also recommend that for anyone who's interested.
- 1:21:55László Kiss Kollár: I think that has a pretty good overview.
- 1:21:57Pablo Galindo Salgado: Yeah,
- 1:21:58Pablo Galindo Salgado: I'll definitely link to your talk on YouTube.
- 1:22:00Speaker 2: There is only one thing I want to add before we go,
- 1:22:03Speaker 2: which I think is interesting and it's also a bit, you know, selfish,
- 1:22:07Speaker 2: which is that, so Tachyon is really good.
- 1:22:10Speaker 2: The only interesting challenge of Tachyon is that,
- 1:22:14Speaker 2: you know, if your application spends a bunch of time in C code,
- 1:22:18Speaker 2: like NumPy or, you know, Pandas or Polars or like nowadays,
- 1:22:21Speaker 2: like all the machine learning stuff like CUDA or whatever it is.
- 1:22:25Speaker 2: Unfortunately,
- 1:22:26Speaker 2: again,
- 1:22:26Speaker 2: like Tachyon is a Python profiler.
- 1:22:28Speaker 2: So it only sees Python, right?
- 1:22:30Speaker 2: It is who calls that C code, but not the C code.
- 1:22:32Speaker 2: And of course, you can say as a user, you are not super interested in what is happening on the guts of NumPy.
- 1:22:39Speaker 2: But sometimes you are, right?
- 1:22:40Speaker 2: Because what is going on or why my application is low, sometimes you need to just go there.
- 1:22:45Speaker 2: That's the unfortunate life we live in.
- 1:22:47Speaker 2: And Tachyon cannot analyze C code because it's a Python profiler.
- 1:22:51Speaker 2: It's not a C profiler.
- 1:22:52Speaker 2: On the other side, a C profiler cannot analyze Python.
- 1:22:55Speaker 2: So you can only see C code.
- 1:22:58Speaker 2: So you will see the internals of CPython,
- 1:23:00Speaker 2: but it will not have Python names.
- 1:23:01Speaker 2: It will not tell you full bar batch.
- 1:23:03Speaker 2: It will tell you by valuable frame default,
- 1:23:05Speaker 2: and that's not useful.
- 1:23:06Speaker 2: So that is one big challenge.
- 1:23:08Speaker 2: And the other is that the moment you want to go into the world of C profilers,
- 1:23:12Speaker 2: complexity explodes.
- 1:23:14Speaker 2: It's just like, if this is hard, which is hard,
- 1:23:17Speaker 2: when you want to do C profiles,
- 1:23:19Speaker 2: it's like 10 times harder.
- 1:23:20Speaker 2: And then when you want to do both at the same time,
- 1:23:23Speaker 2: it's a million times harder.
- 1:23:24Speaker 2: So unfortunately,
- 1:23:25Speaker 2: we didn't want to add that complexity to the standard library because,
- 1:23:29Speaker 2: you know, it's a lot of complexity for core developers to maintain.
- 1:23:32Speaker 2: And it's also really,
- 1:23:33Speaker 2: really,
- 1:23:34Speaker 2: really hard.
- 1:23:35Speaker 2: It's extremely hard and it requires a lot of care and,
- 1:23:38Speaker 2: you know, bugs will happen.
- 1:23:40Speaker 2: So we didn't want to like put.
- 1:23:41Speaker 2: So one of the things I've been working on here at Hudson River Trading is a version of
- 1:23:45Speaker 2: Tachyon is like the big brother of Tachyon,
- 1:23:47Speaker 2: which is called Cronon,
- 1:23:48Speaker 2: which is also physics
- 1:23:49Speaker 2: related because like the in quantum mechanics if you quantize time the particle of time is called
- 1:23:55Speaker 2: a chronon so you know because it's time because it's processed so we call it chron and this is a
- 1:24:00Speaker 2: profiler we have been using for nine months already here for with extreme success extreme success like
- 1:24:06Speaker 2: the whole company is using it all the time and this profiler does everything that tackian does
- 1:24:11Speaker 2: but it's also multiple versions of python so you can profile 312 313 314 315 all that you want and
- 1:24:18Speaker 2: also profile C code and kernel code.
- 1:24:20Speaker 2: So you can see literally everything.
- 1:24:22Speaker 2: Like you can see something
- 1:24:23Speaker 2: like,
- 1:24:24Speaker 2: oh, your application is calling,
- 1:24:26Speaker 2: I don't know, calculating Python and that goes into NumPy
- 1:24:29Speaker 2: and that's creating a bunch of arrays.
- 1:24:30Speaker 2: But one of those arrays just trigger a page fall in the kernel
- 1:24:33Speaker 2: and then the kernel is like trying to find memory for you. So you can see how much that takes.
- 1:24:38Speaker 2: And it supports the streaming.
- 1:24:39Speaker 2: So you can have like Grafana dashboard with all the profile and
- 1:24:43Speaker 2: The Flame Graph is changing as your application is running,
- 1:24:46Speaker 2: so you don't need to even wait for it.
- 1:24:49Speaker 2: You don't need to attach even.
- 1:24:50Speaker 2: You can just keep it 24-7 and see the data as it comes in.
- 1:24:54Speaker 2: It supports all sorts of formats,
- 1:24:56Speaker 2: all sorts of tools.
- 1:24:58Speaker 2: It works on macOS as well and Linux.
- 1:25:02Speaker 2: So we are going to make it open source soon in a month or two.
- 1:25:06Speaker 2: Yes, and that's going to be a big deal, big deal.
- 1:25:09Pablo Galindo Salgado: Cool.
- 1:25:09Speaker 2: Secret sauce.
- 1:25:10Pablo Galindo Salgado: Yeah, that sounds amazing.
- 1:25:12Pablo Galindo Salgado: I mean,
- 1:25:12Pablo Galindo Salgado: already,
- 1:25:12Pablo Galindo Salgado: Takion is very amazing.
- 1:25:14Pablo Galindo Salgado: Alas, it will be known as profiling dot sampling.
- 1:25:17Speaker 2: Yes, yes, yes.
- 1:25:18Speaker 2: We now know.
- 1:25:19Speaker 2: Most people call it Takion.
- 1:25:20Speaker 2: Most people call it Takion.
- 1:25:21Speaker 2: Call it Takion.
- 1:25:22Speaker 2: That's the real name.
- 1:25:23Speaker 2: The other one is the, you know, the name that you need to use when you go to boring meetings
- 1:25:28Speaker 2: with, like,
- 1:25:29Speaker 2: suits and, like, you know, companies.
- 1:25:31Speaker 2: Companies, oh,
- 1:25:31Speaker 2: who are you Takion?
- 1:25:32Speaker 2: No, no, I'm profiling dot sampling.
- 1:25:34Speaker 2: Oh,
- 1:25:34Speaker 2: okay, okay.
- 1:25:35Speaker 2: But, like, no,
- 1:25:35Speaker 2: no.
- 1:25:36Speaker 2: When you go to the party.
- 1:25:36Speaker 2: We trust this one,
- 1:25:37Speaker 2: yeah.
- 1:25:37Pablo Galindo Salgado: It's not one of the more weird physics things.
- 1:25:40László Kiss Kollár: Everyone should just call it Tachyon until it spreads and it just becomes the name.
- 1:25:44László Kiss Kollár: Yeah,
- 1:25:44László Kiss Kollár: yeah.
- 1:25:44László Kiss Kollár: No one will understand what you're talking about profiling or something.
- 1:25:47Speaker 2: If you talk to your manager, you say, oh, I use profiler or something.
- 1:25:50Speaker 2: Oh,
- 1:25:51Speaker 2: okay.
- 1:25:51Speaker 2: But like, no,
- 1:25:52Speaker 2: with your friends, you say, I use Tachyon and I fucking did it.
- 1:25:57Speaker 2: Oh,
- 1:25:57Speaker 2: okay.
- 1:25:57Speaker 2: That's right.
- 1:25:58Pablo Galindo Salgado: Who is this Tachyon?
- 1:25:59Pablo Galindo Salgado: Why does he solve it?
- 1:26:00Pablo Galindo Salgado: Yeah, who is this guy?
- 1:26:01Speaker 2: Who is this guy?
- 1:26:02Pablo Galindo Salgado: Well,
- 1:26:02Pablo Galindo Salgado: thank you guys,
- 1:26:03Pablo Galindo Salgado: Pablo,
- 1:26:03Pablo Galindo Salgado: Laszlo.
- 1:26:04Pablo Galindo Salgado: Thanks for being on the show.
- 1:26:05Pablo Galindo Salgado: Awesome work on getting this out to the world.
- 1:26:07Pablo Galindo Salgado: This is going to be super cool for everyone.
- 1:26:09Pablo Galindo Salgado: It's going to be great.
- 1:26:10Speaker 2: Thank you so much for hiring us,
- 1:26:11Speaker 2: and I hope people enjoy it.
- 1:26:13Pablo Galindo Salgado: I'm sure they will.
- 1:26:14Pablo Galindo Salgado: All right.
- 1:26:15László Kiss Kollár: Thanks a lot.
- 1:26:16Pablo Galindo Salgado: Bye, guys.
- 1:26:16Speaker 2: See you.
- 1:26:16László Kiss Kollár: Thank you.
- 1:26:18Pablo Galindo Salgado: This has been another episode of Talk Python To Me.
- 1:26:21Pablo Galindo Salgado: Thank you to our sponsors.
- 1:26:21Pablo Galindo Salgado: Be sure to check out what they're offering.
- 1:26:23Pablo Galindo Salgado: It really helps support the show.
- 1:26:25Pablo Galindo Salgado: This episode is brought to you by Sentry.
- 1:26:27Pablo Galindo Salgado: Sentry's new MCP server connects your error reports straight to your coding agent.
- 1:26:32Pablo Galindo Salgado: Claude Code reads the errors,
- 1:26:33Pablo Galindo Salgado: finds the bugs,
- 1:26:34Pablo Galindo Salgado: and fixes them.
- 1:26:35Pablo Galindo Salgado: Get started at talkpython.fm/sentry.
- 1:26:39Pablo Galindo Salgado: If you or your team needs to learn Python,
- 1:26:41Pablo Galindo Salgado: we have over 270 hours of beginner and advanced courses on topics ranging from complete beginners to async code, Flask, Django,
- 1:26:49Pablo Galindo Salgado: HTML,
- 1:26:50Pablo Galindo Salgado: and even LLMs.
- 1:26:51Pablo Galindo Salgado: Best of all,
- 1:26:52Pablo Galindo Salgado: there's no subscription in sight.
- 1:26:54Pablo Galindo Salgado: Browse the catalog at talkpython.fm.
- 1:26:56Pablo Galindo Salgado: And if you're not already subscribed to the show on your favorite podcast player,
- 1:27:00Pablo Galindo Salgado: what are you waiting for?
- 1:27:02Pablo Galindo Salgado: Just search for Python in your podcast player.
- 1:27:04Pablo Galindo Salgado: We should be right at the top.
- 1:27:05Pablo Galindo Salgado: If you enjoy that geeky rap song,
- 1:27:07Pablo Galindo Salgado: you can download the full track.
- 1:27:08Pablo Galindo Salgado: The link is actually in your podcast below or share notes.
- 1:27:11Pablo Galindo Salgado: This is your host,
- 1:27:12Pablo Galindo Salgado: Michael Kennedy.
- 1:27:12Pablo Galindo Salgado: Thank you so much for listening.
- 1:27:14Pablo Galindo Salgado: I really appreciate it.
- 1:27:15Pablo Galindo Salgado: I'll see you next time.
- 1:27:34Pablo Galindo Salgado: Get old.
- 1:27:36Pablo Galindo Salgado: We tapped into that modern vibe.
- 1:27:39Pablo Galindo Salgado: Overcame each storm.
- 1:27:40Pablo Galindo Salgado: Talk Python To Me.
- 1:27:42Pablo Galindo Salgado: I sync is the norm.