Published June 24, 20261:34:29

Building a Data Warehouse from Scratch with Jacob Baskin

How Jane Street built Superstore, its own distributed columnar database for analytics, and now shares out its Hive compute cluster by auction.

Chapters

Quotes

  • On what Google lacked before DoubleClick

    “I don’t want to overgeneralize about Google in the mid 2000s, but there is certainly an ethos of we don’t know why anyone would rather talk to a salesperson than use a web UI.”

    Jacob BaskinRead from 07:09
  • On how the parking-sign startup did as a business

    “Not so well. Not so well, Ron. I love this problem to death. I still wish this data existed in the world, but we were not really set up very well to turn this into a business.”

    Jacob BaskinRead from 25:48
  • On why SQL doesn't feel like programming

    “SQL makes it so natural to write queries that you just feel like you’re asking a question of the system. You don’t feel like you’re writing a program. Even though what a database’s query planner actually is, is a compiler that generates code to run your SQL query as a program.”

    Jacob BaskinRead from 33:22
  • On whether programmers understand what the CPU does with their code

    “I think a lot of the last 10 years or 15 years even maybe of CPU design has been designed to give people the illusion that they still understand what the CPU is doing to their code when in fact they have no freaking idea what makes it fast.”

    Jacob BaskinRead from 34:53
  • On traders' strange Superstore use cases

    “And one impulse that I’ve had to really stifle in myself is asking people who are using tools like Superstore are like, ‘Have you tried not doing that?’ I ask it more than no times.”

    Jacob BaskinRead from 59:53
  • On buying 10 petabytes on the strength of a design doc

    “And I just, to be clear, I had just come from a startup where we had never seen an eight figure amount of money in the whole company’s existence.”

    Jacob BaskinRead from 1:04:19
  • On what really brings big systems down

    “And if you look at what causes system downtime, including for big tech systems that don’t have single points of failure, it turns out that it’s almost always caused by software bugs and not by the kinds of failures that people are designing against.”

    Jacob BaskinRead from 1:11:51
  • On optimizing the Hive's task graph

    “One question you might ask is, are there optimizations you can do on this graph to make it faster to run? And well, hey, now you’re back to writing a query planner.”

    Jacob BaskinRead from 1:30:23

Summary

At Brown, Jacob Baskin wrote his thesis on mechanism design: how to set up an auction or a market so that people do best by naming their true price. He then worked on Google's AdExchange after the DoubleClick acquisition, which meant real-time bidding on every single ad impression, pricing rules advertisers could actually follow, and distributed systems that keep state in as few components as possible. The lesson he took away: incentive compatibility is worth having, but people care more about understanding the mechanism. Advertiser budgets break the theory anyway, and simplicity turns out to be a value of its own. After a startup that digitized parking signs, Jacob came to Jane Street and announced right away that he was going to build a distributed analytical data warehouse.

Most of the episode is about Superstore. Analytics at Jane Street ran on shared Postgres databases: traders did whatever they liked with them, the databases were capped by the size of a single machine, and long transactions and deadlocks had to be shot by dedicated "killers." Off-the-shelf columnar systems like Vertica tried to offer full SQL transactional semantics and were easy to break. Superstore gave up transactions across tables, guaranteeing consistency only within a single table, and made writes asynchronous and separate from SQL: data becomes visible a little later, but the system gets time to lay it out and recompress it in columnar storage. Nobody can read the Parquet files directly, which is what makes access control and complete usage logs possible. Jane Street built its own instead of using Snowflake or Databricks because the cloud services are expensive, its data doesn't live in the cloud, and open source doesn't understand finance workloads. The first design doc turned into an eight-figure purchase of 10 petabytes of storage.

Jacob's biggest regret is the metadata store on CockroachDB: every commit to a table needs a round of distributed consensus, so the commit rate to a single table can't scale. It's now being replaced with Aria, built around a single sequencer: a single point of failure that, as Ron argues, is hardly a worry in practice. The last third of the conversation is about the Hive, Jane Street's compute cluster with hundreds of thousands of CPU cores and more than 10,000 GPUs. It is big enough to take down almost anything by accident. Time on it is allocated by a second-price auction, but a bid can't express urgency, so Jacob wants to move to utility curves over time, ship code to workers over BitTorrent and give users a declarative, Polars-style interface that the Hive can optimize the way a query engine does.

Advice

  1. Large enterprise customers need more than a web UI: figure out what they're trying to do and why instead of telling them how to do it, and build a close relationship with them.

  2. Make your pricing rules understandable: customers should see why they were charged what they were charged without anyone getting out a whiteboard. That matters more than a theoretically flawless mechanism.

  3. Push users to look for something better than the first solution they came up with, but don't argue with the use case itself: they've thought hard about what they need.

  4. Prepare future users early: explain what you're building and why, and they'll agree to try the product early, which does a lot to make it stick.

  5. Build a culture where projects are bets: trust colleagues who are making a reasonable attempt, even if it might not work out.

  6. Before building features, work side by side with your users: a feature that doesn't fit how they actually work won't get used.

Mentioned

Show 25 more mentionsShow fewer mentions

Transcript

01From mechanism design to Google ads

The mechanism design Jacob studied for his thesis out of pure interest paid off right away: his first job was Google's ad exchange.

Well, it’s my pleasure to have Jacob Baskin here on Signals and Threads. Jacob’s a software engineer here who has worked on a bunch of large scale compute and data systems that we’ve built here, and we’ll talk about a few of those. But first of all, just welcome. Thanks for joining me.

Happy to be here.

And I always like to hear a little bit about how people got started. Can you tell me a little bit more about how you got into computer science in the first place?

Well, so I’ve been coding since I was a little kid. My dad taught me BASIC1BASIC — a beginner's programming language created at Dartmouth College in 1964. In the 1970s and 1980s versions of it were built into home computers, and for many people it was their first programming language. back when I was seven. But then in college, I was actually not going to be a computer science major. I initially planned to be a psychology major, but I couldn’t get away. I enjoyed coding too much and there was too much cool stuff to work on. So I went to Brown University2Brown University — a private research university in Providence, Rhode Island, founded in 1764 and part of the Ivy League. and I ended up doing a bunch of stuff for my thesis around mechanism design3Mechanism design — the branch of economic theory about setting the rules of a game (an auction, a market, a vote) so that participants pursuing their own interests arrive at the outcome the designer wants. In 2007 Leonid Hurwicz, Eric Maskin and Roger Myerson won the Nobel Prize in economics "for having laid the foundations of mechanism design theory." Wikipedia. and the connection between economics and algorithms, which I found super interesting and had no particular belief that I would ever end up using this in my career. There’s some really cool stuff where incorporating the economics makes finding efficient algorithms and finding good ways to actually do the computations within a reasonable amount of time much more difficult.

And just say a bit of jargon, like mechanism design is weird econ jargon for designing markets, right?

Yeah. Well, markets are one kind of mechanism. I guess if you want to be technical about it, there’s a lot of mechanisms that don’t look like markets. But usually when people talk about mechanism design, they’re talking about something that looks like an auction, where people have some number that’s denominated in dollars or whatever, that they’re willing to pay for a certain thing or a certain collection of things. And your job as a mechanism designer is getting everyone to say their amount of dollars without having to be strategic and underhanded in a way that lets you figure out a socially good,4Socially good allocation — in economists' terms, one that maximizes social welfare: the total value all participants get together, rather than the organizer's revenue. so something that will result in the most actual value for real human beings, allocation of resources to the people who are contending for them.

And then how does mechanism design connect into software engineering?

Well, often the thing that you’re trying to do is hard, not just from a mechanism perspective. It’s not just that different people want things in different amounts and you have to figure out who wants stuff more and who wants stuff less, but actually figuring out the allocation is computationally difficult. So some classic problems in mechanism design are things like building networks.5Building networks — a classic problem where algorithms meet economics. Just connecting a given set of points with a network of minimum cost (the Steiner tree problem) is NP-hard, and mechanism design adds the question of how to split the cost among users, each of whom knows their own benefit better than the designer does. If you want to connect a bunch of different people’s houses to the internet, you have to literally go in the world and dig trenches and put fiber in trenches, right? And figuring out what are the right trenches to dig and what’s the right fiber to put. Even if you’re the king of the world and you get to dig whatever trenches you want and command the resources of everyone in the economy, still involves some algorithms and computation, but in a world where you actually have to find contractors to do this and pay them and Verizon is out there and AT&T is out there6Verizon and AT&T — the two largest US telecom carriers; they own both mobile networks and wired home internet, fiber included. and they want to do this in different places and are willing to charge you different amounts, right? Then you get this combination of this algorithmically challenging problem, this economically challenging problem. And you have to kind of solve both at once and they have interesting effects on each other.

Sure. Although I would like to point out that I asked you, how does it connect to software engineering? And then you told me how it connected –

It connected to computer science.

To digging trenches.

Yes. Fair enough. Okay. It connects to software engineering because a lot of the problems that we’re trying to build software to solve are problems that are economically important, where the ways that people interact with software are driven by their incentives and by their economic desires.

Right. And obviously you can totally see this stuff playing out in design of exchanges and markets and stuff like that. And there you see a rich intertwining of what you do on the mechanism design and how people behave and how that affects the technology. So despite you imagining this wouldn’t come up much in life, here you are at a trading firm.

Right. Here I am. It turns out that my interests are what they are and are somewhat consistent over the course of my life. But in fact, the way that I ended up dealing with this first at work involved advertising. My first job out of school was at Google, and I wound up working on Google’s very large and very interesting advertising business, helping Google do a better job of showing ads on other people’s websites. The system that I was working on, interestingly enough, was called AdExchange.7AdExchange (DoubleClick Ad Exchange, AdX) — Google's exchange for selling display ads in real time, launched in 2009 on DoubleClick technology; in 2018 it was folded into Google Ad Manager.

So yet another market.

Yet another market. And this one was in fact a two-sided market,8Two-sided market — a platform that brings together two different groups and earns from both: here, websites selling ad space and advertisers. An exchange works the same way, matching buyers and sellers. much like financial markets because you had people with space who wanted to show ads and then you had people who had ads and wanted to find space for them. And our job was to connect them. And we did in fact have to do some mechanism design to make the system work well.

02DoubleClick and real-time bidding

Google bought DoubleClick for its enterprise know-how, and the hardest technical piece became a real-time auction for every single impression.

So I mean, Google obviously selling advertising is very deep in that business. And in fact, early on it was kind of the only way they made any money at all. Where was this in the kind of evolution of Google’s ad business? What had been happening in their business at the time?

So in 2008, which was in fact the year that I started at Google, they bought a company called DoubleClick,9DoubleClick — an American online advertising company founded in 1996. Google announced it would buy it for $3.1 billion in April 2007, and the deal closed in March 2008. The brand was retired in 2018, and its products became part of Google Marketing Platform and Google Ad Manager. which is one of the original companies for doing banner ads. Back in the olden days in the internet, advertisements were much more about like you go to a website and there’s like an image and that image is an image that advertises something and you have to pick which image to load when someone visits the website. And that particular problem of loading the right image when a person visits the website and then also keeping track of all of these, that was DoubleClick’s bread and butter. And Google was very good at showing ads on Google search, but not so good at showing ads on other people’s websites. I mean, Google’s had that business for a long time too, but particularly when it came to sort of larger and fancier websites, DoubleClick was the industry leader. So Google acquired them and then they had this problem of, well, can we do both? Can we take the stuff that we’re so good at when it comes to showing ads on google.com, which was an auction forever.10Google's auction — in Google's search advertising, AdWords (now Google Ads), ad slots are sold at auction, with advertisers bidding per click. The scheme is called the generalized second-price auction (GSP); the first economic analyses of it were papers by Edelman, Ostrovsky and Schwarz and by Google's chief economist Hal Varian (Wikipedia, "Generalized second-price auction"). They wrote very interesting papers back when they were building the system about how they did this auction mechanism for showing ads on Google. Can we combine that kind of auction mechanism with something that takes into account the needs and the desires of large web publishers, people like newspapers or large news operations, Huffington Post, Buzzfeed,11The Huffington Post and BuzzFeed — American online publications launched in 2005 and 2006. In the 2000s and 2010s they were the emblem of new media living on advertising and viral traffic. this was the aughts. So those were large companies at the time. So how do we adapt this auctioning world to one where there’s all these publishers, but also where we don’t know what all the ads are in the world, where in fact there’s all of these other companies, whether they’re ad agencies or whether they’re middlemen who understand the advertisers and what they want and want to integrate with our system in some reasonable way.

Can you say a little bit more about what the kind of two sides of this two company combo was? I can sort of guess at what Google was good at here. Google is really good at building infrastructure and I bet did a lot of good work on setting up the auction so it made sense and had coherent incentives and all of that.

So what was DoubleClick bringing to the table?

What was DoubleClick good at?

DoubleClick understood enterprise customers. I don’t want to overgeneralize about Google in the mid 2000s, but there is certainly an ethos of we don’t know why anyone would rather talk to a salesperson than use a web UI.

I mean, I do sympathize.

