But you can automate only so much, and the tough decisions still fall to the portfolio managers. When is the best time to buy an illiquid stock that trades only once or twice a day? How do you handle a corporate deal structured in an unusual way or the issuing of a new class of stock?

“People think a computer could run index funds­—and they’re so wrong,” says Brian Bruce, a former index fund manager who’s now chief executive officer of Hillcrest Asset Management in Plano, Texas, and editor-in-chief of the Journal of Index Investing.

The skills of an index fund’s human managers are underappreciated, Bruce says. While the top active fund managers are often treated like rock stars, index fund managers are basically anonymous.O’Reilly, 52, was a bit of a star himself as a young man. A native of Ireland who retains a subtle accent, he came to the U.S. in 1983 to attend Villanova University on a track scholarship. As a junior, he ran the mile in less than four minutes—a feat he repeated six times. He led Villanova to a conference championship and represented Ireland at the 1988 Summer Olympics in Seoul.

A few years later, O’Reilly joined Vanguard. He started managing the Vanguard Total Stock Market fund in 1994, when it had less than $1 billion in assets.

For a guy who oversees the better part of a trillion dollars, O’Reilly doesn’t put on many airs. He doesn’t have his own office. Instead, he works at a standing desk on Vanguard’s equity trading floor, which was renovated earlier this year in a somewhat utilitarian style. Vanguard doesn’t spend a lot of money on art or frills. “We don’t need fancy couches or stuff like that,” Brennan says. “We’re here to work.”

Working next to O’Reilly is Michael Buek, who’s managed the Vanguard S&P 500 Index Fund since 1991. Buek’s S&P fund now has $240 billion in assets. O’Reilly’s Total Stock Market fund, which is increasingly used in 401(k) plan target-date funds, passed Buek’s in size seven years ago. O’Reilly likes to needle Buek by reminding him of that.

Although Brexit was a minor event for O’Reilly and his colleagues, they were furiously busy a week earlier during the quarterly rebalancing of the Total Stock Market fund’s benchmark and other U.S. indexes.

When stocks undergo significant changes­—such as when a company is purchased—that gets reflected in the index at the end of a trading day. Minor changes, however, are bundled up and implemented once a quarter. At Vanguard, the quarterly rebalancing is an all-hands-on-deck affair, requiring the buying and selling of hundreds, sometimes thousands, of stocks.

On June 17 a team of 18 traders worked Vanguard’s U.S. portfolio. Pizza was served so staffers could stay at their desks as 4 p.m. approached. In index investing, the daily closing price is the crucial metric. For the most liquid stocks, such as those in the S&P 500, Vanguard buys and sells as close to 4 p.m. as possible to minimize tracking errors. Near the closing bell is also when volume is highest and Vanguard’s trades are least likely to move the market. For smaller, less liquid stocks­—some of which trade only a couple of times a day—the firm has to take care to avoid influencing their prices. It often buys these stocks earlier in the day, whenever traders see the best opportunity. “We don’t just blindly send” an order, O’Reilly says. “We screen to make sure our order won’t make too much of an impact on the price.”