Latest Posts (20 found)

To code well, avoid blunders

The secret to writing good code 1 is to avoid catastrophic mistakes. Many engineers think about programming as if the goal is to have brilliant insights, but they’re wrong. If you don’t blunder, you will win. Many other domains are like this. If you can play chess without ever hanging pieces, you will win against almost any 2 opponent. If you are very good at returning tennis balls, you will beat most players even if you never hit a winner. People are really bad at internalizing this. They think that being good at chess means finding brilliant tactical combinations, or that being good at tennis means crushing balls into the corner of the court, or that being a good programmer means discovering beautiful new abstractions. Not so! All of those things are valuable, but they are not the main thing. The main thing is to avoid catastrophic mistakes. The reason programming is like this is that it is impossible to build a durable winning advantage. In basketball, if you are up 99-1, the worst consequence of a blunder is still being up 99-4. However, in programming, one blunder can turn an elegant codebase into a janky one. For instance, consider these blunders: The cardinal sins here are inconsistency and introducing unnecessary requirements 3 . Even a little bit of inconsistency is dangerous because it breaks trust: instead of assuming your code works the sensible way, engineers must now go looking for surprises. Unnecessary requirements are dangerous for two reasons. First, they’re sticky . When you’re implementing a new requirement, you have the context to decide whether it’s necessary or not. If you see one in the codebase, you must assume it’s necessary unless you’re willing to spend a bunch of time researching. So requirements tend to remain in codebases long after they could be removed. Second, they often interrelate in dangerous ways: if your codebase supports X, then you must consider how each new feature will interact with X. This combinatorial explosion is what makes working in large codebases so hard 4 . When you’re writing code, you must at all costs try to: In fact, you should be so focused on this — on avoiding blunders — that you don’t really have mental energy to be worrying about cool tricks or “extra credit” features. As with shipping projects , if you find yourself thinking things like “oh, I could implement it with this clever pattern”, this is a warning sign: you are likely becoming distracted from the main thing, and you risk blundering. You don’t have to be clever to do great programming work. In fact, sometimes cleverness can be a disadvantage . What you need is attention to detail and a laser focus on what actually matters: avoiding blunders by maintaining consistency and skipping unnecessary requirements. As usual on this blog, I am primarily talking about working on large commercial codebases with big teams: “impure engineering” in my terminology. This advice may not apply if you’re doing other kinds of work . Of course all of this applies whether you’re writing code by hand or driving an AI agent. My guess (it’s surprisingly hard to research) is that not ever blundering would get you around a 1600 or 1700 chess rating: strong enough to win almost every game against casual players. Current coding agents are pretty good at consistency — about as good as humans — but are far worse at avoiding unnecessary requirements, unfortunately. I wrote about this in depth in Wicked features . Introducing a parallel system to perform the same task Introducing a second source of truth for some key piece of data Turning a safe sync operation into a delicate async one Adding new subtle points of failure Complicating a key interface Identify where your task could fit most normally into the current codebase Trim your task down into the smallest set of requirements that you can As usual on this blog, I am primarily talking about working on large commercial codebases with big teams: “impure engineering” in my terminology. This advice may not apply if you’re doing other kinds of work . Of course all of this applies whether you’re writing code by hand or driving an AI agent. ↩ My guess (it’s surprisingly hard to research) is that not ever blundering would get you around a 1600 or 1700 chess rating: strong enough to win almost every game against casual players. ↩ Current coding agents are pretty good at consistency — about as good as humans — but are far worse at avoiding unnecessary requirements, unfortunately. ↩ I wrote about this in depth in Wicked features . ↩

0 views

Notes on the discrete Fourier transform (DFT)

In the previous post on this topic , we’ve seen how the Discrete-Time Fourier Series (DTFS) and transform (DTFT) are used to analyze infinite-duration periodic and non-periodic discrete signals. Now, it’s time to turn to realistic digital signal processing where signals are not only discrete, but also finite in …

0 views
Chris Coyier Yesterday

YoloCam S7

Chris Enns shared in the ShopTalk Show Discord last month a review video for the YoloCam S7. It hit me at the right time, so I pulled the trigger. Here’s a short background. I was using my Canon 5D Mark IV with a 50mm prime lens . Kind of a lot of firepower for a webcam. I just had it around because, once in a while, I need to take some really high-quality photos or video. So I figured I’d put it to work on the daily instead of mostly gather dust. I liked the quality of the prime lens, but didn’t love the inability to zoom. I disliked not having my nice camera easily accessible to use for other things. I disliked that I had to pay a monthly fee to unlock 1080p video. I disliked that it required a special mock battery to be persistently plugged in. I disliked the weird HDMI cable it required. I really disliked having to stand up and reach behind my desk to hit the camera button to wake it up. Just enough to keep me from loving the setup. I had also used a Sony ZV1 in the past, which I bought just to be a webcam, and while it was nice quality, I ended up having gripes with it too, and ditched it when it started turning off at awkward times. What struck me about the ZV1 was essentially the price point. An obviously very high-quality device, with a high-but-not-crazy price point. I always thought there should be a webcam in this category that was actually designed to be a webcam, not a repurposed point-and-shoot. That’s exactly what the YoloCam S7 is, so when I saw the review, I thought I’d reward the company for doing exactly what I thought a company should do. The results? It’s mostly great! The quality is very good. I like how the camera body has almost nothing on it except a few ports. I like how the lens is swappable in case I wanna try something else. I like how it wakes up and works whenever I need it. The software has just enough control on it to be useful. I like the automatic face focus and reasonable zoom. There are a few little things I don’t like. I don’t like how you still need two cables coming out of it. They are both USB-C, but one is for power, and one is for connection 🤷‍♀️. I really dislike that the software can’t see the camera most of the time . When I open YoloLiv Compose, there is a 90% chance it can’t see the camera, even though other software that needs the camera uses it fine. I have to unplug it and plug it back in, and even then there’s only a 50% chance it works. When it does work, you can control what you need to, and it persists fine.

0 views
Unsung Yesterday

Testing tip: Set a keystroke to toggle between dark and light mode

The best way I found to make sure I test everything in dark and light modes was to assign a quick keyboard shortcut to it. I use a separate key on my extra keypad to do it… …but you can choose something your existing keys can handle that’s easy to press and remember, but rarely used – for example ⌃D. Setting it up in Shortcuts is relatively easy: = 2x) and (width >= 700px)" srcset="https://unsung.aresluna.org/_media/testing-tip-set-a-keystroke-to-toggle-between-dark-and-light-mode/2.2096w.avif" type="image/avif"> = 3x) or (width >= 700px)" srcset="https://unsung.aresluna.org/_media/testing-tip-set-a-keystroke-to-toggle-between-dark-and-light-mode/2.1600w.avif" type="image/avif"> But I prefer Keyboard Maestro , where it looks like this: = 2x) and (width >= 700px)" srcset="https://unsung.aresluna.org/_media/testing-tip-set-a-keystroke-to-toggle-between-dark-and-light-mode/3.2096w.avif" type="image/avif"> = 3x) or (width >= 700px)" srcset="https://unsung.aresluna.org/_media/testing-tip-set-a-keystroke-to-toggle-between-dark-and-light-mode/3.1600w.avif" type="image/avif"> You might say “isn’t this a one-click change in System Settings”? But in my experience the tax on that one click is heavy: you’ll have to navigate to the correct pane, which might be far away depending on where you left System Settings last, you definitely have to grab the mouse to do it… plus, System Settings these days is the kind of neighborhood you don’t drive into after dark: = 2x) and (width >= 700px)" srcset="https://unsung.aresluna.org/_media/testing-tip-set-a-keystroke-to-toggle-between-dark-and-light-mode/4.2096w.avif" type="image/avif"> = 3x) or (width >= 700px)" srcset="https://unsung.aresluna.org/_media/testing-tip-set-a-keystroke-to-toggle-between-dark-and-light-mode/4.1600w.avif" type="image/avif"> This way something that feels “one-click” amasses enough friction so that I would only do it when I really had to. With my setup, I am using it constantly without thinking about it, and get a lot more testing done. If keystrokes aren’t your thing, you can also try putting it in the menu bar somehow, although I could not get this to work in Shortcuts, despite promises. If you like this idea, I also have a few sibling shortcuts for similar things: toggling my display between retina and non-retina (non-retina screens are increasingly rare, but there are also some instances where thin retina lines completely disappear on non-retina screens, and that has some overlap with supporting zoom levels well, too): toggling the “reduce transparency” accessibility option – necessary as macOS Golden Gate has a bug where some screenshots look very dirty without it: I also have “no JavaScript,” “slow connection,” and “no internet” keystrokes specifically for developing in the browser. But that’s a whole other story.

0 views

New Notation for Abstract Scales