I sympathize too. I would almost always rather use a web UI than talk to a salesperson, but there are definitely cases, especially when it’s one company talking to another company where first of all, having the attitude as a business that we really want to understand what it is that our customers are trying to do and why, rather than think that we should know better than them and tell them what we should try to do. And then also have a much more managed relationship with these people that’s not just like, “Here you go, enjoy your advertising system.” So that was sort of where DoubleClick was coming in. They had built relationships with the very largest web publishers and the very largest advertisers. And obviously Google appreciated having those relationships, but they also really appreciated having the DNA of, well, here’s what it takes to serve large customers, which was just not something that Google did very much of at all in the early days.

Got it. So then what was the kind of technical work that you were doing? You have these two companies that you need to integrate their businesses together. How does that turn into a technical problem?

Google's first production server rack (1999) at the Computer History Museum: cheap motherboards and disks on corkboard. Betting on masses of unreliable hardware is what led to GFS, MapReduce and Bigtable
Google's first production server rack (1999) at the Computer History Museum: cheap motherboards and disks on corkboard. Betting on masses of unreliable hardware is what led to GFS, MapReduce and Bigtable

Well, so we were building all of this on Google infrastructure. So DoubleClick and Google had completely separate technical infrastructure and pretty quickly the decision that, and this was in fact before I started, Google made the decision we’re going to throw out all the DoubleClick stuff and build it all again on Google infrastructure because of course they did. So the challenge became sort of trying to take the insights that DoubleClick had about their business and combine them with Google’s … It’s worth saying that at the time, Google’s infrastructure felt like it came from the future. A lot of the stuff that Google built … And these days, we just sort of live with it in the cloud. So we don’t recognize after the fact how revolutionary it was back in the mid 2000s, but things like MapReduce and BigTable, which were Google’s distributed systems for storing and processing large amounts of data.12GFS, MapReduce and Bigtable — Google described these systems in famous papers: the Google File System (2003), MapReduce (2004) and Bigtable (2006). The open-source Hadoop and HBase were modeled on them. They had this very large distributed file system called GFS that stored many petabytes of data. You could just run applications over thousands of computers at once just by typing in the right numbers into a config file. These things were not table stakes across the industry.

Yeah. And I remember when those papers came out, they made a huge splash because it was … In some sense, the underlying techniques were not super new or surprising exactly, but they had sort of implemented it at scale and gotten … And there’s a lot of hard things to go from taking an idea that kind of makes sense to doing it really effectively at scale and had learned a lot from that experience. And it was actually great that they published those papers and I think it influenced the industry broadly a bunch.

So really the technical work or one very hard piece of technical work was taking this Google infrastructure that was, again, very horizontally scalable13Horizontal scaling — growing a system by adding more machines rather than replacing one machine with a more powerful one (vertical scaling). and combining it with these DoubleClick insights about what is the feature set that you need to serve these large publishers and large advertisers. For AdExchange specifically, there’s another very interesting technical piece, which is called real-time bidding.14Real-time bidding (RTB) — a way of selling ads in which each individual impression is auctioned off in a fraction of a second while the page loads: the ad exchange sends a request to buyers, they send back bids, and the winner gets the impression. To integrate with the systems on the advertiser’s side, the things that actually know what ads people want to show, rather than have them give us all of their ad inventory15Ad inventory — ad industry jargon. Usually it means the ad slots a publisher sells; here, the stock of ads an advertiser picks from. in advance and be able to pick out of a database, we actually would query these systems across the internet for every single ad impression that they wanted to show and let them submit a bid in real time.

Oh, wait, how does that actually work practically? They have ads. Those ads have relatively heavy assets like images and stuff that need to get delivered. And is it like literally just in time, like someone loads a webpage and it needs to find an ad and it goes all the way end to end to the actual advertiser who’s providing the ad and gets the image at the last moment?

Is it really like just in time the whole way through?

ExplainerHow a single impression gets auctioned

Google launched real-time bidding on its DoubleClick Ad Exchange in 2009. The whole auction fits into the time it takes the page to load:

  • the browser reaches the ad slot, and the publisher's code sends a request to the exchange: which site, which slot, what size, plus an anonymized visitor ID from a cookie;
  • the exchange sends a bid request to the buyers' servers, the systems that purchase ads on behalf of advertisers, and waits on the order of a hundred milliseconds for answers; anyone who's late is out of the auction;
  • the buyer uses its own data about the visitor to decide what the impression is worth and replies with a bid and an HTML snippet containing the ad;
  • the highest bid wins; in those years the winner paid the second-highest bid, and in 2019 Google moved its exchange to a first-price auction;
  • the browser gets the winner's HTML, and it is the browser that fetches the image from the advertiser's servers and loads its tracking pixels, which is why the ad itself never passes through the exchange.

Well, so it’s actually, it’s just in time twice. So the first thing that happens is you say like, “Hey, I want to show an ad here.” And then you need people to bid. So that goes through Google systems to look at all of the people who sort of have bids. They have some filter criteria. We don’t call everyone for every single time Google shows an ad on the internet, but there’s some filter criteria. We choose which advertisers call. We say like, “Hey, here’s information about this advertising spot on this website. What’s your bid?” And then they return us a bid and then if they win, we inject a little HTML snippet into the ad unit on the webpage. That goes to their system and fetches the image.

Got it. So then the final asset is not actually flowing through Google systems, that’s just being directly loaded from the final advertiser.

Exactly. With a lot of asterisks around … This is all very much integrated with all of the crazy ad tracking pixels and cookies16Tracking pixel — an invisible one-pixel image: when the browser loads it, it tells a third-party server that the page was opened. Cookies — small pieces of data a site stores in the browser to recognize the user on later visits. stuff that got built in the internet around that time. So really the load on pages for loading ads, I mean these days as well, but also in those days, was incredibly heavy just in terms of all of the various tracking cookies and pixels and different domains that provided all of this different stuff to do metrics and monitoring for the ad. That ended up being much worse than the image itself.

Got it. And then also this whole infrastructure is also probably kind of a security disaster, although maybe in a way that wasn’t as obvious back then.

Definitely all of the tracking and cookie stuff is absolutely a security and privacy mess, but we did in fact think about this. And one of the things that we built was a way for advertisers to link what they knew about a given user with a particular ad impression without us being able to extend their reach to that user across the internet. We would anonymize users identifiers in a way that didn’t give advertisers access to them, but it still let them know if they had seen that user before.

Got it. So I guess that sounds like part of the security problem. I guess the other security problem is around the like delivery of weird malware17Malvertising — spreading malware through ad networks: the attacker buys impressions, and their code lands on perfectly respectable sites that nobody hacked (Wikipedia, "Malvertising"). through JavaScript nonsense –

This kind of complex routing system.

Yes. So Google also had pretty reasonable controls for that. That can be very difficult. That was a real arms race with malware actors, but at least we tried very hard. But yes, certainly once you get to put arbitrary HTML inside a user’s browser, yeah, it’s a pretty fraught scenario. And certainly at the time, browsers didn’t have any particularly good sandboxing18Sandbox — an isolated environment where untrusted code runs without access to the rest of the system. Modern browsers use sandboxes to separate pages and the frames embedded in them from each other. abilities for managing this well.

Right. Luckily when this all started, it was less important and then we had some time to spend time making it better as it got more central to the world.

Yeah, I think that’s fair. It’s certainly very important to the publishers at the time. If you remember back in the day, the New York Times didn’t have a paywall.19The New York Times paywall went up in March 2011; before that, from 2005 to 2007, only the opinion columnists sat behind the paid TimesSelect. Just so much journalism on the internet and just content more generally on the internet was ad supported. And this is one of the exciting things about working in that industry at the time is we were like on a mission to make the ad supported internet actually work for people. Now we failed, but we tried really hard.

03Lessons from Google: explainable mechanisms and contained state

Incentive compatibility turned out to be the smaller part of the problem: people care more about understanding the mechanism, and distributed systems work best when the hard state is contained in a few components.

So you’d studied something about mechanism design in school, and then here you were right in the middle of designing these mechanisms. How well did the lessons that you learned in school pan out? What do you feel like you learned from the whole process of trying to do this stuff with a real system?

So the main message that you get or that I got at the time from the sort of academic community around mechanism design was that building incentive compatible mechanisms20Incentive compatibility — the property of a mechanism under which every participant does best by truthfully reporting their real preferences. The classic example is the second-price auction. was extremely valuable. That if you build the mechanism right, it benefits people to tell you the truth. And if you build mechanisms wrong, then people are going to try and game the system, and this will end up resulting in a worse situation than you otherwise would have. And I think the main thing that I learned in industry was that’s definitely a valuable thing that it’s nice to do, but that is a much smaller part of the problem than I believed it was back when I was in school.

So what’s the rest of the problem?

So two big things that you have to focus on that are not covered in that view of mechanism design are first of all, people need to understand the mechanism. It’s no good if you can give them the complicated proof that the mechanism is incentive compatible if they don’t have any idea what the heck is going on. So being able to point to, well, here’s why this good thing happened to you. Here’s why this bad thing happened to you. Here’s why we charge you this amount without having to get a whiteboard out is really important when you’re actually trying to sell something to people who are not mechanism design PhDs.

Can you give an example of a part of the technical design that was done to achieve that goal of making the results more explainable to people?

Okay. Well, so a great example is budgets. If I’m an advertiser and I want to go and show ads on websites, probably I don’t want to spend infinite amounts of money, even if I can get really good prices all day.

Probably I want to spend a thousand bucks, maybe a thousand bucks a day.

You want some risk limits?21Risk limits — in trading, a cap on possible losses or position size that must not be exceeded. Ron is jokingly translating an ad budget into trading-firm terms.

Yeah, I want some risk limits.

Fantastic.

So let’s say that I go and I start spending my budget and I spend it really quickly and then I have like five bucks left and it’s getting towards the end of the day. What should I do to give myself better outcomes? Well, I should probably lower my bid, right? Because the chances are that I have been spending too fast and I could get more of the good stuff that I want for less money if I just bid less for it. And this is not really an incentive compatible result because another way of saying that is if I have a budget, then I should bid less than my marginal value22Marginal value — what one more unit of a good, here one more ad impression, is worth to a participant. In an incentive-compatible auction it pays to bid exactly that; with a limited budget it pays to bid less. of each thing in order to get the best results for me. Right. So budgets break sort of a very naively memoryless23Memoryless auction — every impression is auctioned separately, regardless of what the participant has already bought and spent. A budget is exactly what ties the auctions together: what you spent in the morning limits your bids in the evening. incentive compatible auction all the time. And yet very few people try and model this for their market participants. In almost all the cases, what you’ll see is that people offer, maybe they have some kind of second price auction,24Second-price auction (Vickrey auction) — a sealed-bid auction in which the highest bid wins but the winner pays the second-highest bid, so everyone does best by bidding exactly their true value. William Vickrey described it in 1961 and won the Nobel Prize in economics in 1996. maybe not even, but nobody tries to take into account people’s budgets when figuring out how to allocate them stuff.

When you say nobody, you mean like in the academic literature, nobody thinks about budgets, or do you mean in real world systems?

ExplainerWhy budgets break truthful bidding

In a second-price auction for a single impression, bidding your true value is the best strategy whatever your rivals bid: you pay their bid, not yours, so there's no reason to shade it up or down. But that holds for one auction. With a daily budget the auctions become linked: money spent in the morning on a $3 impression can't be spent in the evening on one that would have earned more. So a bidder with a budget does best by bidding below value, and by how much depends on how many impressions and competitors are still to come that day, which nobody knows.

You can build this into the mechanism, but then bidders stop understanding why they won or lost. Ad systems went another way: the per-impression auction stays simple, and spending pace is handled by a separate, understandable setting. In Google Ads, for example, the advertiser sets an average daily budget; the system may spend up to twice that in a day, but no more than 30.4 daily budgets in a month.

In real world systems, people let you manage your budget. They don’t try and manage your budget for you. And they will even maybe say like, “Hey, you should bid less so that your budget lasts all day.” And rather than trying to model budgets as part of the mechanism, they just let it be this other thing that people have to manage on their own. Because when we try and incorporate people’s budgets for them in some way, they just get results that they don’t understand. And in fact, people have a lot of constraints that they’re not telling you that you’re not really in a good place to know and you just kind of have to let them do their thing and be sort of incentive compatible in a narrower sense if you can without really trying to be fully incentive compatible in some theoretical sense. I remember –

So simplicity is a value.

Simplicity is a value.

So Google was obviously an interesting place to learn about all of this kind of market stuff around ads, but there’s also a lot of interesting technical stuff happening there as you were mentioning. What do you feel like you learned from the experience of being a kind of systems engineer and systems designer in that world?

Just so much. I feel like I’m still mining a lot of my early Google experience for software engineering insights. One of the main things that I learned was kind of how to think about distributed systems in ways that let you design them well. The Google approach to building distributed systems is to try and make the hard part be as contained as possible. You take some existing system that does a very hard distributed system thing, whether that’s distributed consensus or25Distributed consensus — a way to get several servers to agree on a single value even if some of them fail or the links between them break. Ron and Jacob come back to it toward the end of the episode. whether that’s like building a large stateful key value store,26Key-value store — a database that stores values under unique keys and can write and look them up quickly, but usually without complex queries like SQL. Examples are Bigtable and Redis. and then you build your system in terms of that existing thing. And often this is sort of a nested process where like BigTable, which is this great distributed key value store is built on top of Chubby,27Chubby — Google's distributed lock service, built on the Paxos consensus algorithm and described in a 2006 paper by Mike Burrows. Bigtable relies on it, for example, to elect a master server and to store its schema. which is this distributed consensus mechanism. And most engineers at Google are not building BigTable or Chubby, they’re building something on top of both of them. And in particular, building large stateless systems is much easier than building large stateful systems.28Stateless and stateful systems. A stateless component remembers nothing between requests, so you can run as many copies of it as you like and restart any of them without worry. A stateful component holds data, which has to be replicated, recovered and kept consistent. So you really want to contain the state of your system in as few different components as you can.

