37 TeraBytes in three weeks
In June 2026 a Codex user opened an issue on the openai/codex repository with a set of numbers that did not seem to belong together. The SQLite database in which Codex keeps its feedback logs, ~/.codex/logs_2.sqlite, took up about 1.2 GiB and held 506,149 rows, an unremarkable size for a log, and yet the counter that hands every new row its ID had already passed five and a half billion. Over roughly 21 days of uptime the main SSD of that machine had taken about 37 TB of writes, and the reporter's own process and file checks pointed at the Codex logs as the main continuous writer. When the reporter watched the database for 15 seconds, 36,211 new rows went in while the number of rows it kept stayed exactly where it was, because every insert at one end was matched by a deletion at the other.
I came across the story on November 2, when it was retold it on dev.to under the title "Codex Was Torching Your SSD and Nobody Noticed for Months," and what stayed with me was less the bug than the second half of that title. The bug had been reported in June and the issue closed in July, so by the time the article appeared it was old news to anyone following the repository. The months before the report were what unsettled me, because the drive is the one part of a laptop that wears out without making a sound, and I realized that I had no idea how many bytes my own Mac wrote on an ordinary day, let alone which program wrote them. Six days after the article appeared I tagged the first version of Disk-O-Meter, a small menu bar app that counts what gets written to each disk every day and names the processes that wrote it.
Figure 1. The chronology
Some argue that the wear on a drive is measured in bytes written rather than bytes stored, and that because nothing on a Mac puts the first of those figures in front of us day after day, a runaway writer can work away for months in plain sight. I will start with the mechanics of how a file that never grows can still wear out a drive, then turn to why the usual tools missed it, and from there to how Disk-O-Meter measures writes, how it finds the process responsible, how it raises an alarm, and where its numbers stop being trustworthy.
Why a small file can wear out a big drive
An SSD stores data in flash cells that survive only a limited number of erase-and-rewrite cycles, which is why manufacturers state a drive's endurance as a figure called TBW, terabytes-written, the total amount of data the computer may send to the drive before the maker stops promising that the cells will hold it.
The issue put the Codex numbers against that scale. At 37 TB in 21 days, a year of the same use comes to about 640 TB, which on a 1 TB drive means rewriting the whole drive some 640 times a year, and since some consumer drives are rated at around 600 TBW, the reporter concluded that such a pace could use up a drive's warranted endurance in less than a year. People were careful to call this extrapolation from one heavy user rather than a forecast for everyone, and I keep that caution here. The stakes on a Mac are, if anything, higher than on a desktop PC, because Apple doesn't publish endurance ratings for its SSDs, and in a MacBook the flash is soldered to the logic board, so worn-out storage is not a part anyone swaps on a Saturday afternoon.
Figure 2. The 37 TB measured in 21 days, carried forward at the same pace, reaches the 600 TBW rating of some 1 TB drives after about 11 months, which is arithmetic on one heavy user's machine rather than a forecast for anyone else's.
The harder question is how a file of 1.2 GiB can account for terabytes, and the answer lies in the way SQLite writes. A database in this mode first appends every change to a companion file, the write-ahead log or WAL, which here is logs_2.sqlite-wal, and only later folds those changes into the main file during a step called a checkpoint. Each new log row is therefore written at least twice, once into the WAL and once into its page of the database, and every index on the table has to be updated as well. Pruning the oldest rows to keep the file at a fixed size costs writes of its own, because the pages those rows lived on must be rewritten without them. The file stays the same size for the same reason that a bathtub with the tap running and the drain open holds a steady level of water, since the level tells you nothing about how much is flowing through it, and in the Codex case the flow was enormous.
Figure 3. Inserts and pruning both change pages, and every changed page is written once to the write-ahead log and again when a checkpoint copies it into the database file, which is how a file of fixed size keeps a drive busy.
What kept the tap open was a single default, which the issue identified in one line of Rust
Targets::new().with_default(Level::TRACE)
That line told the logging sink feeding the SQLite database to keep every message at the TRACE level from every source, including the libraries Codex depends on. TRACE is the most verbose level a program offers, meant for a developer who switches it on for a few minutes while chasing a bug, and the issue's samples show what it records when left on all day. A single message about a file named ld.so.cache being opened had been stored 128,764 times, the internals of the WebSocket library appeared line by line as it polled its connection, and TRACE messages alone made up 70.7 percent of the bytes the database still held.
Figure 4. TRACE messages made up 70.7 percent of what the log database still held, and INFO, much of it mirrored telemetry, made up most of the rest.
The size of the file, which is the one number anyone would think to check, was the one number that could not reveal the problem, and that observation points to a wider failure of the tools we use to look at our disks.
The hidden numbers
Almost every storage figure a Mac shows us answers the question of how much space is used. Finder's Get Info window, the Storage page in System Settings, and du in a terminal all report what is stored, and a log that sits at 1.2 GiB week after week gives each of them a reassuring answer. The quantity that wears out a drive is a flow, the number of bytes written per day, and no snapshot of what is stored can show a flow, just as a photograph of the bathtub cannot show how fast the tap is running.
Figure 5. The database held steady at about 1.2 GiB, which is all that Finder or du can show, while the drive beneath it took about 37 TB in 21 days, nearly 29,000 times the file's size
Tools that measure the flow do exist, but each of them has to be asked, and asked at the right moment.
- Activity Monitor's Disk tab ranks processes by bytes written, yet its figures start when each process launched and vanish when it quits, so they cannot tell you whether today was worse than last Tuesday.
- The
iostatcommand reads the kernel's disk counters and prints throughput, but only while someone sits watching it in a terminal. -
smartctlreads the drive's own lifetime counter, which is the most honest number of all, but a lifetime total moves so little between two glances that a bad month disappears into years of ordinary ones. None of these tools keeps a history by day, and none of them speaks up when something changes.
That draws the right lesson when it tells to "measure bytes written, not just disk space used," and it offers a checklist of these same tools for doing so. A checklist, though, helps only the person who already suspects something, and the whole difficulty of the Codex case was that nobody had a reason to suspect anything. What was missing was a measurement that a person sees without having to go looking, one that counts writes by the day, names the program behind them, sits somewhere always in view, and complains when a number crosses a line. Those four requirements became the design of Disk-O-Meter.
What Disk-O-Meter measures
The raw material already exists inside macOS. Every disk is managed by a driver object in the I/O Registry, the kernel's live catalog of the hardware attached to the machine, and each of those drivers, of the class IOBlockStorageDriver, carries two counters named Bytes (Read) and Bytes (Write) that add up every byte moved since the Mac booted. These are the counters iostat reads, and any user can read them without special privileges. The following command prints them directly.
ioreg -c IOBlockStorageDriver -r -k Statistics | grep -E 'Bytes \((Read|Write)\)'
Run it twice a minute apart and the write counter of the internal drive will have grown by exactly the amount written in that minute, which is the whole principle of the app in one experiment.
Those counters reset to zero at every boot, so the real work lies in turning them into a history that survives restarts. Every 15 seconds Disk-O-Meter samples them, adds the growth since the previous sample to the current day and hour, and saves a checkpoint that records the counter values together with the boot session ID the kernel assigns at startup. If the app quits and comes back within the same boot, the counters have kept running, so the next sample picks up everything since the checkpoint. After a reboot the new boot ID shows that the counters began again from zero, so their whole value counts as new, and an external disk that is unplugged and plugged back in gets a new driver entry that the app treats the same way. On Apple silicon the internal SSD appears as several NVMe namespaces, a main one plus small firmware and recovery containers, which the app adds up and counts as one disk, while each external drive keeps its own history, recognized by its serial number so that it follows the drive even when it returns under a different disk name.
Figure 6. Each sample adds the growth of the kernel's write counter to the current day and hour, and the saved checkpoint decides on the next sample whether to continue where counting left off or to treat the whole counter as new
What the user sees is a figure in the menu bar, by default the amount written to the internal SSD today, shown with three digits as in 27.9 GB so that the label keeps one width as the day goes on.
*Figure 7. Four forms of the menu bar label, drawn by the app from sample values, showing today's writes, today's reads and writes side by side, the current rate, and today's writes in red after a limit has been crossed
Clicking the label opens a popover whose Usage tab shows the totals for a day, a calendar week, a calendar month or a custom range of days, along with a per-day average and a chart of paired bars, blue for reads and red for writes, one pair per hour when the period is a single day and one pair per day for longer periods.
Figure 8. The Usage tab charting a single day hour by hour, with sample data from an ordinary working day in which the red bars sink overnight, whereas a steady writer like the Codex log would keep them high through the small hours as well
A log that stays at 1.2 GiB while the drive takes more than a terabyte and a half a day could not hide behind this display, because the label counts the water running through the bathtub rather than the level in it. Knowing that the drive is busy, however, answers only half of the question, and the other half is who is keeping it busy.
Catching the writer
The Processes tab answers that second question by keeping a ledger per program. Every 15 seconds the app reads each process's cumulative disk counters through proc_pid_rusage, a system call that reports how many bytes a process has read and written since it started, adds the growth since the last sample to today's total for that process name, and tells processes apart by their process ID together with their start time, so that a reused ID is not mistaken for an earlier program. The list then ranks every process that did any I/O in the chosen period, with the biggest writers first, a red bar for what each wrote above a blue bar for what it read, and a field at the top that narrows the list by name.
Figure 9. The Processes tab ranking a week of sample data by bytes written, including root daemons such as mds_stores and backupd that only the optional helper can see. A runaway agent would sit at the top of this list
Codex runs under the user's own account, and macOS lets a program read the counters of any process owned by the same user, which means that a Codex process writing at the pace described in the issue would have appeared at the top of this list from the first day, without any extra permission. I say "would have" deliberately, since I built the app after the fix had shipped and never watched the old Codex on a Mac of my own, but the mechanism requires nothing more than a long-running process owned by the user, and an agent left running for days fits that description exactly.
The heaviest writers on a Mac are often not the user's programs at all but system daemons running as root, such as Spotlight's mds_stores, Time Machine's backupd and softwareupdated, whose counters macOS hides from ordinary programs. For those the app offers an optional helper, a small daemon inside the app bundle that runs as root under launchd once the user approves it in System Settings and answers the app with every process's counters. It reads counters and writes nothing, and in the released builds it answers only a client signed by the same developer team, so another program cannot borrow it.
Even with the helper, the processes rarely add up to the disk total, because the kernel issues some writes on behalf of no particular process and because a program that starts and exits between two samples is never seen. The tab therefore ends with a row called Other / unattributed, the disk total minus the sum of the processes, and when that row grows large it becomes a clue in its own right. A tab, however informative, is still a tab that someone has to remember to open, which is exactly the habit the Codex story shows we lack.
An alarm or an audit?
Everything described so far still depends on someone looking, so the Settings tab accepts up to two write limits, each an amount that one disk may write in a calendar day, week or month, such as 50 GB a day on the internal SSD or 1 TB a month on an external backup disk. A bar beneath each limit shows how much of it the current period has used, and the Usage tab's Written tile shows the same share, as in 77% of 1 TB. The app checks the limits every 15 seconds, and once one is exceeded the share turns red, the menu bar label turns red until the period ends, and a notification reports it, once per limit and period.
Figure 10. The Settings tab with sample data, where a weekly limit of 9 GB on the internal SSD has been exceeded and turned red, while a monthly limit of 1 TB is still under a fifth used
The issue's figures show how much difference that makes, and the following is plain arithmetic on an average rather than a measurement of anything real. Thirty-seven terabytes over 21 days comes to about 1.76 TB a day, or roughly 20 MB written every second around the clock, and at that steady pace a 50 GB daily limit would be crossed about 40 minutes after midnight. Real writing comes in bursts rather than at an even rate, so the true moment would differ, but even a writer working at a tenth of that pace would break the same limit well before the end of the day. Some learned what had happened after three weeks and 37 TB, whereas a limit like this one would have turned the menu bar red on the first day.
*Figure 11. At the issue's average pace of about 20 MB/s, a 50 GB daily limit is crossed at 0:41, and even a writer working at a tenth of that pace crosses it before seven in the morning
The menu bar label can also show a rate instead of a daily total, measured over the last 15 seconds and written as 12.4 MB/s. A Mac left untouched writes something now and then, for its own housekeeping, but a label that never drops below twenty megabytes a second while its owner is away from the keyboard raises a question that a single click on the Processes tab will answer.
I can't tell you which limit to set, because I have no honest way to know what an ordinary day looks like on your machine. The sensible course is to let the app run for a week without limits, see what a normal day and a busy day write, and then set a daily limit comfortably above the busy one, so that the red label means something when it appears. An alarm is only as good as the number behind it, though, and that number has limits of its own that are worth stating plainly.
What a meter cannot tell you
The figures Disk-O-Meter reports are host writes, the bytes the Mac asked the drive to store, and they are not the same as the writes that actually land on the flash. Inside every SSD a controller moves data around to spread wear evenly and to reclaim blocks that hold deleted data, so it physically writes more than it was asked to, an effect called write amplification, and Apple's SSDs do not expose how large that factor is. TBW ratings are stated in host writes, which keeps a comparison with them meaningful, but how quickly a given Mac's flash actually wears depends on a multiplier that neither this app nor any other can see.
The counting has gaps as well. The app records I/O only while it runs, or earlier in the same boot, so it belongs among the login items, and its very first launch only takes a baseline from which counting begins. A crash or a forced power-off can lose the I/O since the last save, which is never more than five minutes old. On the Processes tab, a program that lives for less than 15 seconds goes unseen, and the per-process counters include writes to external disks, which is another reason the processes may not add up to the internal SSD's total. The app also runs only on macOS 26 or later.
The Codex story deserves the same care. The samples in the issue mention ld.so.cache and inotify, which belong to Linux, so the 37 TB were measured on a Linux machine, by one heavy user, and neither the reporter nor the dev.to article claims that every Codex user wrote anything like that much. The feedback log lives in ~/.codex on macOS too, and the default that filled it came from Codex itself, but I have no figure for how much any particular Mac wrote, and I would rather say so than borrow a number that doesn't belong to Macs.
Anyone who wants a check that doesn't depend on my code can read the drive's own lifetime counter with smartctl, which comes from Homebrew.
brew install smartmontools
smartctl -a disk0 | grep 'Data Units Written'
The counter is reported in units of 512,000 bytes, and its growth over a week, multiplied by that unit, should come close to what Disk-O-Meter reports as written to the internal SSD over the same week, since both count host writes. A large and lasting gap between the two would mean writes are happening while the app isn't running, which is itself worth knowing.
Where to get it?
Disk-O-Meter is free under the MIT License and is published as a signed and notarized DMG and ZIP in the Disk-O-Meter repository on GitHub. Whether you install it or simply open Activity Monitor's Disk tab tonight and sort by bytes written, the useful habit is the same, which is to look at how much your drive writes rather than how full it is.
Top comments (0)