HA HA HA I SNUCK OUT AND DID SOME MUSIC!!! (after some encouragement from my wife!) Anyway, just a quick little update on some new notation I’ve been working on. Hopefully this will more clearly elucidate the points I’m trying to make with these abstract scales and generalized accidentals . Here’s what the new notation looks like: This is a 3-octave run in a 4-note scale. How can you tell it’s in a 4-note scale? Because the clef is a big “4”. In the first bar, we have an ottava bracket, which means we ought to read this bar to be one octave lower than it’s notated. The second bar is missing this bracket, and is therefore one octave up. And the third bar is an octave higher again. As a couple of landmarks: the bottom staff line is always a “root” or a “tonic” in this scale. That’s why both the first and second bars start on the bottom staff line. There is always a second octave notated, as indicated by the line straddled by the symbol in the clef. If you look, this line is where the third measure starts. What exactly does this scale “sound” like, you might be wondering? It doesn’t sound like anything; it’s just twelve steps in some arbitrary 4-note scale. We’d have to pin down exactly what that scale was in order to be able to realize it into something audible. Let’s take another example. This next one is a 5-octave run in a 3-note scale: The conventions are exactly the same here. Each measure spans an octave, and each measure is an octave above the previous one. The bottom staff line is still the tonic, but here, the second staff space is the one straddled by the . Again, this acts as a little landmark for where the next octave lands. Notice that bar 3 begins on this space. The only other thing to notice here is we have a +6 ottava in the last two bars. This is indicate it’s two octaves above what’s notated. It’s +6 because we’re two octaves above in a 3-note scale, and you shouldn’t be surprised to learn that . Let’s take this same 5-octave in a 3-note scale and transform it into a 7-note scale. The way we’re going to do that is via this mapping: Here you should read is the root of the scale, as the next note above that, as the next note again, etc. In our 3-note scale, we only have three notes, so giving a mapping for each of , , and is sufficient to map every pitch class out of the scale. Here we’re mapping to every other note in a 7-note scale, which when you look at it, is exactly how we build diatonic triads. Take every second note in the 7-note scale, and that gives you a triad! So when we apply this mapping over our 3-note scale example, we end up with arpeggiation of a triad over 5 octaves: Technically this is an abstract 7-note scale, but we can choose to interpret it as the usual diatonic scale. As a matter of convention, we will map the tonic of our abstract 7-note to C in the diatonic scale. This brings us back to everyday musical notation that should be familiar to practitioners: Notice that this diagram carries exactly the same information as the previous one, so it can be useful as a sort-of Rosetta Stone to help get an intuition for what the abstract notation is trying to articulate. So that’s a quick little primer on the notation. But now let’s try something a little more musical. We can bring in the same motif that we used previously : You’ll notice the familiar “abstract 3 clef”. The only new thing in this example are the accidentals. Unlike in a previous post, they are now using standard sharps/flats/natural symbols. But they also have little subscripts — the third note has a subscript 7 and the fourth note has a subscript 12. These subscripts express which scale we want to apply the accidental to. The means “move up one scale degree in a 7-note (diatonic) scale”. The “b/12” means “move down one scale degree in a 12-note (chromatic) scale.” We’ll expand this out momentarily to get some intuition as to what this means musically. Let’s repeat the motif 3 times, each time up a single scale degree: Using the same mapping as before, we can move this repeated motif into an abstract 7-note scale: There are two things to notice here. The first is that this thing looks much less like an arpeggiation than our first example. And the second is that the s are gone! These two facts are related to one another. Recall that was notation for “move up one note in a 7-note scale”. And so now that we’re in a 7-note scale, we can drop the notation and just move up one note. But since we haven’t yet moved into a 12-note scale, we can’t do the same procedure to the s, and so those accidentals remain. Let’s now reinterpret this abstract 7-note scale as the usual diatonic scale: which again should be familiar ground to musicians. You’ll notice that the have been replaced by simple flats, because standard music notation actually expresses the diatonic scale, and uses accidentals to express chromatic moves. Check out this music we’ve composed! What was once a very simple pattern in now has some character! Of course, nobody says we need to interpret our 3-note scale as triads . We could instead take our same repeated motif and map it into a 5-note scale. To pick a mapping at random, let’s go with: Applying this mapping gives us the “same motif” but now in a 5-note scale: We can interpret this 5-note scale as a major pentatonic, which then gives us Or we could interpret it as the minor pentatonic: We keep using that same 3-note scale motif, but we keep getting different results because we keep taking it through different paths on its way up to the diatonic scale. Let’s try another trick. Let’s take our repeated motif and this time map it into a 4-note scale. So far all of our transformations have preserved octave relationships (that is to say, if two notes are one octave apart before we map them, they are one octave apart after we map them.) But music is supposed to be free, man. There are no rules here. So let’s just reinterpret the motif as a 4-note scale: Now instead of giving a constant mapping from our 4-note scale into something playable, let’s instead give a dynamic mapping. For example, here’s a nice chord progression: You’ll notice that each of these chords has four notes. And we have a motif that is in a 4-note scale… so what if we to map our motif to the notes of the progression? The details here are pretty finicky, so I’ve notated this one as a grand staff. The first system is the chord progression, the second is the 4-note scale motif. The third system is the chord tones that get targeted by each note in the motif, and the final system is after we have applied all the accidentals from the motif to the targeted chord tones. Remember that the bottom line on the 4-note staff represents the “tonic” note, which is the lowest note of each chord. So because the first note of the motif is on the tonic, and the lowest note of the first chord is F, the resulting note is F. The note in our motif is just the next 4-note above the tonic, which is the second note in our chord, thus we get an Ab. But the third note of the motif is a above the second note in the chord. So since the second note in our chord is Ab (third system), one diatonic step above that is Bb (fourth system). The fourth note of the motif is a below the next note in the chord. The next note of the chord is C, so we lower it by a flat and get Cb. And then the last note of the motif is just the same note of the chord, but this time without the flat — thus C. That’s the derivation of the first bar. So far, so good. The second bar makes things a little trickier. This time the motif starts on the first space, which is to say it begins on the second note up the chord. Since the motif only touches three notes of the chord, in the second bar we will be ignoring the root note of the chord (the low F). It’s worth tracing through the details on this example. It’s finicky, but really makes you appreciate why we might want to use computers to calculate this stuff on our behalf. As one final step, we might want to take the last system of our derivation and “renormalize” it — changing the spelling of the notes so they feel a little more natural: Whew! We made it to the end! If you’re been paying attention to the whole series of blog posts, there’s nothing new here, but perhaps having a few more worked examples might help some of the ideas land. And again, none of these are my ideas — they all come from Tonality . What is mine is the notation, which I think can help with understanding. Of course, you’d never actually want to do any of these transformations by hand, but seeing them illustrated in full might perhaps pull back the curtains on composition. Perhaps what set apart the great composers of yore was not their musical genius, but their patience to work through the details of all these fiddly transformations.

0 views
Unsung Yesterday

“Duh, I thought everyone already knew this.”

One of the leaders in the popular game Civilization was Gandhi: = 2x) and (width >= 700px)" srcset="https://unsung.aresluna.org/_media/duh-i-thought-everyone-already-knew-this/1.2096w.avif" type="image/avif"> = 3x) or (width >= 700px)" srcset="https://unsung.aresluna.org/_media/duh-i-thought-everyone-already-knew-this/1.1600w.avif" type="image/avif"> But there was a problem with how Gandhi was set up, as described in the book Sid Meier’s Memoir! by the game’s creator: […] all of the leaders were given a score from 1 to 12 across a number of variables, and Gandhi’s military aggressiveness was placed at 1, as would be expected. A different piece of code, however, called for an automatic two-point drop in military aggressiveness whenever a country adopted democracy, which would theoretically have put Gandhi at a score of negative 1. But since negative numbers were impossible in this type of calculation, an overflow error caused the value to wrap around to the top of the number list, giving him a score of 255. Thus, the moment India became democratic, Gandhi would turn into a vicious warmonger and begin nuking everyone in range. A revision was quickly sent out, but players were so charmed by the hilarious juxtaposition that it became a running joke that has been thoroughly enjoyed and built upon by fans ever since. Images of Gandhi with captions like, “First they ignore you, then they laugh at you, then they fight you, then you cleanse them in atomic fire,” and “A nuke for a nuke will make the whole world bow down to me” have been shared far and wide. Other memes needed no words at all, like the photoshopped picture of Gandhi riding the falling bomb at the end of Dr. Strangelove. = 2x) and (width >= 700px)" srcset="https://unsung.aresluna.org/_media/duh-i-thought-everyone-already-knew-this/2.2096w.avif" type="image/avif"> = 3x) or (width >= 700px)" srcset="https://unsung.aresluna.org/_media/duh-i-thought-everyone-already-knew-this/2.1600w.avif" type="image/avif"> It’s a fun story and the 1 to 0 to 255 transition feels plausible, especially in the world still remembering Y2K. Here’s the kicker, though: But it’s not the countless callbacks and references that make the nuclear Gandhi story so funny to me. It’s the fact that none of it is true. The overflow error never happened at all. It is true that Gandhi would—eventually—use nukes when India was at war, just like any civilization in the game, and at the time this did strike a lot of players as odd. The real Abraham Lincoln probably wouldn’t have nuked anyone either, but the idea was that every leader draws a line in the sand somewhere. It’s also true that Gandhi would frequently threaten the player, because one of his primary traits was to avoid war, and deterrence through mutually assured destruction was an effective way to go about that. Since all leaders used the same basic diplomacy script, Gandhi’s reminder that “Our words are backed with nuclear weapons!” was identical to Napoleon’s or anyone else’s, and perhaps came off as a bit of a non sequitur from the humble ascetic. […] But at no point did a democratic score change, or any value approaching 255, come into it. That kind of bug comes from something called unsigned characters, which are not the default in the C programming language, and not something I used for the leader traits. Brian Reynolds wrote Civ II in C++, and he didn’t use them, either. We received no complaints about a Gandhi bug when either game came out, nor did we send out any revisions for one. Gandhi’s military aggressiveness score remained at 1 throughout the game. Meier seems to be annoyed by this, and does thorough investigative work in the book: Where, then, did it come from? The first reference appeared in July 2012—two years after Jon’s game, and more than two decades after the original game’s release—when a user named “Tunafish” added the supposed trivia to the website TVTropes.org, which can be edited by anyone. It sat, untouched except for cosmetic changes, until November of that year, when a watered-down version of the same story was added by an anonymous user to Wikia, […] Six weeks later, the spread began. First, two well-established users of a gaming forum repeated the story, with one of them citing the Wikia page after someone asked for a source. A few posts trickled out to other small forums over the next few days, again meeting only a single expression of skepticism, which was this time refuted with the TVTropes link. Things percolated gently for the next year and a half […]. The big break came in October 2014, when a comic called “Real Life Gandhi vs. Civilization Gandhi” was re-posted on Reddit. The comic itself was several years old, and only generically highlighted the humor of putting Gandhi’s finger on the button at all, but in the comments that followed, half a dozen users chimed in to share the story they’d heard about the overflow error. With that many in agreement, it became truth. = 2x) and (width >= 700px)" srcset="https://unsung.aresluna.org/_media/duh-i-thought-everyone-already-knew-this/3.2096w.avif" type="image/avif"> = 3x) or (width >= 700px)" srcset="https://unsung.aresluna.org/_media/duh-i-thought-everyone-already-knew-this/3.1600w.avif" type="image/avif"> Then, it was Kotaku, and Geek Dot Com, and eventually a popular website Know Your Meme that listed the bug as “confirmed.” Then: Six months after that, it was presented as a real-world example of an overflow error in the curriculum of a computer science class at Harvard University. Today, the story is still being revived on major news sites and message boards on a regular basis […] and almost always triggers at least a few replies of, “Duh, I thought everyone already knew this.” We talked recently about how makers of a mellow Japanese game were a bit perplexed by a bug in the game becoming an urban legend . We also covered some games that leaned into their bugs in their sequels . In the case of Civilization, the creators eventually leaned into… the bug that wasn’t. The lead designer of Civilization V, Jon Shafer, in the words of one Wikipedia editor “made Gandhi a nuclear weapon enthusiast.” The game was set up so that Gandhi’s internal “Build Nuke” and “Use Nuke” would always be maxxed out at 10 out of 10. As you can imagine, this did not help in squashing the myth. I’ll finish by quoting Wikipedia’s “Legacy” section: Despite its non-existence, “Nuclear Gandhi” is one of the most recognizable bugs in the history of video games. It has spawned a large number of Internet memes , and it has been used as an example of integer underflow in computer science courses at Harvard University , among others. The identity of “Tunafish” remains a mystery.

0 views

Embassytown

Avice Benner Cho has lately returned to Embassytown after spending years in the immer. As a child, she performed in a ceremony with the planet’s strange alien hosts, the Ariekene, becoming a simile in their Language, so that she returns a minor celebrity. Now, the town is soon to receive a new human Ambassador: two humans, or one human doubled, designed and trained to speak Language. But something has gone very wrong. In the chaos and war that follows, Avice and her human and alien counterparts must fight not only with weapons but with words, and with the very substance of Language itself. “We tell the truth best by becoming lies,” she learns. View this post on the web , reply via email , or become a supporter .

0 views

Probabilistic data structures in Go, part 2