Although I find it’s always kind of funny when people talk about building stateless systems, like often there is state there. It’s just like not being managed by you.

And so it’s more about like, it’s not so much about the system you’re building being stateless, but the component that you’re adding on, not being responsible for managing this data on itself.

Well, almost every system is like stateful in some sense, or what is it even doing? Maybe you’re building a data center of a million pocket calculators, but otherwise you’re pretty stateful. But yeah, again, the goal is having as few of the components be stateful as you can. So a very Google approach to this kind of problem is like, well, we’ll have this stateful core that goes and gets the data and loads into memory in some extremely efficient form, and then we’ll just have a bazillion web servers that all go talk to it and we’ll push as much of the work out to these bazillion web servers as we can, and then they’ll make what are hopefully very efficient queries to the thing maintaining the state, and that’s what the system will look like. This does not look a lot like the way that trading systems work, where you end up keeping the state very close to the edge29Close to the edge — right at the boundary of the system, where it receives market data and sends orders: everything needed for a decision sits in the trading program's own memory, so no time is lost on network requests to other components. because you prioritize latency at levels that Google just didn’t. Our latency target for ad serving was 250 milliseconds.

Which by some measures is kind of fast, but-

Yeah, it’s fast enough that you’re not going to go and get a cup of coffee waiting for the website to load, which is really the important thing.

Right. But it’s very, very different from the kind of latencies that we worry about when we’re building systems.

And so you can do a lot of things with a 250 millisecond latency budget that you can’t if your latency budget is in the microseconds.30Microsecond — a millionth of a second. A 250-millisecond budget is 250,000 times longer than one microsecond.

Right. Yeah. And people often talk about technical organizations pointing out that the technical organizations are often kind of shaped like their initial application and Google’s early infrastructure in many ways was built around search and ours was built very much around trading systems and that’s led to some very different choices.

And in ads at Google, we were 100% using components that were initially developed for Google search. Google looked at advertising, this was before my time, Google looked at advertising as just a search problem. Our problem is like we have to index all of the ads in the world and find the best one to show for a given website. Yeah, if you squint hard enough, sure.

04Parking signs and the road to Jane Street

A startup mapping city curbs didn't work out as a business, so Jacob picked Jane Street, where almost everyone he knew in finance already worked.

Okay. So you learned a bunch of this fun stuff at Google. How did you end up here?

Well, so from Google, I ended up going and doing a startup focused on helping cities manage their curbs.31Curb management — the urban-planning discipline of who gets to use the edge of the street and when: parking, deliveries, taxis, buses, cyclists.

What do you mean manage their curbs?

A trial Los Angeles parking sign (2015): instead of a stack of text plates, a timetable by day and hour, color-coded for when you can and can't park
A trial Los Angeles parking sign (2015): instead of a stack of text plates, a timetable by day and hour, color-coded for when you can and can't park

So if you walk down the sidewalk, certainly in New York, but also in really just about any city in the world, there will be all kinds of arcane paint markings and signs with icons on them and so forth, denoting if someone pulls a vehicle over to the side of this particular street, what are they allowed to do and what is going to get them a ticket? Okay. Maybe you’re allowed to park, but do you have to pay? Can you park for four hours or can you only park for one hour? Maybe you can’t park, but if you’re a truck, you can load and unload goods from the truck. Maybe you can’t unload goods, but you can unload passengers, but only for three minutes. All of these rules have sort of been built up over time and accrued in these cities and almost nobody has a good record of what they are and why. Okay. So we were trying to solve this problem and build a platform for cities to manage both the actual physical control infrastructure that causes these rules to take effect on a given street, and then also better be able to understand and analyze what the rules even were. How many parking spots are there in New York? This is a harder question to answer than one might think, especially because it changes day to day and hour to hour.

Wait, it changes day to day. How does it change from hour to hour?

Well, there’s a sign that says no stopping 4:00 PM to 6:00 PM Monday to Friday.

Okay. And then how is this company going to solve those problems?

One of the interesting things about parking signs is that exactly where they are matters to plus or minus one parking spot, which is a little tighter than you can do reliably in urban areas with GPS.32GPS in cities — between tall buildings satellite signals bounce off walls and get blocked by them (the "urban canyon" effect), and position errors can reach tens of meters. Okay. So one piece of infrastructure we had was an app that used sort of AR inspired visual odometry techniques33Visual odometry — working out how a camera is moving from the sequence of frames it captures. It underpins smartphone AR apps that "pin" virtual objects to a real scene. to figure out exactly where along the street different things like signs were.

Wait, AR, augmented reality.

So if you like Pokémon GO,34Pokémon GO — an augmented reality mobile game released by Niantic with The Pokémon Company in 2016: Pokémon appear on the phone screen over the real world, and you catch them by walking around town. you lift up your phone and there on the table is sitting a Pokémon and you move your phone around and the Pokémon stays where they are relative to the things in the scene, even if your phone moves. So to do that, you have to build a map of the scene inside your phone.

If you can build a map of a scene inside your phone, then you can build a map of a block inside your phone.

And then we can use those to position the parking signs along the block with extremely high accuracy.

Nice. Okay. Fun.

So that data collection problem is actually really fun to solve. And then once you have the data of like, well, where are the parking signs? Well, then you have to figure out what they say, which is a transcription problem. We didn’t have Claude35Claude — Anthropic's family of large language models; the first version came out in March 2023. Models like this read the text in photos and understand what it means, which the startup had to do by hand. back in the day. We had to figure out how to do this using slightly less general techniques.

And then even once you know what they say, you have to know what that means.

And parking signs have this language that’s sort of all their own where often-

I would think one advantage is like the vocabulary is relatively small.

The vocabulary is relatively small. We ended up essentially hand building parsers36Parser — a program that breaks text down according to the rules of a grammar and turns it into a structure a computer can work with: here, the wording on a sign into a set of rules about who can stop, when and for how long. for this, but it’s actually quite tricky because this is designed to be sort of easily looked at by humans who know that particular city very well. So the vocabulary varies city to city and also things like the position of different numbers and words on the sign looks very different than the linear reading of a sentence of text on a computer. There’s a big two over here and then somewhere else on the sign, it’ll say maximum hours parking. And do you connect those? Well, yes, as a human, we’re very good at using spatial context to put these things together, but figuring out a way to model this in a computer can be quite challenging.

So this sounds like a big pile of fun, grotty engineering problems and a bunch of weird domain specific knowledge that you need to make this thing work. How did this work out as a business?

Not so well. Not so well, Ron. I love this problem to death. I still wish this data existed in the world, but we were not really set up very well to turn this into a business.

That didn’t so much work out. And then I was saying, “Well, okay, what do I do next?” I knew I didn’t want to go back to Google. Partly just kind of been there, done that. Partly the company had gotten much, much bigger in the time that I was there and in the time since I was there. And I was looking for something that I could do in New York. I loved living in New York. I didn’t want to move.

Back to being enough of an urbanist to want to do a startup around cities.

Exactly. And I loved this kind of economic thinking that I was doing back earlier in my career. And I knew of, in fact, a bunch of people who were doing finance-y type stuff in New York. And so I thought, well, where do I do this? What’s the right place for me to put all these things together? Jane Street was a super obvious choice for me, partly because almost all the people I knew who were working in the financial sphere were in fact at Jane Street already. These are people who I’d worked with at university. These are people I knew from Google. These were random people I knew socially. It was a bunch of people who I thought were extremely smart, who I really respected, and they all managed to wind up at this place. And you’re kind of like, “Hmm, I wonder how that happened.” I mean, also I had done some functional programming37Functional programming — a style in which programs are built from functions without side effects, and data is left unchanged wherever possible. The classic functional languages are the ML family (OCaml included), Lisp and Haskell. in college, and even back in 2008, already in the back of my head was, “Oh, Jane Street’s a place you can go and write OCaml.”38OCaml — a functional programming language in the ML family, created at the French research institute INRIA in 1996. Jane Street writes almost all its code in it. Oh, that sounds pretty fun.

So our odd taste in programming languages strikes again.

Absolutely. And I had in fact written some OCaml to do some combinatorial optimization39Combinatorial optimization — finding the best option among a finite but enormous number of combinations: a route, a schedule, a packing. Trying them all is usually impossible, so clever algorithms are needed. problem solving for a class back in university. Not that that came in that handy when I started here. The OCaml that Jane Street writes actually looks pretty different than the OCaml that I wrote 15 years ago. But yeah, I’d known about the place and it seemed really cool. And so I thought, why don’t I interview with them and see what there is?

05Why replace Postgres

Postgres is built for fast transactions, but analytics needs data laid out very differently, and Vertica, a columnar database with full SQL transactional semantics, was too easy to break.

Cool. Okay. So when you got here, what did you find yourself doing? What part of the organization did you land in?

So one of the things that Jane Street does before you start is there’s this team match process where you go and meet with people who seem like teams that you might want to work on and you chat with them. So one of the teams that I did a team match with was this team called database infrastructure. And I talked to this guy, Sam, who talked about, well, Jane Street runs all these Postgres databases.40PostgreSQL (Postgres) — an open-source relational database, the successor to the Postgres project Michael Stonebraker started at UC Berkeley in 1986. One of the most popular databases in the world. Some of them are really big and we’re having trouble managing them and we just sort of let people put whatever data in there and it doesn’t always go very well, so we really want to make this work better. And I’m like, okay, well, that definitely sounds like a hard problem, but why are you trying to do this? Why don’t you have some kind of distributed analytical database that can query over all of this different data without it having to live on a single computer that runs Postgres? And so I’m like, yeah, that kind of does seem like something we thought about. We haven’t built it yet, but it seems like that would be a good direction to at least explore. And I’m like, okay, I’m very happy to work on these database problems, but just so you know, if I come and work on your team, I’m going to try and build this data warehouse41Data warehouse — a database that pulls together data from many sources so it can be analyzed in one place. It is built for large queries over accumulated data rather than fast small changes. analytics thing.

So can we dig in a little bit more to the kind of like, status quo ante, what is wrong with the throw a lot of data into a Postgres database? Isn’t that what databases are for is throwing a lot of data into them? How were you using them and what was weird about that use from your perspective?

So Postgres is a great database, but it has a lot of different goals that it’s trying to meet. One of the things that Postgres is trying to do is be able to do really fast single row or few row transactions.42Transaction — a group of database operations executed as a single unit: either all the changes are applied or none are, and other users never see an in-between state. Think about running a store. Someone clicks a checkout button on your website and they go and buy a widget. And you want to both record this order that someone bought this widget. You want to decrease the number of widgets in your inventory by one. And you want this to all happen while the page is loading in a very short amount of time and you want it to all succeed atomically.43Atomicity — the A in ACID, the set of guarantees of transactional databases (atomicity, consistency, isolation, durability): an operation is indivisible and can't be half done. Postgres has to solve that problem. There’s this other set of problems which we kind of call sort of analytical processing, which are about I have a lot of data and I want to answer questions about all of this data altogether in aggregate in some way that could involve not just single rows, but like many millions of rows of data. Postgres can do this for you as well, but it’s much slower at it because it’s constrained by needing to store this data in a way that lets it do these atomic transactions over very few rows. It’s like for example, Postgres maintains indexes.44Index — an extra data structure, usually a tree, that lets you find rows by a column's value without scanning the whole table, like the index at the back of a book. The price is disk space and updating the index on every write. You have all this data in a table and Postgres can look up this data for you by potentially a lot of different things, a lot of different potential keys into this piece of data. But that means that all these indexes have to live on disk. And also Postgres can very efficiently update individual rows. And if you think about it, what this means is that Postgres can’t really compress across rows. Because if I have to be able to change that one bit on that one row, if that bit is compressed into like some 50 kilobyte or one megabyte chunk, well then every time I change a row, I got to write that 50 kilobytes or that one megabyte of data back to disk, and that’s just going to be a non-starter for these transactional use cases. So Postgres does as good of a job as it can given the constraints that it has. But ultimately, when you’re doing these analytical processing use cases, you really want to lay out the actual data at rest45Data at rest — data sitting on disk, as opposed to data moving over the network or being processed in memory. in a very, very different way.

Right. And this kind of goes back to this classic distinction between row oriented databases and column oriented databases,46Row-oriented and column-oriented databases lay data out differently. In a row store the values of one record sit next to each other, which makes it fast to read and change individual rows: the transactional workload (OLTP). In a column store the values of one column sit together: data of one type compresses well, and an analytical query reads only the columns it needs: the analytical workload (OLAP). which has always struck me as super weird. The idea is like, I would like to get a piece of software for managing my data. It’s like, wait, do you want a row oriented database or a column oriented database? And I’m like, you mean I have to pick my data structure now? Why can’t I pick it on a table by table basis? Why can’t I take my data and represent it multiple different ways so that I can do both this kind of access and that kind of access efficiently, depending on the particular kind of thing I want to do?

