The Pragmatic Engineer
00:54:29 · Gergely Orosz, Maude Lemaire
[00:54:29] S2: And I understand then why you don't want to have many shards because if you have more shards, you would need to hit all of them. We're talking like, it's almost like a linear scan. [00:54:37] S1: Yeah. Yeah. Oh, no, it's quite, quite, quite inefficient. And again, I don't know that this is an actual example of one of the- This was hypothetical. This is completely hypothetical, but there were still very many significant scatter queries that were hitting almost every single shard before it knew that it could complete the query and return the result. Which, yes, I understand why that was a constraint then. You don't want to add more shards. But then again, you also cannot make the shards much bigger and they're under very heavy load. And so I was ready to apply the playbook that I'd been using for the last several years of like, well, let's [00:55:12] S2: just burn down the scatters. Let's just get rid of the scatter queries. Don't have scatter queries.
00:55:12 · Gergely Orosz, Maude Lemaire
[00:55:12] S2: just burn down the scatters. Let's just get rid of the scatter queries. Don't have scatter queries. [00:55:17] S1: Just don't have scatter queries. That can't be that hard. Well, it turns out that can be very hard when you're dealing with a... Rails, Monolith, and you've got ActiveRecord. And I always sort of thought it was funny, the number of, there were a lot of ex-Twitter folks at Slack early on, and everyone was like, haha, ActiveRecord. And I was like, what are you, like before they did the whole like Scala Java thing, right? And I was like, okay, I guess like we're all, you know, joking about ActiveRecord. I did not understand. Yeah. Until I like came face to face with it and I was like, oh, I really don't like this. This is really terrible. [00:55:54] S2: So like the record is Rails' abstraction layer for the database, right? So you define things in, I guess, code and it kind of maps nicely to database, except it might be harder to fine tune your queries, et cetera.
00:56:08 · Maude Lemaire
[00:56:08] S1: Yeah, I mean, it does a very good job at hiding the underlying data model from you, which, again, pros and cons. I came from a world where, like, SQL was, you know, religiously written out by hand for performance reasons. And then I was being... Thrown into this world where at one point we were trying to figure out, we were doing a bunch of work around domain extraction. And so how do we rip out everything related to, say, pull requests from the Rails monolith and extract that into a separate Go subsystem, take everything that deals with pull requests, just make the requests go through, say, the monolith still, but then just immediately send them over to the other system. Really standard sort of migration procedure. Started doing that. We started with stars and I think that project was eventually abandoned, but I was working, I was pairing with someone who had like a ton of Rails experience. And I was like, okay, you gotta like, because I, as someone who was so used to reading just code that was very sort of straightforward and didn't have so many levels of abstraction. It's a little bit daunting when you're going into a world where now there's abstractions upon abstractions upon abstractions. And I was working with her to try to rip out more of the STARS-related queries inside of the Rails model. We'd found sort of the root caller that created this query that would call into the STARS table. And it was like a five-line function. And I was looking at it with her on Zoom. And I said, wait, Kate, where... Where is the call? Like, where is the sequel being made? Like, what is happening? It's a five-line function. And she's like, Mo, that's the million-dollar question. And I was like, what are we looking at? What is happening? Because I half expected to see... I mean, at this point, I think so many people use Prisma, right? And Prisma, you can sort of... It's not, you know... Plain SQL written out as a string between quotation marks, but you can sort of see the structure of the SQL query being made. You do not get any of that in this case. It just looks like a regular function call. And in that moment is when I realized this is why this has been impossible to date. And why the problem has gotten so bad, because no one sees the impact Just writing a new line of code.
00:58:39 · Gergely Orosz, Maude Lemaire
[00:58:39] S2: And also fixing it now will probably, it's not as easy as just tweaking your abstraction layer. You would probably have to change how code is being written, being called, starting to call more either functions that call SQL, et cetera. Like it's just, you took a technology that worked great when you were small, you were able to scale it as long as you, and they figured out how to grow it as long as things are going linearly. [00:59:04] S1: Yeah, and I think one of the things that blew my mind the most that both gave me a lot of respect for how they've managed to date and also filled me with much dread was when you work inside of GitHub, obviously you have the admin view of GitHub and there's this bar at the top where you can load up a page on GitHub and it'll tell you exactly Wish MySQL queries were run to populate the page, which clusters they hit, how fast they all were, totals around all of this stuff. [00:59:38] S2: Just like the internal employee view. Yeah. [00:59:40] S1: Yeah, yeah, yeah. And what's called the files disambiguated page, which is sort of like the repo homepage that you land on with the readme. That page last I checked before I left. [00:59:51] S2: Before you left like a year ago?
00:59:51 · Gergely Orosz, Maude Lemaire
[00:59:51] S2: Before you left like a year ago? [00:59:52] S1: Actually less than that. But yeah, yeah, yeah. So some amount of time ago, it was over 100 MySQL queries to populate that page across at least three different MySQL clusters. And the thing with ActiveRecord is that it only caches the output automatically if the query is exactly the same. And so if, say, you're fetching user information, like full blanket, like select star from users where user ID equals blank, and you have that full user, but then later on you do select star from users where user ID equals blank and something else, it's not going to reach back into the results that it cashed for that first query because they are not exact same queries. Every single count. Or at least when I last left. Almost every single count you see on a GitHub page is live calculated. None of those are cached. There's a lot of reasons why that is. Mostly product reasons, actually. But that's one of the first things that I was like, but why? And to go back to like my sort of silly emoji example of like the 10,000 in month emoji, no one cares. Why does anyone care, right? And if you have low counts of things, sure, okay, maybe it matters that there's three open pull requests on like this very small repo that like no one really does anything with. But once it gets to like 99, don't just, don't show anything, just say 99 plus. Don't bother counting it. Why are we counting this?
01:01:23 · Gergely Orosz, Maude Lemaire, Gergely Orosz
[01:01:23] S2: Really interesting that So far, we talked about you did interesting things at Slack, at GitHub, you also worked at Copilot Code Review. Afterwards, you worked at Cursor. Again, they really pushed how we're coding with AI tools. But so far, we've not really talked about AI. It just didn't come up naturally. And I wanted to ask... Firstly, what do you think AI so far? You obviously use these tools all the time, increasingly, intensively. What parts of the job does AI not help you with? And what parts of it has it helped and has it changed how you work? [01:02:02] S1: Oh, gosh, yeah. It has not helped me with performance optimizations, basically, at all. At least the investigation part. Maybe the implementation part is a little bit faster. [01:02:14] S2: Once you know what you want to do. [01:02:16] S1: But yeah, figuring out what I want to do. So say I was looking at improving time to first token, time to first visible token. [01:02:24] S0: At Cursor.