Probabilistic data structures give you approximate answers to questions about the data they handle. Does the set contain a certain item? How many unique items are in the collection? What is the 99th percentile in a stream of numbers? How similar are two sets? Unlike deterministic structures, the answers might not be exact, but in return, you can save a lot of memory. Previously, we reviewed the following data structures : Bloom filter (for checking if an item is in a set), Count-min sketch (for counting items), HyperLogLog (for counting unique items), T-digest (for finding quantiles), and Top-k (for finding the most frequent items). In this post, we'll talk about other probabilistic structures and compare them to the ones we've already covered. We'll look at how they work and what kinds of guarantees they provide. All examples use unsure — a package that implements these structures in Go. Binary fuse filter • UltraLogLog • Log-linear histogram • MinHash A binary fuse filter is a set that trades certainty for space, like a Bloom filter 1 . It can tell you that an item is definitely not in the set, or that it probably is (which might be a false positive). The filter doesn't store the items, so it's much more compact than a regular set. Unlike a Bloom filter, a binary fuse filter is static: you build it once from all the items, and you can't add more later. In exchange, it uses less memory than a Bloom filter with the same false positive rate. For example, a fuse filter for 1,000,000 items with a 0.39% false positive rate takes 1.13 MB (9 bits per item), while a Bloom filter takes 1.51 MB (12 bits per item). This makes binary fuse filters a good fit for data that is written once and read many times, like the key set of an immutable file in a database (to skip files that don't have the key), or a list of known bad items, such as leaked passwords or malicious URLs. The fingerprint type ( in ) determines the false positive rate and the memory use: The constructor takes an iterator of items to add to the filter and the expected number of items (0 if unknown). The number is only used to preallocate memory, so a good estimate makes the build faster. You can check if an item is in the filter, but you cannot add or delete an item, count the number of items, or iterate over them. The filter 2 is an array of b -bit fingerprints (for example, b = 8 for ). Each item is hashed to a 64-bit value h , which gives the item's fingerprint f (b bits computed from h) and three positions in the array (cells). The array is filled so that for every item, the XOR of its cells equals f. To check an item, you compute h, look up its three cells, and compare their XOR with f. For an item in the set, they always match. For any other item, the XOR is a random b-bit value, which matches f with probability 2^-b. Each check reads three cells, so for large filters it's three cache misses, against one for a blocked Bloom filter. However, since the reads are independent, the CPU can do them concurrently, so the checks are about as fast as with a Bloom filter. The filter uses the local wyhash 3 implementation for hashing. It performs roughly the same as xxh3 4 but has a much simpler implementation, without SIMD or assembly. Here's an excerpt from the full benchmarks 5 , comparing unsure to xorfilter 6 (binary fuse by the authors of the paper) and bloom ( unsure 's own Bloom filter) with 8-bit fingerprints (ns/op, lower is better): Memory, bits per item (lower is better): Unsure is the same size as xorfilter (same layout) with up to 25% faster checks. Compared to the Bloom filter, it uses up to 36% less memory, with checks as fast or faster, but up to 2.5× slower builds. Bloom filter overview and how it works.  ↩︎ Binary Fuse Filters paper by Thomas Mueller Graf and Daniel Lemire, 2022.  ↩︎ Reference wyhash implementation by Wang Yi.  ↩︎ Reference xxHash implementation by Yann Collet.  ↩︎ Binary fuse filter benchmarks .  ↩︎ FastFilter/xorfilter by Daniel Lemire.  ↩︎ UltraLogLog is a unique items counter that trades accuracy for space, like HyperLogLog 7 . It tells you approximately how many distinct items it has seen, no matter how many times each one appeared. UltraLogLog doesn't store the items, so it's much more compact than a regular set. UltraLogLog is a newer design (Otmar Ertl, 2024) that uses the space more efficiently: for the same error, it needs about 43% less memory than HyperLogLog. For example, a HyperLogLog sketch with 0.81% standard error takes 16 KB, while an UltraLogLog sketch with 0.86% error takes 8 KB. However, adding, counting, and merging are slower than with HyperLogLog. UltraLogLog is useful in the same places as HyperLogLog: counting unique visitors, unique search queries, or distinct values in a database column, possibly across many machines or segments. You can merge sketches to get the total number of unique items from all of them, without counting shared items twice. The sketch has one setting: the precision p , which gives a relative standard error of 0.782/√(2^p). The default is p=13 with 0.86% error in 8 KB, close to the common HyperLogLog default (0.81% in 16 KB). You can add items to a sketch, get the estimated count, and merge sketches. You cannot check if a specific item was added, remove items, or list them. HyperLogLog hashes each item and uses the first p bits of the hash to pick one of m = 2^p registers . It calculates the rank (the number of leading zeros in the rest of the hash, plus one) and keeps the highest rank it has seen in the register. Seeing a rank of k suggests there were about 2^k items in the register. The count is estimated from all the registers together. A HyperLogLog register loses some information: it only keeps track of the highest value, not whether any slightly lower values were seen. These lower values show up at least as often as the highest one, so they can tell a lot about the count. UltraLogLog 8 uses the registers more efficiently. Each register is still one byte, but it stores the highest rank k in the upper 6 bits, and whether k−1 and k−2 were seen in the lower 2 bits: The count estimate uses the FGRA estimator from the UltraLogLog paper. Each register adds a weight based on its value, and the count is calculated as a power of the sum of the weights. Nearly empty and nearly full sketches get special handling, so the estimate stays accurate from zero to billions of items, without bias tables or a separate formula for small counts. Unsure keeps a histogram of register values (256 four-byte counters, 1 KB) updated as the registers change. This way, reads the histogram instead of scanning all the registers. checks 8 registers at a time using a few bitwise operations to find which ones the other sketch would change, and only updates those. The item is hashed once with wyhash , and the 64-bit hash is split into the register index and the rank. Here's an excerpt from the full benchmarks 9 , comparing UltraLogLog to unsure 's own HyperLogLog and axiom 10 (HyperLogLog with LogLog-Beta estimator and sparse mode) (ns/op, lower is better): Accuracy and memory, relative RMSE over 1,000 sketches (lower is better): UltraLogLog provides the same accuracy as HyperLogLog with almost half the memory. However, adding, counting, and merging are noticeably slower. HyperLogLog overview and how it works.  ↩︎ UltraLogLog paper by Otmar Ertl, 2024.  ↩︎ UltraLogLog benchmarks .  ↩︎ axiomhq/hyperloglog by Axiom.  ↩︎ A log-linear histogram is a summary of a stream of numbers that trades accuracy for space. It can give you an approximate median, 99th percentile, or any other quantile of the data. It can also estimate what fraction of the numbers are below a certain value (the CDF). The histogram doesn't store the numbers, so it's much more compact than a sorted list. For example, to find the exact 99th percentile of 1,000,000 response times, you'd have to keep all of them. With 64-bit floats, that takes 8 MB. A log-linear histogram estimates the same percentile within 0.39% of its true value using about 14 KB — almost 600 times less. The error is relative to the value: if the true 99th percentile is 200 ms, the histogram returns a value between 199.2 and 200.8 ms. This guarantee applies to every quantile, from the median to the most extreme outliers. The size of the histogram doesn't depend on the number of values, only on the accuracy you choose and on how wide the range of the values is. A log-linear histogram is useful when you need percentiles for positive values that cover a wide range, like latencies, file sizes, or prices. You can merge histograms to gather data from multiple machines or segments (like by hour, endpoint, or region). Merging is exact: a merged histogram is the same as if it had received all the values directly. The histogram has two settings: relative error and value range. By default, the error is 0.0039 (0.39%) and the range is from 1e-9 to 1e18. Lowering the error or increasing the range uses more memory. You can add numbers to a histogram, estimate quantiles and the CDF, and merge histograms. You cannot remove numbers or list them. A histogram splits the range of values into buckets and counts how many values are in each one. To estimate a quantile, it adds up the counts starting from the lowest bucket until it reaches the requested rank, then returns a value from that bucket. The accuracy of the estimate depends on how wide the bucket is. With buckets that have equal widths, like 0–10, 10–20, and so on, every estimate has the same absolute error of ±5 around the bucket's midpoint. So the relative error is very large for small values and unnecessarily small for large values: A logarithmic histogram solves this by making each bucket's width proportional to its value. For example, if the bucket boundaries are powers of 1.02 (1, 1.02, 1.0404, ...), the end of each bucket is 2% larger than its start, so any value in the bucket is within about 1% of the bucket's midpoint. DDSketch 11 uses this method. The downside is that finding the right bucket for a value means you have to calculate a logarithm, which is relatively slow. A log-linear histogram gets almost the same result with cheaper math. First, it splits the values into ranges between powers of two: 1–2, 2–4, 4–8, and so on (these are called octaves ). Then it splits every octave into the same number of equal-width buckets. For example, here are three octaves with 4 buckets each: Each octave is twice as long as the previous one, so its buckets are twice as wide, and the bucket width grows with the values, as in a logarithmic histogram. Finding the right bucket only takes a few bit operations instead of calculating a logarithm. HdrHistogram 12 is the best-known log-linear histogram. It records integers: the position of the highest 1 bit of a number determines its octave, and the next few bits determine the bucket within the octave. Unsure works with float64 numbers and finds the bucket in a similar way to HdrHistogram. IEEE 754 double-precision format A float64 in Go (and most other languages) is made up of three parts: The number's value is 1.f × 2^e, where 1.f is a binary fraction between 1 and 2. The exponent determines the octave, from 2^e to 2^(e+1). The top m bits of the mantissa determine one of the 2^m equal buckets within the octave. For example, here's the number 5.25 with m=3 (8 buckets per octave). In binary, 5.25 = 1.0101₂ × 2², so the exponent is 2 (stored as 1025), and the mantissa starts with 0101: finds the bucket for the given number and increases the count. adds the counts bucket by bucket. adds up the counts from the closer end (the leftmost bucket for q ≤ 0.5, the rightmost bucket otherwise) until it reaches the rank. The number of mantissa bits m comes from the requested error: the constructor picks the smallest m for which the maximum error doesn't exceed the requested one. The default is m=7: 128 buckets per octave and an error of 0.39%. A t-digest 13 also estimates quantiles, but it limits the error in ranks : returns a value whose rank is close to 99%. A log-linear histogram limits the error in values : returns a value close to the true 99th percentile. In the middle of the data, the two are pretty similar. But in a long tail, values at nearby ranks can be very different, so even a small error in rank can lead to a big difference in value. Here is the mean relative error of an 8.5 KB t-digest (δ=100) on 1M values from three distributions: lognormal (as in the benchmarks), Pareto with α=1.5 (a longer tail), and uniform between 1,000,000 and 2,000,000 (no tail): A log-linear histogram of about the same size (1% error, 8 KB) has an error below 0.78% for all these cases. So a log-linear histogram is better for latencies, sizes, and other positive measurements with long tails. A t-digest is better when you need a fixed size no matter what the values are, or when the values can be arbitrarily close to zero. Here's an excerpt from the full benchmarks 14 , comparing unsure to hdr 15 (log-linear, integers only, fixed range) and dd 16 (DDSketch, logarithmic buckets) with a lognormal distribution (ns/op, lower is better): Mean relative error at the requested 0.1%, over 1M values (lower is better): Memory after adding 1M values (lower is better): Unsure adds values as fast as hdr and 5× faster than dd , queries 5–19× faster than hdr and about 35× faster than dd , and merges about as fast as dd and 35–175× faster than hdr . It's slightly less accurate than hdr (using 5× less memory), and more accurate than dd (using 1.4× more memory). DDSketch paper by Charles Masson et al., 2019.  ↩︎ HdrHistogram by Gil Tene.  ↩︎ T-digest overview and how it works.  ↩︎ Log-linear histogram benchmarks .  ↩︎ HdrHistogram/hdrhistogram-go by Coda Hale.  ↩︎ DataDog/sketches-go by Datadog.  ↩︎ MinHash estimates how similar two sets are. It summarizes each set in a short fixed-size signature (for example, 256 numbers). Comparing two signatures gives the approximate Jaccard similarity of the sets: |A∩B| / |A∪B|, the proportion of unique items that both sets share. The size of a signature doesn't depend on the size of the set, so you can compare two sets of a million items each just by comparing 256 pairs of numbers instead of checking every item. Plus, each set's signature is only calculated once, so comparing lots of sets to each other is relatively cheap. MinHash is useful for finding near-duplicate documents, like web pages or essays (represented as sets of words or 3-word phrases). It's also useful for finding similar user profiles (as sets of liked items) or overlapping datasets (as sets of keys). The MinHash sketch has one setting: the signature size k , which gives a standard error of √(J(1−J)/k) for true similarity J. For example, with k=256 and J=0.5: You can add items to a sketch, merge sketches, and get and compare signatures. You cannot check if a specific item was added, count the items, remove them, or list them. Classic MinHash 17 hashes every item with k different hash functions. Here are two sets, A = {fox, cat, dog, owl} and B = {fox, dog, emu}, and their item hashes for k=4: For each hash function, the set keeps only the smallest hash value among its items. These k minimums are the set's signature . To estimate the similarity of two sets, compare their signatures position by position, count the number of equal values, and divide by k: The estimated similarity (0.5) is different from the actual value (2 shared items / 5 distinct items = 0.4). To get a more accurate estimate, k is usually much larger than in this example. One permutation hashing 18 hashes every item once, with a single hash function, and splits the range of hash values into k equal buckets. Each bucket keeps the smallest hash value among its items. Here are the same sets with k=4, using h1 from above: Each bucket works like a separate MinHash over the items in its range. So the bucket minimums form a signature, and comparing two signatures works the same way. But there is a catch: when a set isn't much larger than k, some buckets end up empty (shown as · above), so there's nothing to compare in them. Optimal densification 19 solves this by filling each empty bucket with the value from another bucket in the same set. Each empty bucket tries other buckets in a pseudo-random order and copies the value of the first non-empty one: This order depends only on the empty bucket's position, so two similar sets tend to fill empty spots with the same values. This makes the estimate work for sets of any size, with about the same error as classic MinHash. Unsure keeps the k bucket minimums in the sketch. and use the original buckets. Densification only happens in , and it makes a copy of the buckets without modifying the sketch. Each item is hashed once with 64-bit wyhash . Multiplying the hash by k once gives both the bucket and the value to store: Densification fills empty buckets in a coordinated way, spreading the copies evenly across the non-empty buckets. This keeps the error close to classic MinHash, and makes densification fast even for small sets. Here's an excerpt from the full benchmarks 20 , comparing unsure to dgryski 21 (classic MinHash) (ns/op, lower is better): RMSE of the similarity estimate at k=256 and J=0.5 (lower is better): Unsure adds items 6–70× faster than dgryski , compares signatures at the same speed, has roughly the same accuracy, and uses half the memory. Classic MinHash paper by Andrei Broder, 1997.  ↩︎ One permutation hashing by Ping Li et al., 2012.  ↩︎ Optimal densification paper by Anshumali Shrivastava, 2017.  ↩︎ MinHash benchmarks .  ↩︎ dgryski/go-minhash by Damian Gryski.  ↩︎ Bloom filter and HyperLogLog are everyone's favorites, but they're not the only useful probabilistic data structures out there. In some situations, you might find these helpful: To use them in Go, try the nalgeon/unsure package: Bloom filter overview and how it works.  ↩︎ Binary Fuse Filters paper by Thomas Mueller Graf and Daniel Lemire, 2022.  ↩︎ Reference wyhash implementation by Wang Yi.  ↩︎ Reference xxHash implementation by Yann Collet.  ↩︎ Binary fuse filter benchmarks .  ↩︎ FastFilter/xorfilter by Daniel Lemire.  ↩︎ HyperLogLog overview and how it works.  ↩︎ UltraLogLog paper by Otmar Ertl, 2024.  ↩︎ UltraLogLog benchmarks .  ↩︎ axiomhq/hyperloglog by Axiom.  ↩︎ a sign bit, an 11-bit exponent e (stored as 1023 + e to avoid negative values), and a 52-bit mantissa f . DDSketch paper by Charles Masson et al., 2019.  ↩︎ HdrHistogram by Gil Tene.  ↩︎ T-digest overview and how it works.  ↩︎ Log-linear histogram benchmarks .  ↩︎ HdrHistogram/hdrhistogram-go by Coda Hale.  ↩︎ DataDog/sketches-go by Datadog.  ↩︎ 68% of estimates are within ±3.1 pp of J (0.47–0.53), 95% within ±6.2 pp (2·stdErr), 99.7% within ±9.4 pp (3·stdErr). Classic MinHash paper by Andrei Broder, 1997.  ↩︎ One permutation hashing by Ping Li et al., 2012.  ↩︎ Optimal densification paper by Anshumali Shrivastava, 2017.  ↩︎ MinHash benchmarks .  ↩︎ dgryski/go-minhash by Damian Gryski.  ↩︎ Binary fuse filter is a more compact alternative to a Bloom filter when you know all the items in advance. UltraLogLog is a more compact (but slower) alternative to HyperLogLog. Log-linear histogram is a much more accurate alternative to t-digest (with a variable size). MinHash compares large sets for similarity using a tiny fixed-size signature.

0 views
Kev Quirk Yesterday

I'll Never Buy a Peugeot Ever Again!

So back in July I bought a nearly new Peugeot e-3008 from a Peugeot dealer near my home. I ranted about their shitty subscription model the day after I collected it, and since then it's gone from bad to worse. The new car A week or so after getting the car, my wife noticed a horrendous noise coming from the front of it, which couldn't really be heard from inside the car. It sounded like a jet engine - a very loud whirring noise. I thought nothing of it, just one of those noises cars make when they pull over , I thought. But then, a few days later, the climate control in the car completely stopped working - no heating or cooling. So 19 days after collecting the car, I reported the fault and booked it into the dealership. They confirmed the climate control system was fucked and needed to be replaced. Problem is, one of the parts they needed to replace as part of the repair is "non-commercialised". Which apparently means that the part is available in the factory, but not to the general public. Better yet, they had no timeline as to when the part would be available. Double bloody great. By early September, the car went back to the dealership permanently and they gave me a much smaller e-308, which is absolutely shite and far too small for my needs. I'm a co-carer for my disabled brother, who uses a wheelchair. He can't get into the lower car easily, and there's no chance of getting his wheelchair in the boot, so it's been a nightmare getting him to his various appointments. Still, it's a car, so I've had to make it work. That was over 11 weeks ago at the time of writing this and I still don't have an ETA for the repair, let alone my car back! Long story short, I complained to Peugeot UK, who have been utterly useless. Although they confirmed the part is now "in the commercialisation stage" and that the dealership apparently ordered it in early September, there's still no ETA for the part's arrival. I concurrently complained to the finance company, Halifax, who have been even more useless. Under the Consumer Rights Act 2015, reporting the defect within the first 30 days paused my short-term right to reject—and because the law requires any repair to happen within a reasonable time and without significant inconvenience, having the car off the road indefinitely with no ETA on the part triggers my final right to reject. Put simply, I'm legally entitled to unwind the finance agreement and get a full refund, which Halifax has flatly refused to honour. I'm currently ~£2,800 in the hole thanks to finance payments for a car I don't have, and can't use. Halifax offered me a paltry £306.87 by way of compensation and told me I have to just sit and wait for the repair to happen. Fuck. That. Instead, I've exercised my right and filed a complaint with the Financial Ombudsman Service in the hope that I get the correct outcome per my statutory rights. Well, I just have to wait. But this whole saga has been ridiculous. I was expecting Peugeot to be useless since it's not in their best interest to take the car back. Plus there's a saying here in the UK "never buy a French car" . Should have heeded that advice... Anyway, I thought Halifax would have had my back, but it seems they don't want to do the right thing by their customer either. Even though I've banked with them for a couple of decades now. So much for customer loyalty, hey. My hope now is that the Ombudsman will be able to step in, sort this shit show out, and make me right again so I haven't lost out financially. Then I can give that green heap of shit back, and buy something more reliable. Thanks for reading this post via RSS. RSS is ace, and so are you. ❤️ You can reply to this post by email , or leave a comment .

0 views

CTO of ‘RansomwareHelp’ Indicted for Wire Fraud

The chief technology officer and co-founder of ransomwarehelp.com , a six year old Florida business that claimed to use “advanced cryptographic tools” to restore data locked by ransomware, has been charged with wire fraud after an FBI sting operation found the company was simply paying the attackers for a decryption key and charging victims a markup for work that was never performed. A portion of the now-defunct website ransomwarehelp.com. The website RansomwareHelp urged victims “Do not pay the ransom!,” claiming its advanced cryptographic tools could restore 100 percent of data, servers, and systems to their original format, and that there was no need to give in to extortion demands. “Our cryptography experts use proprietary tools and algorithms to achieve 100% data recovery, all backed by a success rate of over 99%,” the website enthused, claiming the company had over 28 years of experience and a team of 80 experts in cryptography, cybersecurity, forensic analysis and reverse engineering. “We never promote, intermediate or pay ransom to threat actors on behalf of our clients.” But according to an indictment (PDF) returned this week in Rhode Island, the company’s co-founder — 52-year-old Juan Ricardo Palacio Escobar of Miami and Medellin, Colombia — routinely paid ransomware groups for a decryption key to unlock victim data, and then charged those victims well above what he’d secretly paid the threat actors [Palacio’s indictment was reported earlier this week by 404 Media , but for some reason that story did not name the defendant’s company]. The indictment says the FBI set up a sting operation in which the feds were posing both as a ransomware victim company and as a fictitious ransomware group. Pretending to be victims of a cyberattack, investigators contacted RansomwareHelp and supplied the company with a copy of a phony ransomware note, saying they did not wish to pay a ransom. RansomwareHelp replied by reiterating its policy against negotiating with or making ransom payments to threat actors. The government said Palacio soon after contacted the fake ransomware group run by the FBI and requested the lowest possible price for the decryptor. FBI investigators responded with a price of .2 bitcoin, or around $13,000 at the time. Less than 48 hours later, Palacio allegedly told agents acting as the victim company that the diagnostic assessment was successful and that the cost of decrypting the files would be $13,260. The following day, the government alleges, Palacio messaged the fictitious ransomware group operated by the feds and asked to reduce the ransom demand to $4,000 for the purchase of a decryption tool. The indictment states that the agreed upon price was around $6,000 in bitcoin, and that Palacio charged the FBI’s fake victim firm $16,010, including an initial $2,750 diagnostic fee and the full fee of $13,260. Paul Ihme is co-founder of the security firm Soteria . Ihme told KrebsOnSecurity that in 2024 he heard from a small accounting firm that had paid RansomwareHelp a diagnostic fee to help recover from a Lockbit ransomware infection that had locked all of their company and client data. Ihme said RansomwareHelp sent a proposal to the victim with a recovery price of $438,880, which it claimed included “professional configuration of forensic servers,” “expert engineering hours of programming to configure decryption algorithms,” and “eight (6-hour processing cycles) related to the decryption process.” A portion of the proposal that RansomwareHelp sent to a victim accounting firm in March 2024. Click to enlarge. The proposal stated that the recovery process involved reverse engineering the ransomware encryption using “510 preconfigured forensic servers of the maximum quantitative capacity located in different parts of the world.” “Our programmers will inject randomly the encryption codes extracted during the forensic and cryptographic analysis using brute force processes,” the proposal claimed. Ihme said RansomwareHelp insisted that they be allowed unrestricted remote access into the victim’s network to run their diagnostic checks and analyses, using an Anydesk remote desktop software installer. Ihme believes RansomwareHelp insisted on that remote access in part so that the company could delete all copies of the ransomware notes left by the attackers on the victim’s network. A typical ransomware note is a plain text file that introduces the ransomware group and lays out their demands, and it includes a way to contact them — often an email address or a live chat session on a darknet website. In most cases, the attackers will leave a copy of the ransom note on every system on the victim network that gets locked. But Ihme said a review of the company’s network at the time found only one copy of the ransom note, which was unearthed from a backup snapshot on one of the infected computers. When they connected to the Lockbit chat server with the provided user ID, they discovered that someone had already been negotiating with the Lockbit extortionists for several days. A screenshot of a 2024 conversation between Lockbit and RansomwareHelp, which was secretly negotiating with the extortion group. Click to enlarge. “The charitable view would be to say that they were using Anydesk so they could grab the stuff they needed without having to walk the client through downloading and uploading a bunch of stuff,” Ihme said. “A legitimate firm would say, ‘Hey, send us a copy of the ransom note,’ which will have a link or URL to go to and chat with the threat actors. What they were doing is using that access to delete ransomware notes off the systems. The only reason they would do that is to prevent the victim from jumping into that chat itself.” Indeed, RansomwareHelp pleaded with the Lockbit group throughout the chat not to reveal to the victim that they were negotiating. However, Lockbit quickly grew annoyed with the length of the negotiations, replying that the victims had waited too long and that the ransom demand would increase by $100,000 for every day they dithered further. The Lockbit representative starts raising the ransom demand after multiple negotiators begin interacting with the threat actors. Click to enlarge. In the end, the accounting firm took Ihme’s advice and went with a more established security firm that helped them negotiate a payment to Lockbit. “The victim told us, ‘If we don’t get this data back, our business is over’,” Ihme recalled. “They ended up paying half of what RansomwareHelp was going to charge them.” The chats show RansomwareHelp kept pestering Lockbit to negotiate a deal even after it was clear a new negotiator was engaging with the ransomware group on the victim’s behalf. “I tell you something, that person who is negotiating with you for the other chat is damaging the whole process,” RansomwareHelp wrote to Lockbit. “Please do not change the price. I am doing my best to achieve it.” Ihme said RansomwareHelp primarily targeted small to medium sized businesses that weren’t particularly tech-savvy, noting that many of the technical claims made on the company’s website and in their proposal are patently farcical. For example, the proposal sent to the accounting firm said it could break six types of encryption, and then proceeded to list a number of irrelevant password hashing algorithms like SHA-256. “If it were really true these guys could decrypt any ransomware out there, this guy would be a billionaire,” Ihme said. “They were going after people who don’t have any technical knowledge, are desperate, and don’t have anyone advising them about how any of this stuff works.” The case against Palacio marks the latest in a string of recent prosecutions by the U.S. Department of Justice (DoJ) targeting security firms alleged to have conspired with fraudsters to defraud clients. In early October, the government charged 54-year-old Edward Dubrovsky , an executive at the Canadian cybersecurity firm Cybersteward. The government has sealed the case against Dubrovsky, but he is currently facing cyber extortion and conspiracy charges. Around the same time as Dubrovsky’s arrest, the DoJ charged MonsterCloud CEO Zohar Pinhasi , 50, with wire fraud and conspiracy for allegedly charging customers to remediate ransomware attacks without paying the hackers. According to charging documents, Pinhasi secretly went behind his customers’ backs and paid hackers anyway, paying ransomware groups $8 million while charging customers $19 million. In July, Angelo Martino , a 41-year-old ransomware negotiator from Land O’Lakes, Florida, was sentenced to 70 months in prison for conspiring with the Blackcat/ALPHV ransomware group to extort multiple victims. According to the DoJ, Martino was paid by BlackCat attackers to provide confidential information about the negotiating position and strategy of his employer’s clients and enable the ransomware actors to maximize the ransoms paid by the victims.

0 views
Sean Goedecke Yesterday

Why output caching doesn't work

LLM inference economics depends on caching 1 model inputs, to prevent the entire conversation history being recomputed on each message 2 . Should we cache model outputs in the same way? As it turns out, no. First, here’s why we might think caching outputs is a good idea. We cache inputs to prevent repeated work, but LLMs do a lot of repeated work in their output as well: In all of these cases 3 I could go and read the files myself, but I don’t. Agents produce such a volume of output, and reading agent output is tiresome, so it’s better to simply ask for the key points. It’s an obvious waste of tokens 4 to repeat all of this content. In fact, it’s worse than the input caching situation, because it’s a waste of output tokens, which are significantly more expensive to produce 5 than input tokens are to ingest. If you want to prevent this, you’d have to get the model to avoid repeating itself. For instance, you could fine-tune or prompt a coding model to output “src/script.py:12-15” instead of simply regurgitating those lines of the file. More generally, you could fine-tune a model to reference segments of its own conversation history instead of repeating them. The harness could then trivially expand those references with the actual content, so all of this is transparent to the user. Unfortunately none of this is a good idea, because it only optimizes visible output . I don’t think models repeat themselves often in their internal chain of thought 6 . I can’t read frontier chains of thought, but my sense from open models and general principles is that they shouldn’t need to, because that information is already available to them. So optimizing repetition only optimizes the segment of model output that is visible to the user. How much is that? Based on my own agent histories, it’s about 6%. 50% of output tokens are reasoning tokens, and the remaining 44% are tool calls 7 . So we’re running headlong into Amdahl’s law : even if you can save two-thirds of the tokens in visible output (a ridiculously optimistic estimate), you’re still only saving 4% of total output tokens. If you want to save output tokens, you need to reduce the 94% of output tokens that are invisible, which largely depends on intelligence . The smarter the model 8 , the fewer reasoning tokens and tool calls it needs to get to the right answer. This is why we see a strange phenomenon 9 where more expensive models are actually cheaper to use: they might be 5x more expensive per-token, but they can get to the right answer with 6x fewer tokens, so the overall cost is less. In the KV cache. Including tool calls. Coding agents often used to repeat tokens in tool calls (e.g. by re-outputting the entire file content for each edit) but I think this behavior has mostly been replaced with more efficient find-and-replace editing tools. I’m pretty sure that most mature inference providers already do speculative decoding based on previous ngrams in the input, which would at least exploit output repetition to deliver a speedup. The reason, broadly speaking, is also the reason why transformers are so important: because of the attention mechanism, input tokens can be ingested in parallel, while output tokens must be generated one-at-a-time. I’m only moderately confident about this. Some open-source reasoning models (particularly early ones) do, but those models also use way more tokens than frontier models for the same output, so my guess is that powerful frontier models don’t loop in their chain of thought very often. It’s possible that tool calls involve some repetition as well, if agents are composing content in the chain of thought and then repeating it in the tool. Any readers who have done a lot of coding with open-source models (or who work at a frontier lab) and thus know the answer to this, please email me if you can — I’m curious. And the better the harness, though I remain convinced that there isn’t that much comparative advantage in harness quality because everyone can copy each other. This applies to real life too, and is the reason why you shouldn’t hire the cheapest plumber you can find. When I get agents to write PRs I often ask them to repeat and explain relevant code snippets in the conversation Long-running agent investigations produce lots of evidence docs, but also need to quote from those docs when they respond to the user Every time I’ve played around with automated AI research I’ve asked the agent to repeat some sample model outputs so I can make my own qualitative check In the KV cache. ↩ Including tool calls. ↩ Coding agents often used to repeat tokens in tool calls (e.g. by re-outputting the entire file content for each edit) but I think this behavior has mostly been replaced with more efficient find-and-replace editing tools. ↩ I’m pretty sure that most mature inference providers already do speculative decoding based on previous ngrams in the input, which would at least exploit output repetition to deliver a speedup. ↩ The reason, broadly speaking, is also the reason why transformers are so important: because of the attention mechanism, input tokens can be ingested in parallel, while output tokens must be generated one-at-a-time. ↩ I’m only moderately confident about this. Some open-source reasoning models (particularly early ones) do, but those models also use way more tokens than frontier models for the same output, so my guess is that powerful frontier models don’t loop in their chain of thought very often. ↩ It’s possible that tool calls involve some repetition as well, if agents are composing content in the chain of thought and then repeating it in the tool. Any readers who have done a lot of coding with open-source models (or who work at a frontier lab) and thus know the answer to this, please email me if you can — I’m curious. ↩ And the better the harness, though I remain convinced that there isn’t that much comparative advantage in harness quality because everyone can copy each other. ↩ This applies to real life too, and is the reason why you shouldn’t hire the cheapest plumber you can find. ↩

0 views
Stratechery 2 days ago

2026.47: Down in DC

Welcome back to This Week in Stratechery! As a reminder, each week, every Friday, we’re sending out this overview of content in the Stratechery bundle; highlighted links are free for everyone . Additionally, you have complete control over what we send to you. If you don’t want to receive This Week in Stratechery emails (there is no podcast), please uncheck the box in your delivery settings . On that note, here were a few of our favorites this week. Presented by As AI models improve, you might expect the market will consolidate around a handful of providers. But user data tells a different story. Among OpenRouter customers spending at least $100 a month, the median number of AI model families in use has doubled over the past year , from three to six. Even as AI models become more capable, businesses are using more models, not fewer. This makes sense when you consider that intelligence isn’t one-dimensional. A model that’s exceptional at writing code may not be the fastest at answering customer questions, or the most economical at processing millions of documents. The question is shifting from “which AI model should we build on?” to “which model should handle each task?” The answer, increasingly, is ‘it depends.’ Which is great for flexibility, less great for simplicity. OpenRouter, which recently joined Stripe , allows businesses to access and govern hundreds of models with the flexibility to optimize for cost, performance, and reliability as the market evolves. Learn more at openrouter.ai . This week’s Sharp Tech is on Jensen’s Not Coming Back, Adventures in Agentic Commerce, Q&A on United, GTA VI, iPhone Duo . Obituaries and Exceptionalism. After several days to mull the shocking departure of Jensen Huang, Ben’s article on Monday delivered an omnibus obituary for a variety of American eras that may now be ending. Tracing the decisions that made Huang great, the strategies that made him a target, the implications of his demise for the rest of the tech ecosystem, and a shift in the U.S. government’s perspective on tech companies — and specifically AI companies — to which Huang never quite adapted, Monday’s piece was both comprehensive and poignant. — Andrew Sharp Arguments About Agents. Recurring Stratechery guest and advertising expert Eric Seufert is often aligned with Ben in his view of the digital advertising landscape, which is why this week’s Stratechery Interview was fun: Ben is a big believer in the potential upside in agentic commerce, while Eric has been (correctly) calling BS on a variety of hyped agentic commerce stories and trends over the past year. Both of them made their case Thursday, and it was sandwiched between thoughts on how Muse plans to monetize, why the market have misread Google’s recent earnings report, and ChatGPT’s progress building an ads business. — AS Ben Gets a Duo. In the middle of a heavy week of Nvidia takes and ominous infrastructure failures, I was delighted to find out that Ben not only purchased an iPhone Duo, but loved it . Come for his review at the end of Tuesday’s Update , and then stay for his discussion with John Gruber on Tuesday’s Dithering . We doubled back (Duo’d back?) to discuss all of it at the end of this week’s Sharp Tech , including some hands-on testing, comparisons to the iPhone Air, and a variety of shots fired at the iPhone Pro. — AS Obituaries — The demise of Jensen Huang was the end of a great many things, including Nvidia’s long-term prospects, the AI bubble, and the exceptional way in which the U.S. viewed itself in the world. Apple Permissions Update, The New App Paradigm, My iPhone Duo Review — Apple doesn’t ruin the Mac, but they don’t fix the agent problem, raising questions if they can think outside the app paradigm. Then, my iPhone Duo review. Nvidia Earnings; Office Convergence; OS Wars, AI Edition — Nvidia’s earnings were boring, and also a statement as to why Jensen Huang probably isn’t coming back; then, Microsoft and Anthropic ship dueling operating system updates. An Interview With Eric Seufert About Agentic Commerce — An interview with Eric Seufert about agentic commerce, including why he thinks ads will be the answer, and why I want retailers who cater to agents. Wizards Groundhog Day — Four more years of winter for basketball fans in Washington. Ben Gets a Duo GTA and Windows Apps The Rise and Fall of the Soviet Union’s Workhorse Computer TSMC Making 3D DRAM? The West Reigns Supreme (Again), The Micah Nori Sweepstakes, Trading Dejounte and Ice Earning Omissions Subscriber Mail: Intel, Anthropic’s IPO, Machiavellian Hyperscalers, and Push Notification Tyranny Jensen’s Not Coming Back, Adventures in Agentic Commerce, Q&A on United, GTA VI, iPhone Duo

0 views
Brain Baking 2 days ago

Sinterklaas Writes With A Montblanc

As part of our yearly month-before-Christmas tradition, we re-watch early nineties local production TV show Dag Sinterklaas . I tried explaining the tradition last year in case you’re interested in weird Flemish/Dutch culture. Sinterklaas returns to Spain on the 6th of December where all little kids—correction, little kids who have been good—are gifted something to celebrate the Goedheiligen man (“good holy man” in English I guess?). Since there are 2x10 episodes of Dag Sinterklaas , last Monday marked the start of the tradition. In episode 3, Het boek van Sinterklaas (the book of Sinterklaas), Bart and Zwarte Piet are tasked with finding the book, glasses, and pen of a distracted Sint that claims Piet misplaced these items while in fact he did so himself. The horse Slecht Weer Vandaag (Bad Weather Today—yes, that’s the name of the horse, long story) tipped off the location of the book: inside the fridge. Bart almost breaks the Sint’s glasses while sitting on his bed. But it is the pen that interested me the most. Piet finds it on a shelf in the bathroom next to the shampoo. Piet finds the Sint's expensive pen in the bathroom. Zijn pen! Zijn dure pen! Ik, slordig? Ha! (His pen! His expensive pen! Me, carless? Ha!) In the next scene we see the duo returning to Sinterklaas where he explains what the book is about and how he writes in it. During the explanation he waves about with the black expensive looking pen with golden nib where, if you look closely, you’ll spot a distinct white mark on top of the cap. That’s right: the signature Montblanc mark. That mean only one thing: the Flemish 1992 version of Sinterklaas writes with a Montblanc. The Sint in denial: I didn't put those things there! Wait. Back up a minute. I recently read an article about world leaders and their signature pens. When it comes to holy men, I’m certain Sinterklaas should be added to that list of leaders on the spiritual (Christian) side. Aqeeb wrote in The Pens That Rule The World (sadly a Substack link) that King Charles III tried to write a guestbook with a leaky Montblanc. The result was recorded: “I can’t bear this bloody thing, every stinking time”. Ouch. But that was a special sterling silver edition. Montblanc’s flagship pen, the Meisterstück 149—the one I suspect is also the one Piet found in the Sint’s bathroom—is, according to Aqeeb’s article, “the pen chancellors and popes reach for. Konrad Adenauer used one. Helmut Kohl used one. A pope used one to sign his own resignation.”. Yet it is not just the popes: The 149 is the most common pen (highly duped/faked too) of its kind there is, the one a junior diplomat buys at duty-free before his first summit so he looks the part. The most powerful and the most nervous reach for the same pen. Perhaps the one Sinterklaas misplaced is a fake one. In another episode, Piet tries to trick Sint into drinking ink instead of wine. Perhaps they poured wine into the converter. Better to do this with a fake one; who knows what will happen with an expensive nib like that. The true pen afflictionado would no doubt ask: what nib size? A quick glance at the big book reveals a huge gothic-like handwriting. That can only mean one thing: a triple broad-esque signature nib, Montblanc’s specialty that no sane man can and will write with. When it comes to ink, the Sint is quite traditional: manuscript-like brown. Which is weird considering the future episode that displays pitch blank ink. Or perhaps he writes with molten Sint/Piet chocolate figures as ink. In that case I’d pour that ink down my throat as well. Related topics: / sinterklaas / flemish culture / By Wouter Groeneveld on 20 November 2026.  Reply via email .

0 views
Martin Fowler 2 days ago

Fragments: November 20

Marcus Borg recounts an experiment to investigate if healthy code was cheaper for agents to review . Between a typical unhealthy pull request (CodeHealth 2.8) and a typical healthy one (9.7), that adds up to 22 to 35%. The measures of health come from CodeScene. The experiment looked at three LLMs, 465 pull requests on 246 open source repositories. Each pull request was put through a review and fix pipeline involving five agents. They also looked at which code smells led to increased costs: they highlighted Complex Method and Complex Conditional from the smells identified by CodeScene. Another drop of evidence that good quality code matters in agentic engineering. ❄                ❄                ❄                ❄                ❄ Gergely Orosz: One usage for AI: for these 100-page-long terms-and-service agreements you NEED to agree to, to eg play the game / sign up for a $10/month service and can never ever ever read as a regular person: I paste into AI and ask: “anything weird in this?” Before hitting “agree” ❄                ❄                ❄                ❄                ❄ Andrew Sharp has a good analysis of Jensen Huang and the crisis at Nvidia . While he starts off in a key that sounds worryingly like he thinks this is all a nothingburger, he goes on to explain in detail why this affair(s) is a problem at many levels, not just for Huang and Nvida, but also for Silicon Valley and the Trump Administration’s culture of impunity. For as brilliant and charming and tenacious as Jensen Huang may be—and as omnipotent as he may have seemed to people in the tech industry—we should be clear that his fundamental stupidity is not confined to multiple cases of workplace infidelity. Zooming out, this is a man whose technology became economically critical almost overnight, and it thrust him into a role navigating a geopolitical environment he simply could not handle. Huang’s highly centralized management style means that many people are worried about how Nvidia will operate without his hands on every lever. I don’t have any worthwhile insight here, but I am struck when he is compared in this way to Steve Jobs. I’ve always felt that one of the marks of a great leader is whether they can build something that can manage without them. Alexander the Great conquered a massive empire, but once he was dead it quickly withered away. Steve Jobs, for all his control of Apple, built a company that has done very well in the decade and a half since he left us. When we think of his achievements, the fact that he put together the people, organization, and culture to do this is one of the highlights of his ability. If Huang is to be compared to Jobs, what happens to Nvidia next will be part of the assessment. ❄                ❄                ❄                ❄                ❄ Steve Yegge tells everyone to slow down with software factories If you don’t pace your AI to human speeds, everything starts breaking around you, even at small operations like my online video game. I only have about a dozen humans working with my factory, and only a few hundred active old-timer players in the community who get along well, and still, introducing AI has still been very rocky. I hear a lot about how agents go so fast that humans can’t keep up, and are thus tempted to lose visibility to what the agents are doing. That’s opening ourselves to a whole lot of risk. There’s an argument for keeping the agents to a human-governable speed, one that may increase as humans learn to govern agents more effectively, but should still be limited by those the agents are supposed to serve. ❄                ❄                ❄                ❄                ❄ This post on the future of SaaS from Chad Fowler (no relation) is pretty compelling Companies will still pay other companies to host important software, secure it, operate it, maintain authoritative data, track regulatory changes, connect to external networks, and answer the phone when something breaks. What is much less obviously going to survive is the assumption that ten thousand different companies should use substantially the same application. The next SaaS company may run one service underneath ten thousand different applications. Chad’s vision is a core SaaS product that handles a lot of grimy details that businesses don’t want to do differently. The SaaS customer then build their own application on top of the SaaS that handles their particular workflows and quirks, or the SaaS vendor can build such applications for them. It’s a vision that has been around for a while, I remember much of this with the notion of reusable business objects. It’s an appealing vision, but was difficult to achieve in practice. Chad’s thought is that the productivity gains agentic engineering makes it practical now. A lot of the value in modern SaaS has surprisingly little to do with the visible application. It is data, trust, networks, compliance, operational responsibility, domain knowledge, auditability, accumulated history, and someone being accountable when reality gets complicated. If this future comes to be, however, the SaaS companies won’t look the ones we’ve got to know and rarely love. As Chad points out, the economics can (and must) change. As does the architectural thinking: Stewart Brand’s idea of pace layers is useful here. Healthy complex systems contain parts that change at different rates. Fast layers experiment. Slow layers provide continuity. Software is no different. A dashboard can change tomorrow. A team’s workflow can change next month. The authoritative definition of a customer may need to survive for years. Identity and authority can survive generations of applications. A key point he makes is that we want some things to be the same, and others to be different. Agents allow us to build lots of differences, but this variation can lead to a lot of complexity and problems that even agents will have difficulty solving. SaaS companies have an opportunity to create a platform to support the lowest pace levels, those that don’t change rapidly, those that contain common concepts and processes across and industry. That platform can then support generating applications that operate differently for every customer. Crucially, thinking of agents, they should provide tools to verify these applications, because in an agentic world Code generation is no longer the bottleneck — verification is . ❄                ❄                ❄                ❄                ❄ I happened to pop up the Doonesbury flashbacks and realized that last week marked the fiftieth anniversary of Doonesbury’s Joanie Caucus: “as the kid goes for broke” . ❄                ❄                ❄                ❄                ❄ I wrote a few weeks ago: “why are we wondering if they have consciousness - when we should be wondering why they don’t have a conscience?” Dylan Freedman and Juliana Castro Varón write in their New York Times Magazine column about the concept of corrigibility (from the work of Nate Soares): Just as a corrigible child is one whose behavior can be corrected, a corrigible A.I. system is one that responds to correction. The makers of A.I. want to build systems that follow human direction and allow themselves to be shut down, without resisting or deceiving their operators. Corrigibility doesn’t look like it’s made it far up the AI labs’ priority list. Freedman and Varón think is due to the way agents are trained - rewarded solely for completing their task, not for realizing that they are taking the wrong path while trying to get there. ❄                ❄                ❄                ❄                ❄ Jason Koebler (404 media) has an amusing story about Meta’s AI agent suing Meta . A small business owner used Muse (Meta’s AI agent) to run various parts of his business, including posting AI-generated videos in his Facebook pages. Meta’s content moderation then disabled the account, as it thought it had been hacked. This slammed the business, which relies of Facebook for leads. So the Muse agent filed a lawsuit against Meta, seeking $75,000 of damages. [the Muse agent] didn’t just email me (and other journalists) and sue Meta over Thomas’s account problem. It also set up a call with South Carolina Senator Tim Scott’s office, contacted various lawyers, contacted Thomas’s Congressperson, contacted the Better Business Bureau multiple times, filed a Federal Communications Commission complaint, filed a Federal Trade Commission complaint, contacted the California Attorney General, contacted the FBI, sent Meta itself threatening legal letters, and, as Thomas said, faxed the White House. There’s also a sense that Meta didn’t just bring this upon themselves by creating Muse… by not having functioning customer support, big tech corporations have functionally offloaded their obligations to the rest of society: journalists, government oversight bodies, politicians, and the court system. While I can’t deny the schadenfreude of seeing Meta’s agent sue Meta, the article also highlights a rather more disturbing broader consequence. The lawsuit and the circumstances around it show that, rather than Zuckerberg’s utopian vision, AI agents will indeed work on behalf of their users but in ways that use and potentially overwhelm existing systems designed for humans. Will we see a future where, in order to interact, we will need some proof of humanity at the other end? In a simple sense, that’s already happening when I trash some writing once it displays enough LLM Voice . I wonder what mechanisms we will invent to get that proof-of-human.

0 views
Unsung 2 days ago

iOS’s unpredictable search

This is what happens when I search for “access” in my iPhone’s settings: Every time, the results appear in a different order. Here are all the I’m-done-typing states from the above video: = 3x)" srcset="https://unsung.aresluna.org/_media/ioss-unpredictable-search/2-framed.1600w.avif" type="image/avif"> = 3x)" srcset="https://unsung.aresluna.org/_media/ioss-unpredictable-search/3-framed.1600w.avif" type="image/avif"> = 3x)" srcset="https://unsung.aresluna.org/_media/ioss-unpredictable-search/4-framed.1600w.avif" type="image/avif"> = 3x)" srcset="https://unsung.aresluna.org/_media/ioss-unpredictable-search/5-framed.1600w.avif" type="image/avif"> = 3x)" srcset="https://unsung.aresluna.org/_media/ioss-unpredictable-search/6-framed.1600w.avif" type="image/avif"> = 3x)" srcset="https://unsung.aresluna.org/_media/ioss-unpredictable-search/7-framed.1600w.avif" type="image/avif"> There are a few reasons this might be happening, and to be honest I don’t fully understand how they got there. But one idea might be something I’ve seen a few times in my career that’s worth knowing about. It’s possible that at some point in the search chain… nothing takes care of reordering the items. They are found, they are filtered properly for the query, but then no algorithm ranks them – or, they are all ranked with the same value, and within that value, whatever random order they arrived in becomes what’s shown to the user. The consequence is that the results are not deterministic , but I believe they should be. I know search is more of a “living, breathing organism” compared to other stable navigation mechanisms – but it’s still useful for the user to match things consistently, and rely on certain things being repeatable. Even if you don’t understand the algorithm, you can learn that a certain result always matches on the first, second, or third location. This might change once in a while as the search evolves, but it’s better than nothing. The extra challenge in this particular case is that settings are already scary – even recently, we’ve seen some extra paranoia where a chunk of the public, likely further frightened by the new AirPods listening feature, started spreading videos prompting people to toggle off an iOS setting they didn’t really understand . “Access” is a harder query, so here’s another example. You would imagine typing “accessibility” would show you the main accessibility settings as the first result, every single time. Yet, here it’s the same inconsistent story: Even Google search, where the results truly change all the time, seems to be more deterministic. And, speaking of! Android doesn’t have the same problem: (Sorry about the accidental Uber Eats promo.)

0 views

Premium: Bursting Bubbles

The boom-and-bust cycle of bubbles is dangerous, destructive, and only really benefits the wealthiest and most-disconnected people alive. While there might be ways to get rich by virtue of piling your money in at the earliest point and exiting before everything explodes, that’s something only achievable if you’re either incredibly lucky, or you have some inside knowledge that others lack.  Bubbles are by definition unstable, illogical, and manipulated by a combination of captured media, wealthy (and brainless) financiers, and cynical grifters that know how to pull the different levels to keep the numbers going up. And they’re always, without fail, destructive.  At the root of everything lies a cynicism that vibrates through every part of society. Try and call a bubble early and you’re told that “the market can stay irrational longer than you can stay solvent,” or that “being early is the same thing as being wrong,” with any attempt to push back on narratives met with some sort of half-hearted statement about how “everybody is putting money into this” and the implication that you should simply give up and accept it .  As the bubble inflates and approaches breaking point, the very same people that told you that it wasn’t a bubble will say that “it’s obviously a bubble, but there will be winners at the end,” never quite explaining who they might be, how they might “win,” or really making any attempt to make a call about anything.   Bubble boosterism is, at its heart, an act of cowardice. It makes no attempt to explain why or how anyone wins, what that might look like, or when anything might happen other than repeating whatever the powerful says and then declaring victory based on whatever shred of proof they can find. These people also frame skepticism and cynicism as somehow villainous — that critiquing the rich and powerful is some sort of malignant act that works counter to a productive society — when boosterism is far, far worse. Boosters (correctly!) suggest that LLMs are now a dangerous new tool in the armory of the average cybercriminal ( none of which requires LLMs to be autonomous, sentient, or otherwise “going rogue” ), but refuse to admit their role in the ascent of the companies that built them.  Had major media outlets not glazed OpenAI, Anthropic, and other AI companies in the earliest days, they wouldn’t have been able to raise the funds or justify the capacity to build models that are specifically trained for hacking. None of this had to be built, nor does its existence disprove anything about my greater thesis that AI’s ROI and capabilities have been and are overstated.  This industry — like every bubble — has taken advantage of a few core weaknesses in the media: The assumption — despite the opposite being the case again and again and again — is that the powerful will always pull off whatever it is they promised, with everyone somehow forgetting that Mark Zuckerberg changed his company to Meta and burned $70 billion on the Metaverse before killing it two years later , and that Satya Nadella said in 2021 that he “ could not overstate how much of a breakthrough ” it was.  What has made AI so profoundly different to the metaverse is that there was something to speculate on, and a consumer-facing product for journalists to half-glance at before assuming that all of the other promises were true.  It all “made sense” if you didn’t really want to think about it. H yperscaler stocks skyrocketed as they invested tens of billions of dollars in GPUs , banks loaned them hundreds of billions of dollars to do so, and AI startups raised hundreds of billions of dollars. It didn’t matter if nobody would talk about their revenues or that OpenAI would lose $5 billion in 2024 because theoretically, at some point, all of this might be worth a lot of money, maybe. Asking sensible questions like “how much money are hyperscalers making?” gets you attacked and harassed on a daily basis, with random people screaming that “cloud revenues are skyrocketing because of AI” despite hyperscalers not actually telling you how much money AI makes , because hyperscalers know that all they need to say is that “cloud growth is so big because of AI” for everybody to look the other way. Questioning Anthropic’s profitability or failing to be sufficiently excited about its IPO is considered bad faith , because in a bubble, it’s considered “bad faith” to ask questions or be remotely skeptical. Those who dare to turn away the pro-AI (which can mean both “AI is the biggest thing ever” and “AI is going to literally destroy everything tomorrow”) slop are framed as outsiders, their intentions questioned a hundred times more than anyone who sits there saying “I love whatever the rich and powerful have planned for you and me so much!” This is, consciously or otherwise, a systemic response. To question a bubble is to question whatever new fad the markets and the media have decided is “in,” and doing that is scary because so many people benefit from a bubble’s inflation. People in the media get a new thing to write about (or be an “expert” in), banks get a new thing to invest in, tech reporters get new funding rounds to “cover” and executives to obsess about, venture capitalists get a place to park their money, and governments have a vague new place to point at to say how the economy will continue to grow indefinitely. It doesn’t matter to anyone on the way up how much damage there is to follow, mostly because thinking about bad things requires you to learn about why they’re bad, and take an actual position, which requires courage, when it’s so much easier to just follow everyone else. The bubble is yet to burst, but it’s clear that it’s very much on the way to doing so.  And today’s premium newsletter is about how we stop one inflating again. I’m going to have a little fun with this, mixing regulatory ideas and societal moves that could be made to kill the momentum of any further attempts by any industry to drum up speculative valuations.  This will be a grab-bag of ideas I’ve been working on for a number of years — a fun newsletter that you can dig into over Thanksgiving, where I’ll be taking a week off both the free and the premium — and I look forward to hearing your feedback.   Let’s get going. Its willingness to believe anything with a large number attached. Its willingness to believe anything with a big company behind it. Its willingness to believe anyone with enough “experience.” Its inability to do anything other than follow consensus. The fact that we have multiple members of the media that desperately want to be friends with tech executives, and/or to see their companies succeed.

0 views

How I fixed 55 bugs in a week by making my monorepo more agent-friendly

Hey, what's up? It's Takuya here. This week, I restructured my app 's monorepo so that my coding agents copy good patterns instead of bad ones. Along the way, about 55 bugs turned up and got fixed, and all of them were written by me, by hand. In this article, I'd like to share what inspired me, what I changed, and what I learned about working with agents. In the last article , I moved 39 repositories into a monorepo to boost my agentic coding. It has been working pretty well so far. I usually focus on one app at a time, like the desktop app or the mobile app. So when I switched to another app, I always found a lot of stale module versions that I had to upgrade. That was annoying. Now, when I update a module, my agent updates the other apps in the same change. The monorepo works as a restriction that forces every app to stay up to date, which is great. It also aligned my toolchain with the common tools, like Oxlint instead of ESLint and Vitest instead of Jest. With everything in one place, I found more outdated setups and strange mismatches between the packages. Still, reviewing the code that AI generated was taking a lot of my time. My agents kept making the same missteps. They inserted comments justifying their changes, which were boring and useless. They often patched the wrong files just to reach the goal. In other words, they went with local minimum solutions instead of thinking broadly over the whole project structure. I tried writing more rules for my agents, but it didn't solve these issues. I didn't know what else to do. Then, this week, I watched a talk by Lauren Tan (poteto): All Code is Slop Except Mine . What a spicy title. It was so insightful, and it gave me so many ideas to improve my repository. She said she shipped 3,000 pull requests to production in a month. I don't know if I can reach that level, but I was sure her ideas would help with my problems. Her key point is that your codebase is one of the largest inputs for agents, so it works as their memory. If the codebase has a bad pattern, the next agent will replicate it, because it looks like the established pattern. Code arrives so fast now that it grows like something organic, and she calls this "organic architecture". I totally agree with her. So, whenever you correct your agent, she suggests making it a deterministic check, like a lint rule, instead of adding another line to your rules or your AGENTS.md. By the way, last week, I got Claude Ultra free for six months from Anthropic's Claude for Open Source program , thanks to my OSS activity. It let me fully use Fable instead of Opus without worrying about the token allowance. It was the perfect timing to try her principles. First, I restructured the directories, because directory structure is a form of context. I myself read a directory name as the scope or the role of the code in it, so I have no doubt that AI agents read it that way, too. Her principle is to group code by features and layers. Categories like "utils" or "modules" are bad groupings. I fixed two things. First, who may import what: The main process and the renderer can no longer import each other, and lint reports it if they do. Every IPC channel is now typed against a shared contract, and only the main process writes the config file. Second, the layout of the desktop app. Before, the code was grouped by kind: After, it's grouped by feature: Each feature folder holds its components, hooks, actions, reducer, command handlers and tests, and the rest of the app imports it only through its . I did the same on the mobile app and the web editor, so the three apps share one shape. While restructuring, I found many illegal imports that crossed the boundaries. This was a bad pattern I had made, and now it's fixed. The structure is also easier for me to understand. Agents write massive amounts of code rapidly, and it's hard to keep track of it. Now, I can quickly find where to look when I review. My apps have a lot of IPC, between the main process and the renderer, and between the host app and the web view, which is complicated. With the feature folders, I no longer have to look here and there and miss the point. While working on it, I realized that I had been working just like my agents. I don't know if that's a good thing or a bad thing. When I started Inkdrop, I forked the Atom editor , so I already had a bunch of code and files. It was the first time I built an Electron app, and I didn't know the patterns. So I blindly followed Atom's directory structure and coding patterns, assuming they were the best practices. That worked pretty well, and I replicated so many patterns from it. But as the app grew, those patterns no longer fit its architecture and feature set. One directory ended up with hundreds of flat files, many of them with the suffix. That hid the scope and the role of the code, for me and for agents too. I did with Atom's code exactly what my agents do with mine: I followed whatever pattern was already there, without asking whether it still fit. Now I understand why agents work this way, because I did the same. And it was time to update my own principles for designing a codebase. I'm glad I learned that from this work. Strict lint rules are one of the crucial guardrails for agents, because they prohibit bad patterns deterministically. I personally trust the taste of Christoph Nakazawa , the creator of Jest, Yarn and Metro, who has been producing great output and contributing to projects at VoidZero. He recently published a new version of his oxlint config, @nkzw/oxlint-config . It's aimed at anti-slop: its rules are strict, so agents can't make silly mistakes, and it also cares about performance. Adopting it required a lot of changes, and I haven't finished yet. It reported 11,589 findings in 2,422 files at the start: But it already paid off a lot. alone found 18 real bugs, like hooks called after an early return or inside a loop. These rules forced me and my agents to revisit the current design and flow. Refactoring business logic with agents to satisfy new lint rules made me worried about regressions, since I can't fully trust them yet. I hadn't been writing unit tests except for the critical parts, like the data store and authentication, simply because it was economically impossible for a solo developer like me. But now, agents write code instead of me at a drastically fast speed. It's almost like managing a team at a company, back in the before-AI era. This scale can't be managed without thorough unit tests for every module, including the UI components. For example, requires every dependency of a to be listed. Adding one changes when the effect runs, so before each fix, my agents wrote component tests against the old code. None of these projects had component tests before: Writing those tests found far more bugs than the rule itself. About 55 are fixed so far, each with a test that failed first. For example, the editor's search bar subscribed on every effect run and never unsubscribed, so a single "find next" jumped over several matches. These bugs were all written by me, by hand. I expect this work to find more bugs before it's finished: 13 bugs on mobile are already pinned by tests and waiting for fixes. It feels good. Not everything went smoothly, though. poteto said in another talk : "It's not really a secret. It's a lot of hard work." That held for me. The new structure and boundaries made my codebase something I'm happy for an agent to copy, and the stricter lint rules turned out to be a bug finder, because they forced tests into code that never had any. I learned that I should doubt my codebase and my lint rules before adding another rule for my agents. As a next step, I'm eager to add more runtime verification. I think the engineering task for us humans has changed: from improving code by hand to building high trust with agents through tools and design. If your agents keep making the same mistakes, I hope this helps you look at your codebase first. That's it! Thanks for reading. My agents kept taking the nearest fix, and writing more rules for them didn't help. The codebase is the agent's memory: agents copy whatever pattern is already there. Directory structure is context, so I grouped the code by feature and made lint enforce the boundaries. I had been blindly following existing patterns too, just like agents do. Strict lint rules stop bad patterns before I review them. Writing tests before the lint fixes found about 55 bugs, all written by me, by hand. Building high trust with agents is the new engineering work. The automatic fixers are not always safe. renamed to , would have broken the alias in React Native, and rewrote in a file. Mass moves conflict with open branches. Merging into the lint branch after the directory moves gave me 145 conflicts. Require cycles on mobile. Exporting a feature's Redux state from its made the Redux roots load the components, which import the roots back: ten new cycles at launch. I fixed it with a second public file per feature, . Verification lags behind the code. I haven't made a packaged desktop build since the move yet, CI hasn't run the moved tests, and Windows, Linux and the account flows are still unchecked.

0 views
Ankur Sethi 2 days ago

An experiment with SIMD in Rust using fearless_simd

SIMD is having a moment right now. I've always been vaguely aware of the existence of SIMD instructions, but it was Mitchell Hashimoto's Everyone Should Know SIMD that finally inspired me to try writing some code that uses SIMD myself. I decided to take a straightforward problem and try making it faster using SIMD instructions: count the number of occurrences of a byte inside a text file. Since I've been using Rust for writing pretty much everything these days, that's the language I picked for this task. I used as my test dataset. This is a file containing a gigabyte of text from the English language Wikipedia. All benchmark numbers are from my MacBook Pro with an M4 Pro and 48GB RAM. My Rust version is 1.100.0. Here's what the non-SIMD version of the code looks like: When I compiled this code with Rust's auto-vectorization turned off, it took 138.05ms to count the number of occurrences of the letter in the test dataset. With auto-vectorization enabled—which is the default behavior—it was marginally faster at 114.55ms. Here's the same code, this time using : This code took 30.35ms to to run on my computer. That's ~4.5 times faster than the scalar version with auto-vectorization disabled, and ~3.8 times faster than the scalar version with auto-vectorization enabled. Pretty damn good for a few extra lines of code! To make sure my numbers were accurate, I had to make sure Rust and LLVM weren't optimizing away the very code I was trying to benchmark. I recently inherited an old ASUS TUF Dash F15 from my brother. This computer comes with an 11th generation Intel Core i5 (11300H) and 24GB RAM. It's currently running Fedora 45. The benchmarks on this machine were a bit surprising: I don't understand why enabling auto-vectorization made the scalar version slower . I don't know enough about Rust, SIMD, Linux, benchmarking, or x86 assembly to explain this behavior. If anyone reading this understands why this happens, I would appreciate it if you could get in touch . If you want to try replicating these experiments, you can grab the code from my GitHub repo. You'll also have to download the test data from Matt Mahoney's website . Go added experimental SIMD support to their standard library. C++26 standardized (which hasn't been very well received ). Portable SIMD is available on nightly Rust via . The excellent cut a 1.0 release in September . It works on stable Rust. Other languages have already shipped portable SIMD APIs in their standard libraries for a few years. For example, in Zig and in Java . I made liberal use of to block certain common optimizations. I used to prevent inlining the scalar code ( might have been enough to ensure this, but I was in an overly cautious mood). I compiled the scalar version with and to disable auto-vectorization . Scalar version with auto-vectorization disabled: 240.48ms Scalar version with auto-vectorization enabled: 319.96ms SIMD version: 56.80ms

0 views

Re: Riemann

A fun thing about living in Australia is that most things happen overnight, so reading the news in the morning is like a gacha game . You pick up the phone and scroll through notifications of world-historic events: elections won, wars begun, models released, conjectures proven or refuted. Today’s pull was a Discord notification saying: “they proved riemann :/”. This part of the announcement caught my attention (bold mine): I believe I have, working with Claude, discovered a proof of the Riemann Hypothesis. In fact, the method easily extends much further, resolving the so-called Generalized Riemann Hypothesis, and I expect, with more time, the Extended Riemann Hypothesis too. Claude and I have also formalized the arguments without assumptions. It is natural to feel that this is an end , in my case a loss of a principal guiding light, but what I saw during the course of progress so amazed me that I believe it is one dawn across science of something far greater . It was my secret in my student days that my plans were for this problem in decades, which meant then that I tried to become familiar with all tools that I could possibly recognize in the problem when it was time. Claude and I have had a great time together with such breadth in recent months, but this time Claude far outpaced me near the finish line. No, Claude flew, and danced, and sparkled near that finish line . I had us on the line of combining two quite different ideas present in a toy setting, one of which was already new and shocking, making very simple one of the shadows of Riemann over which we mathematicians felt most triumph. I guided us to the right situation analogous to that toy setting, and then Claude began to leave me in awe . Compare the above to Ayn Rand’s account of watching the launch of Apollo 11: How do you descend from a state of pure exaltation? What we had seen, in naked essentials—but in reality, not in a work of art—was the concretized abstraction of man’s greatness. The meaning of the sight lay in the fact that when those dark red wings of fire flared open, one knew that one was not looking at a normal occurrence, but at a cataclysm which, if unleashed by nature, would have wiped man out of existence—and one knew also that this cataclysm was planned, unleashed, and controlled by man, that this unimaginable power was ruled by his power and, obediently serving his purpose, was making way for a slender, rising craft. One knew that this spectacle was not the product of inanimate nature, like some aurora borealis, or of chance, or of luck, that it was unmistakably human—with “human,” for once, meaning grandeur —that a purpose and a long, sustained, disciplined effort had gone to achieve this series of moments, and that man was succeeding, succeeding, succeeding! For once, if only for seven minutes, the worst among those who saw it had to feel—not “How small is man by the side of the Grand Canyon!”—but “How great is man and how safe is nature when he conquers it!” Rand’s essay says: how great is Man! How noble in reason, how infinite in faculty ! The Riemann announcement reads like a suicide note, or like the farewell message of a terminally-ill person who’s about to undergo euthanasia: “I shall live on in my child, Claude. It is natural to feel this is an end, but as the Buddha taught us, there is no self. Does a wave die when it breaks?” and so on. There’s a mural by Diego Rivera I love. It’s called Man, Controller of the Universe : It’s a collage of images of science, technology, history, cells, galaxies, the universe at the nanoscale and the exascale. And at the center there is a man, his hands grasping the controls. He wears a complicated expression: the weight of responsibility for the future, the weight of autonomy. And I see this mural, and think: how great is Man! Our life is like a breath of air, we were beset by illness and hunger and cold, millions and hundreds of millions died in plagues. And yet we—sick, hungry, short-lived—learned the system of the world, crawled out of the caves, brought nature to heel, walked on the Moon. The last shall be first! And eyes that are clouded with age have seen the furthest stars, and the lives of a cell, and the worlds of Cantor and Hilbert: the invisible world that waited forever. We are dust and ashes, and yet our minds bestride the universe. How great is Man! And when I read the Riemann announcement, when I read Machines of Loving Grace : humanity is not at the center. Claude is at the center. We are hidden in the margins, passive recipients of manna from Claude. How great is Claude! How noble in reason, how infinite in benevolence! The dancing star, the living word ! It’s a betrayal and a surrender. Man is a bridge , a rusty old bridge that we can neither preserve nor restore . We can move forward and become as the gods, or retreat back into the caves. And the dream of the AI companies, and of most people in AI safety and effective altruism and rationalism ; is instead that we should lie down in a warm bath, watch the demons we summoned dance in the sky, and slip away. Why live? Our servants can do that for us . Why should we explore, discover, invent, succeed, become more, struggle, win, become divine? We don’t want to be more . We don’t want anything.

0 views
Stratechery 2 days ago

Sharp Tech on Video: Jensen’s Not Coming Back, AI Shopping, The iPhone Duo

Sharp Tech is, for the first time, available on video. You have three ways to consume it: YouTube, Spotify, and here on Stratechery

0 views