And a lot of people try and build systems that do both. But what we found is that the abstractions that make columnar databases efficient kind of leak through the interface layer.47Leaky abstraction — an abstraction that can't fully hide what's underneath it: to use it well you still have to understand the lower level. The term was popularized by the programmer Joel Spolsky in his essay "The Law of Leaky Abstractions" (2002). You can go out and find right now a lot of SQL compliant, whatever that means, different things to different people, databases that have columnar storage. In fact, at Jane Street, we were using one at the time that I came and made my bold claim, which was called Vertica,48Vertica — a commercial columnar analytical database that grew out of Michael Stonebraker's C-Store research project. The company was founded in 2005 and bought by HP in 2011; the product now belongs to OpenText. which is an existing columnar database. It’s in fact very efficient for a lot of these sorts of analytical problems. What we found with Vertica is that because it tried to give you these full SQL transactional semantics, it was very easy to break. A lot of the things that you could do with SQL that Postgres can support very efficiently, trying to build that transactional layer over underlying columnar data just gets rid of a lot of the advantages that you’re trying to get in the first place. And the way that this gets implemented with a lot of these systems just dramatically slows down the queries and can even make the database unusable. Now what most-

06SQL, blessing and curse

SQL is so good that a query doesn't feel like a program, which is exactly why its behavior is hard to predict.

SQL is like the blessing and curse of the database industry.

There’s this language defined like, what, in the 70s,49SQL (Structured Query Language) — the query language for relational databases. Its first version, SEQUEL, was developed at IBM by Donald Chamberlin and Raymond Boyce in 1974; it became the ANSI SQL standard in 1986. I think, that somehow we’re all still using more or less the same language today. And I guess the problem you’re pointing at here is like a kind of overexpressiveness problem of like SQL can do a lot of different things, but the implementation you put under it, maybe we’ll do some of those things really well and some of those things really badly. And when you give the full API surface to people, they’ll maybe try and do all the things that you tell them that you can do and it’s going to be a bad time.

Now the way that I’d put that is that SQL does such a good job of being what it is that it doesn’t feel like programming. If someone told you like, “Oh, C++50C++ — a programming language Bjarne Stroustrup created as an extension of C; the first commercial version came out in 1985. Famous for its power and complexity, it is used for browsers, games and trading systems. is way too expressive.” It lets you do whatever you want to do. And sometimes people do bad things with C++ and that means it’s a mistake. No, God knows C++ has plenty of faults, but you’re not going to say, “Oh, it’s too expressive. It lets you do too many different things.” If people treated the SQL that they write as if they were writing a software system when they were constructing their queries, I think we wouldn’t mind that SQL can do all these different things and it has leaky abstractions and et cetera, et cetera. This is all stuff that as software engineers we take for granted, but SQL makes it so natural to write queries that you just feel like you’re asking a question of the system. You don’t feel like you’re writing a program. Even though what a database’s query planner51Query planner (query optimizer) — the part of a database that decides exactly how to execute a SQL query: in what order to join tables, which indexes and algorithms to use. It makes its choices based on table statistics (how many rows, how the values are distributed), so the same query can run in different ways. actually is, is a compiler that generates code to run your SQL query as a program. It doesn’t feel like that’s what it’s doing to us because SQL is such a good abstraction.

Right. But I think it also goes back to almost like the mechanism design point you were making before of sometimes it’s more important to be explainable. And the key thing that SQL trades away is explainability, which is like you do put in a SQL query and then it’s optimized and then a miracle happens or maybe the miracle doesn’t happen. And depending on not just the shape of the tables you run it on, but the statistics that were gathered from that table, it will optimize in different ways. It can be very hard to predict what the behavior is. Right, so you’re sort of not used to as a user who’s sitting there writing SQL work.

Whereas we can all simulate our compilers in our head and understand exactly what they do to our OCaml code. I think a lot of the last 10 years or 15 years even maybe of CPU design has been designed to give people the illusion that they still understand what the CPU is doing to their code52A modern CPU doesn't execute instructions strictly in the order they're written: it reorders them, runs several at once, predicts branches ahead of time and executes code speculatively, and speed depends heavily on cache hits. From the outside it all still looks like sequential execution. when in fact they have no freaking idea what makes it fast.

I mean, I think what you’re saying is obviously true in the sense that if you want to understand what’s actually happening in a program that you write in OCaml or C or whatever, and you really want to understand it at a very low level of detail, God help you. There’s an enormous amount of complex things happening at many different levels and lots of optimizations that are in there that try to make it fast for you even when you haven’t done all the careful work for yourself. But I think there’s a difference of degree. There are deep algorithmic big O notation changes53Big O notation — describes how an algorithm's running time grows with the size of the data: O(n) is linear, O(n²) quadratic. If the optimizer picks a different join algorithm, a query can slow down not by a factor of a few but by orders of magnitude. to the execution of a SQL query, which makes it dramatically harder to predict what it’s going to do just from the query alone than you can from looking at a program in almost any ordinary-

This is true. Very few compilers will change the big O complexity of your code up from under you. Whereas the decisions of the query optimizer for a SQL query engine can often be extremely load bearing. That’s a hundred percent true.

07The Wild West on shared databases

The value of the shared databases came from traders' freedom to join anything, and Jane Street paid for that freedom with automatic killers for long transactions and deadlocks.

Right. And when you say we were throwing lots of data and creating lots of queries and stuff, what for, what was the use case that you were running into that we were all kind of running into and how we were using databases?

Well, so the funny thing is that this was in many ways just kind of emergent from lots of different people’s connected use of these databases. So a great example is like a list of all the trades that Jane Street has done every day. You can totally imagine why that’s valuable. Okay, let’s take some information that I have in my trading. Let’s combine that with all the trades that Jane Street is doing and derive some insight from this. Super valuable. Let’s understand things about the fees that we’re paying to exchanges or the positions that we keep in our different accounts.

Or the symbology.54Symbology — reference data about instruments: which tickers and codes (ISIN, CUSIP and others) a security goes by on different exchanges and with different data vendors. Mapping these identifiers onto each other is a hard problem in its own right.

Or the symbology.

Or the different symbols.

Yeah. Yeah. What markets does this stock trade on? What currency is it denominated and stuff like that.

And part of what gets surfaced here is part of the value here is database as ecosystem. The set of things that you can join together, like every new thing that you add to that increases the value of the platform. And the key thing about joining the data behavior is literally join, like SQL joins55Join — the SQL operation that combines rows of two tables on a shared field: for example, trades with the instrument reference table by ticker. or the essential data operation for bringing this data together.

And many companies, when faced with these problems with transactional databases, end up essentially getting rid of a lot of the flexibility and a lot of the usability of these systems in order to maintain the scale. They will have a schema council56Schema — the description of a database's structure: what tables it has, what columns and types they contain, how the tables relate. A schema council is a group whose approval is needed to change it. that before you’re allowed to add a table to the database, you have to have these people sit in judgment on you and find a schema. You’ll end up with databases where the only queries you’re allowed to run are ones that have been code reviewed.

And in fact, often what you’ll have is you’ll have code that sits in front of the database and you can’t just use the database directly. You go to the program that you type something into a GUI and it goes off and constructs the queries. And so you don’t have any kind of free rein in just running whatever queries that you want.

But we are getting huge value from traders, not just traders, but among other people, traders, being able to do more or less whatever they want on these databases. And we were putting in a ton of work on maintaining the database in such ways to give traders the illusion that they could do whatever they want. Don’t get me wrong, Postgres is a very good database, but there’s a lot of things that you can do once you have hundreds of users on a Postgres database that will slow down and kill the database for everyone. Long running transactions being the best example. So rather than just not let people run transactions on the shared database, we had a long running transaction killer that would go around and kill long running transactions if they got too long.

So can you say more about this? Why are long running transactions bad?

The way that Postgres does atomicity is essentially every time you have a transaction that writes to a table, it sort of forks the table and keeps it in two states, the state before your transaction and the state after your transaction. And then once you commit,57Commit — the moment a transaction is finalized and all its changes become permanent and visible to others. In Git the same word means a saved version of the code. it then has to do essentially almost like a version control merge.

So that on the face of it sounds insanely expensive. When you say forks the table, do you mean like makes a whole copy of the table?

That would be bad.

It’s all copy on write,58Copy-on-write — a technique in which data isn't copied up front: a shared piece is copied only at the moment someone tries to change it. right? So it only forks the pieces of the table that you touch.

So it’s both copy on write and it’s copy on write in a kind of segmented way.

Got it. Okay.

Then why is that bad? A nice analogy for this is like version control. When you use Git59Git — the distributed version control system Linus Torvalds wrote in 2005 for developing the Linux kernel. Work happens in branches, parallel versions of the code that are later merged into the main one. or whatever, you can have lots of forks and actually it’s like kind of okay to have lots of forks. You in fact have lots of long running forks and that doesn’t necessarily cause other things to fall apart. Why is it problematic to have these long running transactions in a database context?

The way the transaction semantics that databases give people aren’t like, okay, begin transaction starts a fork and you work in that fork and then later on you have to merge. So the way that the semantics of transactions in SQL and thus in Postgres is that while a transaction is in flight, it’s effectively locking all the rows that it’s changing. Not necessarily every row that it’s reading, but every row that it’s writing to, it gets effectively a lock.60Lock — a marker that one transaction is currently changing a row or table; everyone else who wants to change it waits until the lock is released. This is to stop merge hell61Merge hell — when parallel changes to the same data conflict and have to be untangled by hand, slowly, at merge time. Familiar to anyone who has gone too long without merging their Git branch. from happening when transactions commit, which turns out to not be what most people want out of their databases. So instead of letting you do whatever you want and then merging, we assume that if you’re touching something, you want to lock it until your transaction’s done and then the next person gets to run on that. But what that means is that long running transactions can accrue along a large amount of locks and a large amount of data that we don’t know if it’s the future or not. And this can end up effectively costing a lot of storage and a lot of compute time on the database for having to take this into account and do all the bookkeeping for this transaction while it’s open. Once a transaction gets closed, you just can very quickly garbage collect62Garbage collection — automatically freeing memory or space that nobody needs anymore. Here: deleting old row versions that no open transaction can see. all of the past stuff that happened before this transaction.

Is the main issue there that if you’re acquiring a bunch of locks that you’re basically running into issues of performance isolation,63Performance isolation — the property of a shared system in which one user's load doesn't slow down everyone else. like this long running transaction blocks other transactions from completing because maybe somebody else wanted to write to that –

And now they have to be pushed later in time. Yeah –

That’s certainly the brunt of the problem. There’s other ways that this interacts with replication,64Replication — copying a database's data to other servers to survive the failure of the primary or to spread out read load. In Postgres, replicas receive a stream of changes from the primary. for instance, and the ability to do what Postgres calls vacuuming,65VACUUM — the PostgreSQL operation that reclaims space taken up by obsolete row versions. Postgres doesn't overwrite a row when it changes but creates a new version of it (MVCC), and as long as a transaction that might see the old versions is open, they can't be removed. which is cleaning up old data in a table that where long running transactions make that hard too. But yeah, certainly this ability to have this chain of long running transactions is one of the things that makes this difficult for Postgres to manage performably.

Got it. Okay. So the state of the world is we have this incredibly valuable, not just a single database, but a set of databases that are being used in this kind of somewhat wild and undisciplined way where lots of people are pretty freely throwing in new kinds of data, throwing new SQL transactions at it and relatively routinely running into exciting performance problems, that you have a bunch of people who are doing a lot of operational work to try and keep this Frankenstein monstrosity running efficiently.

And just another big part of the problem is that Postgres very inherently has to keep all of your data on a single machine. So we had, I think at the time it was like the largest computer that Jane Street owned was running Trader DB.66Trader DB — Jane Street's biggest shared Postgres database, the one under discussion: traders and researchers put their data in it and ran queries against it. So yeah, so what are our requirements when we’re trying to replace the system? What are the things that we want out of the new system? Well, we still want it to be the Wild West. We still want people to feel like they can do anything. We absolutely want this to be able to store more data that you can fit on a computer. And ideally, we want this to be much more compressible and much better at doing sort of large reads over arbitrarily large amounts of data than Postgres.

Right. And essentially you want to move from something that is focused on transactions to things that are focused on big read queries that get lots of data and figure out the results of complex computations.

Exactly. And we also want it to be much harder for people to break isolation. We want it to be much harder for me to go and do some crazy thing on the system that will impact your ability to use it. Right. Both from a correctness perspective and also from a performance perspective. It should be much harder for a single user to bork the whole system for everyone.

Did you have problems? I would’ve thought you’d have lots of performance isolation problems in something like Postgres and very few correctness problems.

Well, you had deadlocks67Deadlock — when transactions wait on each other in a circle: the first holds a row the second needs, and the second holds a row the first needs. They can't untangle themselves; one has to be aborted. were sort of the main ways. Is a deadlock a performance problem? Well, in a sense.

It’s a very, very bad performance problem. Got it. And inherently when you’re grabbing lots of locks … Actually, how do you deal with deadlocks in the Postgres world? Does the whole thing lock?

So we had a deadlock detector, and if queries got deadlocked, we would just kill them.

Makes sense.

08What to give up: cross-table transactions and synchronous writes

Superstore gave up transactions across tables and synchronous writes but kept full guarantees within a single table.

So this is what we wanted. There’s no free lunch, right? As I said, we’re not going to just do Postgres, but better because we think Postgres is pretty good. So what can we give up? Well, it would be really nice if we could give up transactions.

Sure. Although transactions are really nice.

These transactions are really nice. Well –

It’s nice to be able to reason consistently about the data in your database.

It sure is. So what if we couldn’t … Is there a way that we could avoid giving up transactions entirely while still avoiding the kinds of problems that transactions caused on Postgres? So this ended up being a lot of the meat of what we tried to build when we were specing out our data warehouse. And we looked at a lot of the existing systems around this. A lot of them either give up transactions entirely. You have something like Kafka,68Apache Kafka — an open-source distributed platform for message streams, created at LinkedIn and open-sourced in 2011. Data is stored as ordered logs, called topics, split into partitions; order is guaranteed only within a partition. say, which Kafka isn’t a database. Yeah, I know you –

Don’t think of Kafka as a database.

But it is a system that stores a lot of data, right? For sure. And if you look at Kafka, it doesn’t have read-modify-write69Read-modify-write — an operation that reads a value, computes a new one and writes it back so that nobody can slip in between the read and the write: say, taking an item out of inventory. In Kafka you can only append new messages to the end of the log. and –

To the degree that it has any notion of consistency,70Consistency — the guarantee that everyone reading the data sees it in a coherent state: never half a transaction, never changes in the wrong order. it’s the ordering guarantees that are provided, and those are very narrowly scoped.

And there’s the amount of data that you could fit inside of a single partition of a single topic, that’s the scope over which you have well-defined ordering.

Yeah. Or you have something like Redis,71Redis — an in-memory key-value store created by Salvatore Sanfilippo in 2009, often used as a cache. for instance, which has no guarantees essentially across keys.

Okay. Yeah. Another way of limiting the scope.

Which is totally not good enough. If you’re trying to do some complex join across multiple tables where you need consistency across those things, it’s like you definitely need to cross keys.

Yeah. And so on the flip side, you have something like Vertica, which tries to provide full transactional semantics, but if you use it just right, you can make it efficient, which again, we still want this to be the Wild West. So we want something that you don’t need to use just right, and it’ll still work well. So what we ended up landing on is something in the middle. In particular, we wanted to make it possible to do consistent writes to a single table because this is something that comes up a lot is I want to have some log of a system’s behavior or going back to the list of all the trades that we do. You really want to not miss any trades. You really want to not double count any trades, but you don’t necessarily need to insert new trades transactionally with other pieces of data because either the trade happens or it doesn’t and you have some source of truth72Source of truth — the system whose data counts as authoritative: others keep copies and check against it when they disagree. for that. So you can always just pull in new trades from the source of truth to keep this up to date.

That’s right. And also to the degree that you’re making changes, most of the changes are appends.73Append — a change that adds new data at the end without touching the old. Data like this is much easier to handle: nothing has to be rewritten, and chunks that are already compressed stay as they are.

You’re mostly adding new data. And so a lot of the crosstable stuff that happens is like, it’s not quite consistent for free, but it’s mostly consistent in the sense that you might be missing data, but the data is mostly not being changed under your feet.

Yeah. So we wanted to have data that you could atomically write to a single table, you could get order preserving writes to a single table. You could essentially get all of the guarantees that you want for that table, but not between tables. Another key thing that we gave up, so one of the big problems with columnar databases is that rewriting stuff is really annoying because … So the way that columnar databases store their data is every column becomes its own separate stream of data. And the reason you do that is because a single column of data turns out to be extremely easy to compress and manage. The other reason you do this is because most queries don’t hit all the columns in a table, especially analytical queries. You have these very wide tables, and maybe a given query needs like seven out of a hundred columns, and you just get to ignore the other 93. And so this makes adding new columns to a table nearly free at query time, which is super cool. Sure. So given this layout, doing an update of a single row, something that is in Postgres, extremely easy and efficient, becomes very difficult because first of all, all these columns are their own separate things, and second of all, they’re all compressed. But again, we didn’t want to give up the ability to update and delete data because it turns out that being able to do that is really important.

Even though it’s by far not the ordinary thing, mostly you stream it in –

Sometimes, you get it wrong.

And you’d like to go and edit the table.

So we want to have these be able to happen, but we’re sort of okay with them being slow, as long as they don’t slow down other stuff that’s going on in the database. So what we decided to do, and this is kind of a weird decision, is we decided to make all writes in this database asynchronous.74Asynchronous write — the system acknowledges a write immediately and processes it later, in the background. The downside is that readers see new data with a delay. Now you write to this table and your write gets committed, which is the database says, yes, I acknowledge your write. This is going to go in in the correct order. This is going to go in atomically if you ask it to be atomic and so forth, but readers aren’t necessarily going to be able to see it just yet. And this lets us take the time in between when you do the write and when it becomes readable to make sure that the data that you’re writing gets readable efficiently, that we put it in the right place in the columnar data store, that we redo the compression if we have to do the compression and so forth and so on. And we’re much happier doing that neither when someone’s waiting for their read to complete, nor when someone’s waiting for their write to commit, but somewhere in the middle.

Right. And this is very different from doing updates to a database via SQL, where SQL is kind of part of the language and you’re kind of just mixing together the reads and the writes into one set of SQL expressions and they kind of all are supposed to operate in this kind of integrated way. And here you’re kind of breaking out the writes essentially as a totally separate API that has different semantics and where the kind of results of those writes happen asynchronously.

Exactly. And part of you will not see very many commercial or open source systems that make this decision just because, I think mostly because you have to educate your users every single time. But this is one of the cool things about being at Jane Street where all of our users are in house is we just get to tell them how it works and why. And we can even build the first few examples ourselves to give them examples of how this works really nicely. And also very importantly, we can have, even if SQL is like the first class read interface to this system, it doesn’t need to be the first class write interface. Because one thing that we noticed looking at Trader DB, for instance, is that even though a lot of the read queries were extremely ad hoc and just written by hand by a human being, most of the writes were happening in much better defined ways through actual software systems.

Right. And maybe this goes back to its role as an analytical database. The place where the innovation is happening is on the query side, on the read side. And there’s data loading. You got to do the data loading –

But the data loading is kind of done once per data source and that’s kind of that.

Often. Now we didn’t want to stop people from writing ad hoc data to the database if they wanted to. A very common case is like, I have this shared data that’s very big and important and I want to query it, but I want to join it with some other thing that nobody else has ever heard of. So you want to make it easy to upload your little join table to the database to join with the big existing table. We want to have ad hoc data. We don’t necessarily need to have that have full SQL semantics. You just upload the whole table at once. And if that’s fast enough, then if you want to change the analysis, re-upload it.

09Only through Superstore

Refusing direct access to the Parquet files is what gives Superstore access control and complete usage logs.

Got it. So you sort of avoid the whole writing an individual row by just not having that. Exactly. Not a thing in the system. So another thing that’s interesting about this system, it’s called Superstore, is that another thing that we … There’s various things that we have not given people who want it, who want it from it. In particular, just to say a little more about the underlying design, the underlying data is actually stored in Parquet files.75Apache Parquet — an open columnar file format created in 2013 by engineers at Twitter and Cloudera; the de facto standard for storing analytical data. Parquet is lovely open source format for storing columnar data. And a request that people have put out a lot, which has always been denied is like, oh, can I just access the Parquet files directly? You have all these nice parquet files distributed in this nice distributed system. Can I just go and read them directly and do something whatever I want to them? And the answer from the Superstore team has been no. I’m curious, why is that?

So in some sense, this seems like a very natural decision to make because if you look at, again, Postgres, can you just go and read the files on just that Postgres uses to store its tables? No, that would be crazy. You have a database for that. So if you think about it as like, well, we’re building a software system and offering it to the firm, it’s a very natural decision. But the funny thing is how little software that Jane Street develops actually works like that. People are very smart and good at programming and love looking under the hood and understanding what’s going on. And so once you tell them like, “Hey, this is a bunch of parquet files on a disk.” They’re like, “Oh, so I can read them, right?” So why don’t we let them read? Because we get to manage all of the reads and all of the writes, we get to build a lot of features that we can reason about. So one of the best examples is just access control. Sure. If we let people access our Parquet files on the disk, then we’d be stuck with Unix file system access controls76Unix permissions — the classic scheme in which a file has an owner and a group, and read, write and execute rights are set separately for the owner, the group and everyone else. For data sets with thousands of users it is far too coarse. because they were reading files off of a disk and we don’t have any code that’s running in between the disk and them. But in fact, since they’re reading them through our system, we get to build an access control layer and have ACLs77ACL (access control list) — a list of who can do what with an object: read, write, change permissions. and so forth for these data sets. Another thing that we can do is we can do usage logging. So this came out of a real problem with Trader DB and with other systems at Jane Street, which is they become nearly impossible to deprecate or to do schema evolution on. Imagine you have a table and a database and there are like 500 different people querying this database every day and you want to delete this table. Well, which of these 500 people are querying this table? How do you find out? I can go, maybe, okay, so I write down every SQL query that everyone is running and I grep for the name78Grep — a Unix utility that searches text for lines matching a pattern; programmers long ago turned it into a verb. of my table. Well, okay, maybe this works and I find and I grep and I don’t see any matches to my table. Well, except there’s a view that references my table79View — a saved SQL query that can be used like a table. A query against a view doesn't contain the name of the underlying table, so searching the query log won't find it. and now I have to grep for the view too. Well, maybe there’s a view on that view. So it ends up being very difficult to understand who is using this table and who’s not. And then even if you do understand it, why are they using it? And what data are they reading from it and how much … Maybe you can keep this data that you have, you only retain the last month instead of going back to all time. Can you do that efficiently? Who knows? So being able to have full read and write access logs to Superstore turned out to be very important. And to even just build a taxonomy of like, well, here’s the list of all of the data sets that people are storing in our system. Now again, Postgres has that, but this is a system that’s many orders of magnitude larger than Postgres. I guess this is another important thing to say is single computer databases only scale so far. If you want more than a few thousand tables, you’re going to need something that scales horizontally.

10Why not buy

Building its own beat buying: the cloud is expensive and far from the data, and open source doesn't understand finance workloads.

Right. And all of this is happening in the context of a huge explosion in the amount of data that we’re using and the kind of intensity we’re using that data and many different new use cases for all of this data. And somewhere along the way in the middle of this, a kind of revolution in the kind of machine learning driven approaches that we’re using also arrived and also put a lot more pressure on this system.

And it just turns out that once you have a system that’s able to query over many terabytes of data efficiently, you keep finding new use cases. And again, we were building this, this database we keep talking about is called Trader DB. We’re building this mostly for traders and researchers, but we keep finding use cases across the firm. Cybersecurity wants to have access logs for our network. Oh, why don’t you just put that in Superstore?

Tools and compilers wants to have access –

For all the history of the code review that people have done for all sorts of ad hoc queries that people want to do.

Right. Every build that’s ever run at Jane Street. And you just kind of put stuff in. And then from the trading side, you end up wanting a record of the thing that a trading system thought at the time that it made a given order is a very good example of a kind of data that has very high cardinality.80Cardinality — the number of distinct values. In high-cardinality data nearly every record is unique, which makes it hard to compress or roll up into aggregates. You want to write down rows like that across the firm like many billions of times a day. And we just couldn’t do that really, except that now we can. So you end up doing it a lot.

So one thing I wonder about this design is like, we sort of pointed a few different kinds of systems where there are kind of clear distinctions and approach, but data warehouses aren’t like a new idea. Lots of people have written data warehouses and there’s lots of commercial products for data warehouses. How did you think about the question of, should we just like, I don’t know, sign up for ye olde software-as-a-service81SaaS (software as a service) — a model in which the program runs on the vendor's servers and the customer uses it over the internet, paying a subscription or by consumption, with nothing installed in-house. data warehouse thing versus, “No, actually we’re going to go and design our own thing from scratch.”

So software as a service is a very interesting question here because really most of the data warehouses that are at the cutting edge in the world that we see are cloud software as a service offerings, Snowflake and Databricks82Snowflake and Databricks — the largest cloud platforms for storing and analyzing data. Snowflake was founded in 2012, Databricks in 2013 by the creators of Apache Spark; both charge based on the compute you consume. being kind of the two primary examples that it makes sense to point to. And these are perfectly good software. There are a few disadvantages there. One is they’re extremely expensive. And in particular, whenever I talk to people who work at companies that use these systems, they end up thinking very hard about what queries they want to run or not just because the cost of running a lot of queries in dollars is quite high and we just sort of don’t want to think about that. The other problem is that our data isn’t in the cloud. We have a lot of systems producing data and managing data on premises83On premises ("on-prem") — on the company's own hardware in its own data centers, rather than in the Amazon, Google or Microsoft cloud. and requiring people to copy all of their data to the cloud in order to run queries over them just seemed like not a great idea. Sure. But even still, once you’re on premises, there’s still many offerings. There’s commercial offerings, there’s open source offerings, so why don’t we just use one of those? Well, one of the things that we’ve learned, and really I say we, but this was really not me who was pushing this because I kind of came in here and I’m like, “Oh, Jane Street has so much not invented here syndrome.84Not-invented-here syndrome (NIH) — an organization's habit of rejecting ready-made outside solutions and building everything itself, even when that costs more (Wikipedia, "Not invented here"). We never use open source software. We just write everything from scratch.” Probably it’s because this Ron guy85Ron — Ron Minsky, the host of this podcast: he joined Jane Street in 2002 and persuaded the firm to write its software in OCaml. Jacob is teasing him on air. needs everyone write everything in OCaml.

That is a fair complaint.

But I do think, I guess now I’ve been here for long enough that I kind of see some of the method and the madness. In particular, the finance use case does not get very well understood by the open source community because we keep pretty quiet about exactly what we’re doing and why, because we think it’s a competitive advantage. Sure. And our competitors think the same thing. So you’ll have a lot of open source people who can spout off what’s sort of the tech company reason to use an analytical. Okay, people visit your website and record all their clicks and all their visits and sessions and stuff, and you need a big database for this because you have millions of people visiting your website. That’s a very well understood use case for data warehouses. And so a lot of the open source products are very good at solving that. I think very few people who are developing these systems can spout off some of the finance related use cases quite as well. And there’s just a huge advantage for us in being able to do the specific thing that we want to do very well. And because these systems aren’t necessarily built for these use cases from the top, we don’t have any particular reason to believe that they’re going to prioritize the things that we care the most about. Honestly, even in the ones that do think more about finance use cases, there are time series databases86Time series databases — databases for sequences of timestamped values: quotes, sensor readings, metrics. In finance the best known is kdb+ from KX, a columnar database popular with high-frequency traders (Wikipedia, "Kdb+"). where a lot of the people who are using them are finance companies, but Jane Street’s a weird finance company. So being able to just sort of go into our system and make this thing work is extremely valuable.

The exact choice of trade-offs is an enormously load bearing thing. And the fact that we get to make the choice of which of these features matters and which doesn’t and where can we give up on something and where are we going to demand that we really get really perfect. That’s just an extremely powerful place to be.

And we have use cases that if we were to share them with people building these pieces of software commercially, would just make them shudder and walk out of the room. And honestly, sometimes they make me shudder and walk out of the room. And one impulse that I’ve had to really stifle in myself is asking people who are using tools like Superstore are like, “Have you tried not doing that?” I ask it more than no times. It’s definitely good to push on people and see if there’s a better way for them to meet their use case and the first thing they have to have come up with, but you really want to not push back on the use case itself because our traders are very smart and they’ve thought very hard about what is the thing that they want to understand. So being able to say yes in many more cases than a vendor would perhaps say yes to us is a huge advantage.

11Trust and an eight-figure purchase

A newcomer got to replace central infrastructure thanks to a mentoring boss, trust between teams and a firm used to making bets.

So one thing I wonder about this story in general that you’re telling is that you kind of joined Jane Street and were kind of immediately plopped into a team and started to help lead a project that was to replace a pretty central piece of infrastructure that the day it falls over, it’s really bad, like a pretty important central piece. And here you are, like a person pretty new to the organization. And how did that all happen?

Well, so a lot of this is not on me. And I had many collaborators doing this. Many of them had been at Jane Street much longer than me. I talked briefly about Sam, who was my boss when I started at Jane Street. He was very much bought into this general project and did a lot of the work of giving me talking tos when I proposed something that just would not work at Jane Street or that is a bad idea for reasons that he understood and that I didn’t understand yet. And just sort of transmitting to me what are the things that make software valuable at Jane Street and why? And also doing a lot of the work with the prospective users of this system to explain to them what we’re building and why, and make sure that they were ready to use it once something existed. So these were both incredibly important. I was involved with them, but I don’t think that they worked, I don’t think I deserved the credit for them going well. I think really this involved a lot of very impressive organizational flexibility from across Jane Street. One kind of conversation that I had a lot that I found very impressive was I would go and talk to a team who we thought might one day want to use Superstore. This is before it existed. And they would say like, “Hmm, this seems pretty hard. Are you sure you’re going to be able to do it?” And we’d say like, “Well, we’re going to try really hard to do it. We’re going to prioritize this exact thing that you’re talking about working for the following reasons, but you just have to kind of trust us that we really think that this is achievable because we’ve run some tests and it seems to look good.” And they’d be like, “Okay, this sounds great. We will use it when it’s available.” And I was like, “Okay, wow. This was a very ego-free conversation with a lot of trust between teams and trust of me who had not particularly done anything at that point.” And once we did launch the thing, we got a lot of usage very quickly. I think in many ways it turned out to work quite well, which is nice, but people were willing to give it a try pretty easily and early on, which I think really helped contribute to the system’s success.

Yeah. Maybe there’s two key cultural things going on there. One is this kind of extension of grace, the trusting of someone else that’s trying to do things, something, and it seems like a reasonable thing to try and do. And I guess the other thing is just the willingness to make bets. It’s a trading firm. We make bets all the time. And the idea that some of the software projects we’re doing are also bets. And I think I’m fairly confident that the various people that you talked to who said, “Oh, this seems hard.” Some of them thought, “Yeah, this probably won’t work, but it’s okay. We’re allowed to make bets that there’s some risk and sometimes they work and sometimes they don’t.”

Well, and one of the fun conversations on that note that I got to have pretty early on in my tenure at Jane Street was buying the storage appliances that were going to back Superstore. So there’s a few questions here. One is when do you buy these? And the second one is how do you size them? Now this is in 2022 when supply chain dislocations from COVID87Supply chain dislocations — in 2020–2022 the COVID-19 pandemic disrupted manufacturing and logistics, and a global chip shortage stretched lead times for servers and components to months. were still going on and lead times were quite long.

Thank God there are no more supply chain dislocations.88No more dislocations — Ron is being ironic: in 2025–2026 demand from AI data centers set off a new shortage of memory and storage, and their prices shot up.

It’s all good now.

All fixed. So we didn’t have a running system yet, right? So we sat down with a relatively small group of people like, “Okay, well, what’s the right amount of storage for us to buy?” And I don’t know how, but we ended up landing on a number of 10 petabytes.89Petabyte — a thousand terabytes, or a million gigabytes. 10 petabytes is hundreds of the largest hard drives, not counting backups. I was like, “What, petabytes, really? That seems like pretty big.” And they’re like, “Yeah, but you don’t really want to go smaller than that.” Well, how much is this going to cost? And it was some eight figure amount of money. And I just, to be clear, I had just come from a startup where we had never seen an eight figure amount of money in the whole company’s existence.

And before that, you were at Google where they hadn’t seen a storage number as small as eight petabytes.

Right. But where decisions were made in a much larger and more centralized way. So the fact that a few people could get in the room and decide to write this check on the strength of a design doc90Design doc — a document written before development starts that lays out the problem, the architecture of the future system, the alternatives and the trade-offs, so colleagues can discuss them. was pretty … I mean, it made me nervous that day, I would say, but I think it’s also a very impressive thing to be able to do as a company of Jane Street’s size.

12The big regret: metadata on CockroachDB

Consensus in CockroachDB capped the commit rate to a single table, so Superstore's metadata is moving to Aria and its single sequencer.

So Superstore had a bunch of embedded bets in it of different design choices, different things it was trying to achieve. And on the whole, it has panned out very well. Are there any aspects of the initial approach or design or things you did that you kind of in retrospect think didn’t pan out particularly well, decisions that you kind of regret?

Yes. So I think the main decision that I regret from Superstore is the way that we handled the metadata. So in all of these columnar databases, the metadata ends up being a pretty key piece. Metadata being just like, what are the tables and what are the pointers to the data that’s currently in them?

And I guess also what are the permissions and who has access to what? Is that also part of the metadata?

In our case, no. But in many other systems, yes, permissions live in those metadata stores. Sure. So we thought, well, what do we want to use for the metadata store? This pretty clearly has to be some sort of distributed globally consistent storage system because you certainly don’t want your data to be consistent or not just you don’t want. It’s impossible to have a system where your data is consistent, but your metadata is not if the metadata is like the pointers to the data. Sure. It’s like, well, what should we use for this? We decided to use CockroachDB.91CockroachDB — a distributed SQL database from Cockroach Labs, founded in 2015 by former Google engineers and inspired by Google's Spanner. Data is split into ranges, and each range is replicated by its own Raft consensus group. It’s –

It’s like a well-known, well-regarded, open source-

Transactional data.

Transactional data, that’s right.

And again, you want the metadata store to be transactional because very often doing these transactional, even lightly transactional operations over the underlying data require transactional metadata operations.

Right. And you do a transaction every time you add a new chunk of data, you’re doing a transaction and it really looks more like the Postgres use case in that instead of operating on whole columns, you really are operating on rows of like, oh, there’s a new chunk of data and I want to register that chunk of data. And so the ordinary use case is like the dual.92The dual — a mathematical term: the dual problem is the mirror image of the original. Ron means that metadata is the other way around: small transactions on individual rows instead of large reads over columns. It’s the opposite thing here.

And in many ways, CockroachDB was a great fit, but it turned out that we’ve had more and more problems with it as we’ve been scaling. I think one of the key areas where we’ve been having problems with CockroachDB comes to write latency. So we have a lot of the data that’s in Superstore. I would say probably by bytes the majority of the data that’s in Superstore is data that comes in streaming. Some system is writing some stream of data and then we want to take that stream of data and materialize it93Materialize — turn a stream of events or a query into a ready table that can be read. The term comes from databases: a materialized view stores the already computed result of a query. as a Superstore table as fast as we can. As fast as we can is ideally within less than a second, which is like, again, for a trading system, not fast, but for analytical database pretty fast.

Right. They’re fast enough that you could build stuff for analyzing trading on the day and it would be fine, fast enough that you could build monitoring systems based on this, not fast enough that you would want your path from quote to order94Quote to order (tick-to-trade) — the time from market data arriving to an order going out to the exchange, the key measure of a trading system's speed. or something to go through the system.

And this particular style of access ends up being pretty bad for CockroachDB because every time you need to write to a row, you end up doing a transactional update, which for CockroachDB being distributed means like distributed consensus round. And CockroachDB gets its scale by just dividing all of the rows in the world into many different Paxos groups, or sorry, not Paxos, Raft,95Paxos and Raft — distributed consensus algorithms that let a group of servers agree on a value even if some of them fail. Paxos was proposed by Leslie Lamport (the paper was published in 1998), Raft by Diego Ongaro and John Ousterhout in 2014 as an easier-to-understand alternative. many different consensus groups that are independent of each other and like having a bunch of stuff on top of that to make that mutually consistent. But if you’re touching the same row over and over and over and over and over again, in effect, you’re serialized.96Serialized — here: the operations line up in a queue and run strictly one after another. They can't be parallelized, and throughput is capped by the length of one consensus round. There’s no way for them to do those transactions in parallel. And the wall time that a single consensus round takes ends up being quite high.

Got it. And just to unpack a little bit of the distributed systems terminology here, consensus is like the name for the algorithm that does the simplest like get a bunch of servers in different places to agree on anything. It could be a single bit.

Exactly. I don’t want to have there be a single computer that’s the only place that stores like what’s the latest data in this table because then if that computer gets unplugged, I can’t access my table. So what CockroachDB does and what many distributed systems do is they write this to a bunch of computers and then essentially they vote. If the majority of the computers agree on where the data is, then congratulations you get to write your table. And this gives you very nice fault tolerance guarantees. But the way that these computers have to exchange information ends up being a really limiting factor in the design of the system.

And just to be clear, you were saying that the bad thing is having to go to a single place over and over to make a decision, but actually if you just had to go to a single place over and over to make a decision, it would be fine.

Yeah. It turns out CPUs are pretty fast. CPUs are fast. They make a lot of decisions and it’s all of this network communications and distributed synchronization that ends up making this slow.

ExplainerConsensus on every commit, and a sequencer

CockroachDB splits all data into ranges, and each range is held by three (or more) replicas that agree using the Raft algorithm. A write counts as done once the group's leader has sent it to the other replicas and a majority have confirmed they've saved it to disk: at least one network round trip plus a disk write. Writes to different ranges go in parallel, so the system as a whole scales by adding machines.

But every commit to a Superstore table changes the same metadata row, for example the table's latest version number. Transactions that touch the same row have to queue up, each waiting for the previous one to get through its consensus round. However many machines you add, the commit rate to a single table is capped by the latency of that round.

In Aria the order is decided not by a vote but by a single process, the sequencer: it receives all transactions, numbers them and multicasts them to all participants, who apply them in order. The decision is made by one core with no network negotiation, which is why it's fast; durability comes from other components that record the stream, and if the sequencer dies, the system runs read-only until it fails over to a backup.

And one of the things we’re doing now is like ripping out all of the CockroachDB and replacing it with Aria.

And Aria97Aria — Jane Street's internal platform for systems built on state machine replication: all events pass through a single sequencer and go out to participants in the same order. It succeeded a system called Concord; Doug Patti covered it in depth in the April 2022 Signals and Threads episode "State Machine Replication, and Why You Should Care." signalsandthreads.com. is this very finance style state machine replication98State machine replication — an approach to fault tolerance: every copy of the system is a deterministic state machine, so if all copies receive the same input events in the same order, their states stay identical. system that basically shoves all of the data, it gets consistency by shoving all the data through a single core and you just distribute that data out by reliable ordered multicast99Multicast — network delivery in which the sender transmits a packet once and the network delivers it to all subscribed receivers at once. It's how exchanges send out market data. and it gets to all the people. And the thing that’s weird about the system from a kind of big systems person kind of perspective is there is a single point of failure,100Single point of failure — a component whose breakdown takes down the whole system. Distributed systems are usually designed to have none. which is the sequencer, the thing in the middle that gets all the transactions and brought –

There is a plug that if someone unplugs, the entire Aria system will go down. And once Superstore is built on Aria, there is a single plug that you can pull to disable an entire Superstore cluster.

Although it’s worth saying, it disables it in a kind of temporary way and that you can actually recover in that all of the information that goes through the sequencer is also replicated and captured by other components of the system.

Effectively, you’re in read-only mode for a while.

That’s right. And then there’s a careful, in the end involving some human intervention step to make sure the original sequencer is good and dead to flip over to a backup sequencer. So when it’s a single point of failure, you’re not totally dead, but you are paused in a way that’s not awesome. Although I think one of the points about this design that I think is interesting is it’s true that it’s not great to have single points of failure, but if you have a single single point of failure, it’s not as bad. A well-tended machine might experience a hardware failure once every four years in a well-cooled data center and all of that. And then what you’re really taking on in exchange for way higher performance is like, it will be down for a minute once every four years. And that’s not necessarily so bad.

And you have a background rate of outages. I’m not going to sit here and say, “Oh, Superstore never has outages. This is going to be our primary cause of outages.” No, we’re humans. We write bugs the same as anyone. And if you look at what causes system downtime, including for big tech systems that don’t have single points of failure, it turns out that it’s almost always caused by software bugs and not by the kinds of failures that people are designing against.

And anyway, so here, the point that you’re pointing to as a bit of regret is the core metadata system was basically architected with a kind of higher requirements, like made a bunch of trade-offs in favor of very high availability101Availability — the share of time a system is up and answering requests. By the CAP theorem, when the network splits, a distributed system has to choose between availability and consistency. that blocked you from having the kind of throughput you needed to really scale the system as far as we want to.

And throughput in this particular dimension, I think what we, the reasoning-

The query throughput is fine.

Query throughput is fine. Total commit throughput across all of our tables is fine. It turns out the thing that we can’t scale is just like the rate of commits to a single table. And I just don’t think that we fully appreciated how much of a blocker that would be when we were designing Superstore initially.

13The Hive: a cluster that can take down anything

The Hive has grown big enough to take down almost anything by accident, and improving it means understanding the whole stack its users build on top.

Got it. Okay. So let’s talk about the after Superstore world. So you no longer work on Superstore. What’s your day job today?

So today I work on Jane Street’s compute cluster, which is called the Hive.102The Hive — Jane Street's internal compute cluster; not to be confused with Apache Hive, the SQL query system on top of Hadoop. Jobs bid for CPU time. In the illustrated example, A offers $3 for an hour and B offers $2. A gets the hour and pays $2.$0$1$2$3A winsBpays $2 So the Hive is not like all of the computers at Jane Street, but it is sort of the place that you go to if you have a computation that needs to be done by a lot of computers at once. So examples of this include, for instance, training neural networks, but also things like analyzing many days worth of trading to understand what the patterns might be that we see there.

Or running large scale simulations where you take the actual code of our trading systems and run them in simulated mode,103Simulation on historical data (backtesting) — testing a trading system or strategy on past market data: how it would have traded had it been running then. like over large swaths of historical data.

Yes, exactly.

Right. And this system is actually like, I have a great fondness for it because it’s like one of the first … The early prototype of this thing is one of the first systems I worked on. The original version of the Hive was like six Dell boxes piled up on a card table and I think was like set up what we used to call a Beowulf cluster104Beowulf cluster — a cluster of ordinary inexpensive computers linked by a local network for parallel computing. Thomas Sterling and Donald Becker built the first one at NASA in 1994. A home-built Beowulf cluster, circa 2000: ordinary desktop PCs on shelving, linked by a local network.A home-built Beowulf cluster, circa 2000: ordinary desktop PCs on shelving, linked by a local network back in the day. It was like very simple and very primitive. And it’s a very different system now. First of all, then it was a very kind of simple and naive kind of scheduling story of like you would run one thing at a time, it would get the whole Hive, you’d have a master process, which is like go off and schedule jobs running on individual cores and gather the results together and write them down to a file. It was also just about CPUs. We didn’t do any GPU stuff back then. It was like more than 20 years ago. Things are dramatically different now. Can you maybe say a little bit more on what is the kind of use cases that are driving the work on the Hive today?

So there’s a ton of different use cases on the Hive, but if you look at where most of our growth is coming from, most of the growth in demand for Hive compute is coming from training neural networks and processing the feature data105Features — the inputs to a machine learning model: numbers describing each example. Preparing features from raw data often takes as much compute as the training itself. that we’re going to feed to these neural networks.

Right. Some of which ends up being on GPUs106GPU (graphics processing unit) — thousands of simple cores running the same operations in parallel. Built for graphics, GPUs are now what neural networks are trained on. CPU — the ordinary central processor. and some of which ends up being on CPUs.

Yeah. So the training itself for neural networks happens almost exclusively on GPUs, but a lot of the data production and the data analysis that go before and after the training runs happen on CPUs. Great. The Hive is we have hundreds of thousands of CPU cores and over 10,000 GPUs running on the Hive. And this is big enough that it’s become essentially a giant DoS machine.107DoS (denial of service) — an attack that floods a system with requests until it stops responding. Here it's figurative: the Hive is big enough to knock over any service it talks to by accident. You can point this many things at almost anything and make it go down. So one of the big challenges has been just scaling the underlying infrastructure that powers the Hive to make sure that it doesn’t rely on anything that it’s going to DoS, and that it can actually feed all of these computers efficiently. So what are some of the things that we’ve had to make sure that we can scale? So one of them is just storage. And all of these computers have to have their input somewhere and then also have their output somewhere. Sometimes this is Superstore, but in fact, some of the larger data sets on the Hive are too big for us to want to store them in Superstore. We just store them directly on a storage appliance or on a large object storage system.108Object storage — a system that stores data as whole objects by key, without a directory hierarchy or editing a file piece by piece, like Amazon S3. It scales well to enormous volumes. And it’s very easy to accidentally write code that makes these storage appliances fall over. So we’ve been working very hard to make sure that Hive jobs don’t bring down storage appliances.

Is that a problem you solve by making the Hive itself better or is it a problem you solve by isolating the Hive so that its queries don’t like reach out and smack some unsuspecting system on the head and knock it over?

So we have to do both. We definitely isolate the Hive in many ways and we make it much harder for Hive. We try and make it impossible for Hive jobs to accidentally interact with trading systems, which would be a big no-no. But even the stuff that the Hive is supposed to talk to, we want to make sure that the Hive talks to it gently enough that that thing doesn’t get taken down. A great example, we’re still using, for better or for worse, NFS109NFS (Network File System) — a protocol for accessing files over a network, developed by Sun Microsystems in 1984: a remote disk looks to programs like a local one. as the protocol by which Hive machines access much of their data. And NFS has some bizarre locking semantics around certain interactions, especially when it comes to things like listing directories and creating new files in a directory. A very easy way to bring down our storage appliances on the Hive is to create thousands of files in the same directory from different computers all at once at the same time.

Oh, interesting. Just because there’s a kind of consistency semantics on the directory itself.

Yeah. Pretty clearly, I think most people would realize that if you tried to write to the same file from 5,000 machines at the same time, that would go badly. But people don’t realize that creating a file in a directory is effectively writing to a file.

Right. It feels like it should be okay, right? It’s just like some kind of eventually consistent,110Eventual consistency — a weak guarantee in distributed systems: if no new changes come in, all copies will eventually reach the same state, but at any given moment different readers may see different things. eventually all the files that you added show up there would be fine, but like- That’s not how that works. That’s not how NFS works, right? Okay.

So obviously you shouldn’t do that. We put some checks in place like disabled jobs that we think are doing that, but then a big part of this is just building the interfaces to the Hive in such a way that people won’t do that. Rather than having people open files directly, we build frameworks that they can use that can manage their data in larger chunks.

So one thing that’s notable is that your experience coming to work on the Hive is sort of the opposite of your experience of coming to work on Superstore. You started working on Superstore when it didn’t exist. And then you got to ask the nice question of like, what are the APIs I would like to have people to have in order to use this system? And how can I pick just the right trade-offs and all of that? And in the Hive, you came up in a much worse position of a system that, the worst of all situations, I initially wrote and then has been used by lots of people and evolved a lot over time and is the beating heart of a lot of our research work. And you don’t have the freedom to just be like, “Ah, and here’s what all the APIs are going to be.” It’s already being used actively and all the time. So what do you do about that? How do you think about improving the system and changing the kind of trade-offs in a world where there’s already a ton of uses before you get to make any of those decisions?

It’s really hard, I think is the long and short of it. One of the things that I really try and do is I try and understand the full stack of code.111Stack — a set of software layers, each resting on the one below: here, from the Hive itself up to the libraries and research code written on top of it. One of the things that I found was happening a lot when I started on the Hive is that we were building features and then shipping the features and then nobody would use them. And so why was that? It’s because the people who the features were designed for were not actually using our APIs directly. They were using other systems that used our APIs in turn. So it’s not enough to design a feature that solves a problem. You have to design a feature in a way that solves a problem in concert with the other layers of our research stack.

And there’s like 20 years of people hacking away on these layers. So there’s like a lot there.

Exactly. So having that sort of full end-to-end understanding and actually interacting with researchers. In fact, the first thing that I did when I started on the Hive team was I didn’t work on the Hive at all. I sat on a trading desk112Trading desk — a group of traders who trade a particular asset class or strategy; once literally a shared desk. for a month using the Hive with them. I worked with these traders to take some of their code and rewrite it in a way that was sort of more maintainable and better integrated with the rest of the code base, but that involved a lot of using the Hive and changing the way that this code interacted with the Hive, which really gave me an appreciation for at least one of the ways that actual trading code interacted with the Hive. And my goal was to use that kind of insights to better align the way that we released our features with the ways that users were actually working.

14An auction for compute

A second-price auction can't express urgency, so Jacob wants bids to be utility curves over time rather than a single number.

So now you’ve had some experience going off and using it, an experience, seeing what’s going on in the team and making changes to the system. What do you think of as the problems that there are to solve? What are the important things to be done to make the Hive better fit for both what we’re doing today and the insane amount of compute we are bringing up over the next several years?

So bringing this all the way back to the beginning, one of the main challenges that the Hive has is a mechanism design challenge. So one of the things we have to do is we have to schedule different jobs. We have to decide what computers are going to run which people’s code. And sometimes more people are demanding Hive resources than we have resources to give. So we have to decide how to prioritize them. And being a trading firm, we do this using money. People bid in dollars per CPU hour113CPU hour — a unit of computing work: one processor core busy for one hour. Cloud providers count and sell GPU time the same way. or dollars per GPU hour for how much they want to run their code on the system and we run a second price auction. So this all sounds well and good, but in fact, the structure of the mechanism makes it very hard for people to say things that we want them to be able to tell us about how they want their code to run on the Hive.

Are you telling me you would like them to be able to express their true preferences about how valuable they think their job is?

Well, so the funny thing again is that it’s not so much about getting the exact dollar value, which they don’t know down to the cent how valuable their thing is. It’s about what is the structure of their preferences. And particularly the thing that we haven’t been doing a good job at modeling is urgency, right? Maybe this piece of work is worth $10,000 and this piece of work is worth $5,000, but the $5,000 work decays much faster. If I don’t do it this hour, it’s going to be worth $0. Whereas the $10,000 piece of work, if I don’t get to it until tomorrow, it’ll still be worth $10,000. That’s a very valuable piece of information when you’re trying to figure out what the computers should do right now.

Yeah. This is like a key insight that was not at all obvious to me, but as I’ve kind of heard people talk about the kind of scheduling problems on the Hive, just like makes a ton of sense, which is if you think about it in terms of utility curve,114Utility curve — here: how the value of a result to the user depends on when the job finishes. The derivative of this curve over time is urgency: the faster the curve drops, the more urgent the job. the thing that matters is the kind of derivative, right? It’s like, if your utility curve is flat, I would like to get this done, but it’s worth the same if it happens today or tomorrow, then while I’m not very urgent to get it scheduled right now, I’m kind of happy to wait. And if there’s free time on the Hive, happy to schedule it then, but it can also wait and other things that are more urgent can go first. And so this very simple thing of not a single dollar value, but a curve seems like a much better way of thinking about what’s going on.

Yeah. So assuming again that you give people good ways to specify this, and there’s a real API design problem for how do you not just make this thing of running a program on the Hive be an entire economics quiz?

Having everyone have full freedom in writing out their utility curve for every job sounds also like a nightmare.

Right. And plus you hope that they’re like convex.115Convex functions are a favorite class in optimization: they have no false local optima, and problems built on them can be solved with efficient algorithms. Jacob hopes utility curves will turn out to be just as convenient for the scheduler.

Sure. Right. Yeah. It would be weird if they went up in time.

Well, but sometimes they do, right? Think about a thing that runs every hour or every day that you want sort of a regular monitoring cadence. In that case, really your utility is how close you get to being exactly one day after the last thing and one day before the next thing. You’re probably fine with like a 20-hour gap and then a 28-hour gap, but like a four-hour gap and then a 44-hour gap sucks a lot.

Oh, so that means there’s like a peak around where you would like to get the job to run.

It’s not a convex utility curve.

But we in fact don’t –

We’re not modeling that.

Okay, good. Back to the-

We’re not modeling that. There’s a paper from CMU116CMU — Carnegie Mellon University in Pittsburgh, one of the world's leading centers of computer science research. The conversation doesn't say which paper. that talks about this. So you want to model this thing over time. This of course creates an NP hard scheduling problem.117NP-hard problem — a problem for which no algorithm is known that solves it exactly in polynomial time: as the size grows, the time to an exact solution explodes. In practice such problems are solved approximately. I mean, it’s already NP hard because we have these chunky jobs that need a certain number of GPUs in order to run. So that’s solving the knapsack problem.118Knapsack problem — a classic NP-hard combinatorial optimization problem: from a set of items of different weights and values, pick the most valuable ones that fit into a knapsack of limited capacity. Here the "items" are jobs that need a certain number of GPUs.

Gang scheduling119Gang scheduling — scheduling in which all the processes of one parallel job start at the same time, each on its own processor; if there aren't enough resources for the whole group, the job doesn't start. now you want a whole group. And this is because the GPU problems themselves, in fact, all of the original stuff that we scheduled on the Hive was this kind of like, you just have a bag of jobs,120Bag of tasks — a set of independent jobs that can run in any order on any machines. Such computations are called "embarrassingly parallel": they're the easiest to distribute. they’re all independent, they all just want to run, you want to get the result, that’s kind of that.

And this was before multi-core OCaml.121Multicore OCaml — running code in parallel on several cores arrived in OCaml only with version 5.0 in December 2022; before that, an OCaml program executed its code on a single core. They all used exactly one core. We really had an abstract problem.

And now we have, especially GPU jobs where they’re locked into a tight barrier synchronization122Barrier synchronization — a point at which all parallel processes wait for each other before moving on. In distributed neural network training the GPUs exchange results at every step, and one lagging or missing card stalls them all. thing and they are like, if you’re missing any GPU, you can’t do anything and you just kind of have to have this very tight scheduling.

So even solving the scheduling problem at a given time T involves a lot of sort of combinatorial work. As our GPU clusters get more advanced, we want to be topologically aware123Topology — how GPUs are connected to each other: cards inside one server are linked by fast interconnects like Nvidia's NVLink, while servers are linked by a slower network. It pays to place a job on cards that are close together. also. We want to make sure that people get scheduled on GPUs that have good connectivity to each other. And then of course, as our GPUs are now in multiple data centers, we have to pick which data centers things run in, which often means copying their data from where it lives to where the free computers are. So that also gets very challenging. Sure. But then on top of that, we want to add this time dimension, which just makes the problem much more complex. So we know that we’re not going to be solving this problem in an algorithmically perfect way, but we still think that the moves that we can do, like if you think about this as a local search problem,124Local search — a method for approximately solving hard optimization problems: take some solution and improve it with small changes ("moves") for as long as improvements can be found. There's no guarantee of the best answer, but it's fast. the moves that we can do to go from the schedule to a better schedule are valuable enough that it’s worth adding this extra dimension in the modeling.

Sure. Right. And what’s the key pathology in the original kind of just like where it’s going to have, everyone’s going to bid for right now, whether they can run and you just have them bid against each other and the highest bid wins. What’s the particular thing that goes wrong in that case?

So the particular thing that goes wrong is people end up paying much too much money to get their large jobs run and then feeling sad that they didn’t just wait until the night. Essentially, people sort of schedule Hive jobs for the future when they think the resources are going to be cheap because there’s no good way of them modeling their urgency in the bid.

Right. So the main issue is the auction happens when you propose the job and what you really want to do is give the system your job and be like, “Here are my preferences, run it at some point when it makes sense, given what I’ve told you about my preferences.”

And that’s the thing that’s missing.

Right. People end up doing their own work in their head or sometimes even writing little Python notebooks,125Notebook — an interactive document, usually in Jupyter, where code is split into cells and each cell's result shows right below it. A favorite tool of data researchers. modeling what they expect to be the future usage of the Hive to figure out when to submit their jobs.

And thus we have pushed a lot of complexity on the users.

15BitTorrent and a query engine for the Hive

Code for thousands of cores ships faster over BitTorrent, and optimizing Hive task graphs leads straight back to writing a query planner.

Okay. Okay. So that’s one thing that’s wrong. There’s like some problems in the basic scheduling … mechanism that don’t let us exercise the kind of intelligence we want to in terms of picking what jobs run when. What else is wrong with the system?

Well, another class of problems is that we are not very good at starting at running people’s work efficiently on a worker by worker basis.126Worker — a process or machine that takes jobs from a shared queue and runs them. So I want to run this thing on the Hive. Maybe I want to run a thousand different copies of the same process over a thousand different shards of my data.127Shard — a piece of a large data set that has been split up so the pieces can be processed in parallel on different machines. This means that the very first thing that the Hive has to do is get my code onto a thousand different cores. Okay. There’s a bunch of problems with this. One is, well, maybe my code is quite large and just literally physically copying the bytes is going to be an expensive thing to do. Another thing that’s a problem with this is, well, right now all of these bytes are located in one particular place and now I have a thousand different computers all trying to talk to the same one computer that happens to have these bytes. And that’s not going to necessarily go very well either. Yep. So it turns out the way to solve this is more or less with BitTorrent.128BitTorrent — a peer-to-peer file-sharing protocol created by Bram Cohen in 2001. A file is split into chunks, and every downloader simultaneously uploads the chunks it already has to others; the tit-for-tat rule gives more speed to those who upload more.

The same thing that we use to download copies of Red Hat Linux129Red Hat Linux — a Linux distribution from Red Hat, popular in the 1990s and early 2000s; later succeeded by Fedora and Red Hat Enterprise Linux. Installation disc images ran to hundreds of megabytes and were often shared over BitTorrent. back in the day.

Yeah. It’s built almost exactly for this problem of like, I want to have this data fan out130Fan-out — when data or messages from one source go out to many receivers at once. from this one place to many different places. The fundamental insight here is that think about the first person who successfully manages to get a chunk of your file. Well, now they can share that chunk with everyone else while taking load off of the place that the file originally was. So if you have your readers also be writers or your receivers also be transmitters of data, then you end up evening out the work distribution much more nicely across all of the machines that are trying to do work at once. And in this particular case of like a Hive worker that’s trying to start running a binary that it doesn’t have all of yet, that’s just wasted cores. So you might as well use those cores transmitting chunks of the executable to other machines.

It’s funny, BitTorrent is also like an exercise in mechanism design. And this is a problem that we don’t have, but the original BitTorrent design is designed for mutually distrustful people to share data. And one of the things that it wanted to do was incentivize people to be transmitters by giving them more download speed if they donated upload speed.

Which I guess is not actually a part of the thing that we have to worry about here.

No, we like to think that all of our … In fact, not only do we like to think that all of our employees are good actors for stuff like this, but also there’s no particular benefit to you in not transmitting while you receive, given that you’re just sort of wasting space out.

So the incentives are in fact perfectly well aligned.

Cool. What about the APIs that end users get? Those grew very organically. The initial APIs that we provided were like rock simple and not very scalable and not very expressive. And then people have built lots of stuff on the outside of those and kind of extending in all sorts of ways those original designs, but there wasn’t ever a, let’s stop and think about what the right API really should be. So what kind of problems does that create?

So one of the primary APIs that people use to access the Hive is essentially this computation graph API, where you build this sort of graph of tasks that have dependencies of data that are produced by other tasks and so forth and so on. And you end up developing this entire graph where you have your source data at one end of the graph and then like your computation result at the other end. And you tell the Hive, “Hey, run this stuff,” and it will do it in topological order131Topological order — an order of traversing a dependency graph in which each task comes after all the tasks it depends on. and so forth. So this is nice that we have this. One question you might ask is, are there optimizations you can do on this graph to make it faster to run? And well, hey, now you’re back to writing a query planner. In fact, one very common case of this is where your task graph is actually using a data frame library132Data frame — an in-memory table with named columns that a program handles as a single object: filtering, grouping, joining. The concept came from the R language and became the main tool for data analysis in Python. like Polars133Polars — an open-source data frame library written in Rust with a Python interface, started by Ritchie Vink in 2020; it supports lazy execution with query optimization. Pandas is the most widely used data frame library for Python, created by Wes McKinney in 2008. in each individual task. And then in fact, you can analyze the computation that Polars or a different library is doing and optimize not just how the computation graph is structured between the machines, but what computation gets done on each existing machine versus when the computations get distributed.

And the Polars story kind of brings us all the way back to SQL.

All the way back to SQL, a lot of the work that’s done on the Hive looks a lot like a big distributed query. Not all of it, God knows. I’m not going to say that GPU training is something we can write SQL for, but a lot of the work that’s done preparing data sets and analyzing data sets on the Hive looks much more like an SQL query than most code in the world.

And if you go look at the difference between Polars and Pandas, which are like Pandas being the standard dominant data frame library and Polars being this growing upstart, the big difference there is again, the shape of the APIs and Polars is like, rather Pandas is the eager mode thing.134Eager execution — every operation runs as soon as it's called. The opposite is lazy execution: operations are only recorded into a plan, and everything is computed at the end, when the whole query is visible. It’s just like you tell it what you want it to do and it immediately does it. And Polars does what’s called lazy execution, but really the way to think about it is the operations don’t really run the thing immediately. What they do is they build up the query piece by piece, and then you get the whole query and you can see the whole thing and the system can optimize it.

Exactly. And other distributed systems like Spark135Apache Spark — an open-source engine for distributed data processing, created at UC Berkeley in 2009; its authors later founded Databricks. end up having the same insight. Spark also looks a lot like a distributed query engine. So really we want to build sort of a distributed query engine style interface onto the Hive. And we’ve been taking a lot of steps in that direction.

So are you saying that the API that we want is literally Polars or do you think that something of that style is what you want?

ExplainerWhat a lazy query optimizes

Say you need prices for a few symbols on one day from a large Parquet file. In Pandas, read_parquet(...) followed by a filter and a column selection runs step by step, as written: first the whole file is read into memory, then almost all of it is thrown away. In Polars, scan_parquet(...) with the same operations only records a plan at first, and on collect() the optimizer rearranges the steps:

  • predicate pushdown: the date condition is applied right at read time, and parts of the file that can't contain that date aren't read at all;
  • projection pushdown: only the needed columns are read from disk, which the columnar format allows;
  • common subplans: if the same table is needed in two places in the query, it's computed once;
  • join ordering and expression simplification: the same things a SQL database's planner does.

Spark's Catalyst optimizer works the same way: to the engine a query is data that can be rewritten, not commands to execute immediately. A Hive job graph is the same kind of plan, and it can be optimized the same way.

I want Polars to be part of it. I don’t think … So Polars has a distributed product.136Distributed product — Polars Cloud, a paid service from the company founded by the library's author: it runs Polars queries in the cloud, including across several machines at once. I don’t think we are literally going to have people write a Polars LazyFrame,137LazyFrame — the Polars object for lazy execution: unlike an ordinary DataFrame, it holds not data but a query plan, which runs when you call collect(). and that is the way that you use this interface in the Hive. But my guess is that Polars will be in there somewhere, but you’ll also have other capabilities that map to some of, again, the Jane Street specific or the finance specific things that we care about where we sort of privilege things like operations over many dates or operations over different symbols, and we can do a better job because we understand our domain of making sure that things are, for instance, balanced across shards.

But the kind of key enabler is you want the computation to be run in a way that gives you a kind of graph of a computation that is like-

Exactly. You need some declarative138Declarative — describing what you want to get rather than how to get it step by step (the imperative style). The classic declarative language is SQL: how to execute a query is up to the planner. computation graph. And the more that we know about what exactly you’re trying to run over what exact data, the better we can do of scheduling this and making it efficient.

Awesome. All right. So that is the mission that you are currently on or part of the mission –

That you’re creating on. That’s definitely part of the mission that I’m currently on is how do we run these very large DAGs139DAG (directed acyclic graph) — in data processing systems, the usual way to describe a computation: the nodes are tasks and the edges are the dependencies between them. of computation efficiently and what’s more information that we can get about these computations that can help us do so?

Awesome. Okay. Well, maybe that’s a good place to stop. All right. Thanks so much.

Thank you, Ron. This is a lot of fun.

Chapters
  1. 1From mechanism design to Google ads
  2. 2DoubleClick and real-time bidding
  3. 3Lessons from Google: explainable mechanisms and contained state
  4. 4Parking signs and the road to Jane Street
  5. 5Why replace Postgres
  6. 6SQL, blessing and curse
  7. 7The Wild West on shared databases
  8. 8What to give up: cross-table transactions and synchronous writes
  9. 9Only through Superstore
  10. 10Why not buy
  11. 11Trust and an eight-figure purchase
  12. 12The big regret: metadata on CockroachDB
  13. 13The Hive: a cluster that can take down anything
  14. 14An auction for compute
  15. 15BitTorrent and a query engine for the Hive

Related episodes