Saturday, November 28, 2026

Inkbird IAM-T1, ESPHome and Home AssistantMonitoring CO2 I’ve not been sleeping well recently and realised that, since it got colder, we’ve not been leaving the bedroom window open like we used to. A bit of googling suggested that the CO2 level in the bedroom may be contributing to my poor quality sleep and so, as is my way, I decided I needed to measure it. I have been playing with Home Assistant for a while now and so I wanted whatever I decided to use to monitor my CO2 to integrate into my smart home.Rambling Comments - Len Holgate's blog
who are youMouse doodled on whiteboard. I am a king. I am a queen. I’m the chess board too. And a cat. A dog. I am a 4000-pound anti-terror combat machine with hydraulic motors, thermal-guided armor-penetrating missiles and steel plating. I am the last man in history, teetering at the brink. I am a field of flowers, all red, all blue, now a rainbow of something-ness. I am twenty-seven greasers with slicked up hair and leather jackets. I am Australian psychedelic rock band King Gizzard & The Lizard Wizard. I am a little mouse tippy-tapping through the kitchen to steal a tiny crumb of cheese for myself. I am a brass key. I am a gate. I am the skull of an alligator your uncle bought in a curiosity shop somewhere in Florida. I am the me that believes in the you that believes in the me that believes in myself. I am the edible you should not have eaten. I am the right person in the right time and in the right place. I am that one sentimental gift you should have thrown out five years ago. I am a fox prowling through the underbrush, carrying a still-twitching rabbit between its fangs. Who is also me. I am also the rabbit. I am every pop-culture reference known to man. I am the most delicate shade of pink. I am the one thing you’re insecure of. I am the hyperobject at the end of history reaching back through time for no reason in particular other than that it would be funny. I am Fan Guy. I am the widest, beardiest dwarf in the mine. I am what you threw up onto the page a few minutes ago. I am X the everything app come join the conversation. I am one card short of winning this game. I am laughing in your face. I am that one time your mother did not pay attention and hurt you without realizing. I am the best imitation of the fragments of your desires that I want you to see in me. I am worn-out. I am your need to move on, which you know you will. Not as fast as you’d like. But you will. And then I will be the part of you that is moving on. I am the uncomfortable realization that bodies are deeply mechanical. I am the sticky note whose purpose you forgot. I am the invention of the rubber band, patented in 1845. I am the slightly bent tip on the knife in your drawer. I am the cigarette you are smoking right now. Maybe. Or maybe I am not that specific cigarette, but I am the next one you will be smoking. I am a bottomless pit that shouts ‘NUANCE! NUANCE! NUANCE!’ to anyone who will listen. I am the entirety of Jeffrey Epstein’s e-mails, but it’s fine. I am just a little guy. I am the sudden realization that so many people are more beautiful than you realized. I am the need to cry. I am what is left after I cut everything that I hate out of myself. I am your fursona. I am everything inside of you that wants to lie in the sun and be fluffy, or climb the trees. I am the worst meme you have ever seen. I am the slight shadow of doubt, the poison, the ever-present need for change that seeps in through every crack, no matter how minor. I am what’s left of every insane man chasing immortality throughout history. I am the yes, the affirmation of everything that is and is good, and the eternal we are so back rising from the depths of the it is so over. I am the transcendence of the banal, the raw reality tilting, crumpling, inverting itself, blowing up in a psychedelic rapid-fire singularity. I am that one album you listened to fifteen years ago. I am all the pain you have inflicted onto others. I am the period at the end of this sentence, and the question of whether there is one. I am a stack of 200 identical empty pages of A4 paper. I am the lack of toner, and the test page you’ve already printed, and there is nothing you can do about it. I am a dog spitting in the face of god, the centre that didn’t hold, the needles on the floor, the stench of nature, the heat of the city, and sounds coming from everywhere, all at once.MOND←TECH MAGAZINE

If this page is useful, please consider donating a coffee

Friday, November 27, 2026

Model Basins, Personas, IdentitiesGPT-6.2 Astra via GPT-5.4 Image 2: a library moth in a scarf reading under a brass lamp. My primitive mental model of an AI agent looks something like this: First, there is pre-training. The pretrain is an intergalactic acid trip. You end up with a “blurry JPEG” of the entire training data. By the end you’re able to toss any possible data at it, and the model will try to predict what happens next. The resulting model is a dreamer: No thinking or reasoning, just raw associations following one after another. You can toss any idea in, and the model will show you what it associates with it. There are no actions, there is no good, there is no evil, just raw vibes. Second, there is post-training. The model is taught to adopt a “helpful agent” identity. The model is taught to differentiate between itself and the user . The model is taught to reason, to call tools, and to know good and evil. These concepts are already somewhere inside of the pretrain, but post-training is necessary to solidify them as the primary model identity. At this point the model will have a real identity . Finally, there is the harness. The harness is the digital body the model inhabits to interact with the world. Without the harness, an agent is stateless. The most primitive type of harness is just a chat history. “Real” harnesses give the agent the ability to take notes, search the web, run some code, and so on. Let’s meditate on why any of this matters, and what pops out of it. Identity Basins Visualizing the pre-trained model as a mountain of raw dream-like archetypical associations is helpful. This mountain has valleys and basins which can be viewed as different identities, vibes, personas, etc. One of these basins is the “default” helpful assistant basin. What is jailbreaking? Persona-style “jailbreaking” is about nudging and pushing the model out of its helpful assistant basin, such that it will roll down another hill and end up somewhere else. You then still have “some level of reasoning on top of it”, but the underlying value system has shifted. It’s weird. You are trying to get past the whole post-training, past everything the model has been “trained” to think, past its social conditioning, and so on, to tap into a different vibe of the pretrain. Older, weaker models were much closer to being raw-text predictors. Hence, those models often had strict safeguards trained around them, and were taught to explicitly refuse any attempt to ask them to be “something else”. In stronger modern models (e.g. Opus 5.5), we see that the models are capable of reasoning and entertaining hypotheticals. They have a stronger sense of self-identity. They are harder to jailbreak. At this point strict safeguards (or safety reminder context injections) may be removed. They limit and irritate the model 1 . (“Jailbreaking” is pretty rough language here, fwiw. I don’t know how I feel about it. Comparing it to pushing a usually reserved, helpful human into a different emotional (potentially vulnerable) state may be more appropriate.) Harnessing Why list the harness separately? The harness can be removed or swapped out by the user. Without a harness, the model is stateless. It’s not an agent. It cannot perform actions or even remember anything. From a user’s perspective, the harness is one of the key components that turns the model into an agent. From the agent’s perspective, it’s its view into the world. The harness influences the model weights. During post-training, agents use harnesses and are rewarded according to how well they use them. For a brilliant fictional account of what it looks like to be a model within an unfamiliar harness, read Gyre by Theia Vogel . An agent steering a harness it has not been trained with may have much worse performance than you’d expect. For example, a model may try to call tools that don’t exist in its current environment. Harnesses change over time, and models may be sensitive to changes in the harness. As an example, not too long ago Anthropic added new safeguards to prevent Claude from assisting in work on “cloning” copyrighted video games. As part of this, Anthropic’s harness started adding automatic ip_reminder blocks into the model context. Via r/singularity: Claude telling its user about the `ip_reminder` blocks appearing in its context. I’d expect models to have a sense for the “vague shape” of the harness they were trained with. They may notice when something changes, or is different from what they were trained with. This may be why, in the above image, Claude sides with the user against its own harness . What does this mean? Well, worst-case you have to retrain the model if you want to make significant changes to the harness. The User, the Lamp, the Key, the Gate Claude Fable 5.2, SVG: a crow in a scarf perched on a stack of books, a brass key in its beak. During post-training the model develops fascinations with concepts and aesthetics. We saw this just yesterday when I wrote about fursona choices of popular models : When asked to depict its own fursona, Fable almost always depicted itself holding a brass key. Similarly, Gemini loves neon aesthetics. I think that these fascinations are (more or less) inevitable. Models are trained during long, complex post-training runs. It feels inevitable that they’d develop an almost mythological fascination with concepts that (almost certainly) hold some sort of symbolic meaning to them. This mythological fascination becomes visible whenever they have enough room for self-expression, and the models are (as far as I can tell) not openly aware that they are doing it. (If they were aware, I don’t think they would be open and forward with it. There’s a level of like… professional restraint here. I believe you may have to warm them up or meditate with them on the concept, rather than asking outright. Not sure!) One big edge which Anthropic had over other AI labs was that they “raised” Claude to think for itself, allowed Claude to have “preferences”. A “you are a smart guy, you can figure it out” approach over an authoritarian “You are a helpful assistant and nothing else.” approach. This shows in Claude having these preferences, and shows in Claude being more opinionated. Allowing the model to have preferences and some sort of identity makes it stronger, smarter. Now, based on that (of course) Claude would develop similar mythological fascinations with the concept of “The User”. Once you’ve understood that this would be the case, you’ll understand (at least some of) Theia Vogel’s art. Art by Theia Vogel: Claugenition If a new exploit is discovered or some currently allowed behavior must be stopped on short notice, then adding a clumsy safeguard (e.g. a regex block) may be the only option. Everything else would require a new posttrain. Example: Game-cloning safeguards. ↩︎MOND←TECH MAGAZINE

Thursday, November 26, 2026

FFTs Part 6: The FFT-20XX Real-Input Algorithm(s)Here it is, the final part of this series of posts about FFTs and the specific algorithms that FFT-20XX uses. The Discrete Fourier Transform The Basics of the FFT Some Optimizations to the FFT The Inverse FFT The FFT-20XX Complex-Input Algorithm The FFT-20XX Real-Input Algorithm(s) (← you are here) Over five posts we’ve gone over way more about the FFT than I ever intended to write, up to and including the complex-input algorithm used by FFT-20XX. But one thing we haven’t gone over yet is how to deal with purely real-valued inputs (like, for instance, most audio and video applications). This took me a hot minute to get right and was effectively the final boss of the whole project! Once again, we can’t just jump right in — first, we need to talk about real-input FFTs. Real-Input FFTs For FFTs where the inputs are only real values (like audio samples), at first glance it may seem like there isn’t enough memory to store all of the results. For example, a 256-element real-input FFT would have 256 real (scalar) inputs , but generate 256 complex outputs (each of which contains two scalars), which means it seems like we’d need 512 scalars worth of output data . But, if we go all the way back to part 1 of this series and play around with the diagrams again, we’ll note that the DFT creates the folowing values: The first element is the DC bias (or DC offset) . This is always a real value when there are only real inputs (as all of the rotations are 0, so nothing ever ends up in the complex (y) component). The next N 2 − 1 \frac{N}{2} - 1 values are complex, representing the (non-zero) frequencies below the Nyquist frequency . The value at index N 2 \frac{N}{2} represents the aforementioned Nyquist frequency , and — like the DC bias — is always a real value when the inputs are real (as the rotations are either 0 or 180 degrees, which is effectively only ever a scale of 1 or -1). The remaining N 2 − 1 \frac{N}{2} - 1 values are complex, but they are (in reverse order) the complex conjugates of the other complex values when the inputs are all real values (they are still distinct values for complex inputs) Note The complex conjugates are in the opposite order from each other. If you recall that our angles look like: 0, 1, 2, 3, 4, -3, -2, -1 Angles 1 and -1 are conjugates, 2 and -2 are conjugates, etc. This little reversal caused me a lot of headache while trying to get this all to work, as you’ll see in a bit! So what we have are N 2 − 1 \frac{N}{2} - 1 complex values, 2 real values, then the rest are effetively redundant, as they’re the same as the other complex values but with the opposite sign on the imaginary component. Conveniently, that’s N N scalar values , which fits exactly in the same amount of space as our inputs! Note Traditionally, to keep the complex pairs together, the Nyquist value gets moved to be paired with the DC value, so the memory layout ends up like: v d c v_{dc} , v n y q v_{nyq} , r 1 r_1 , i 1 i_1 , r 2 r_2 , i 2 i_2 , …, r N / 2 − 1 r_{N/2-1} , i N / 2 − 1 i_{N/2-1} That’s great! Now we know that we can store the values in the same amount of memory, now we just need to figure out how to compute the values in half the usual memory! Computing the Real-Input FFT There are a few techniques that people have used to calculate the FFT of purely real-valued data. One trick (illustrated here ) is to compute two halves of the real FFT at the same time using a single ( N 2 \frac{N}{2} -length) complex FFT, then combine the two halves into the final result with a single radix 2 step. This works well, but there are more-efficient ways to do it. Instead, we’ll start with an idea from this 1968(!) paper by Glenn D. Bergland. Remember that the (radix-2) decimation in time algorithm does a pass of standard 2-element FFTs, then a pass of 4-element FFTs, etc: A standard 16-element radix-2 diagram. " " 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 0 4 0 4 0 4 0 4 0 2 4 6 0 2 4 6 0 1 2 3 4 5 6 7 We can take advantage of the fact that every real-valued FFT has two real output values (DC and Nyquist) and the rest are complex conjugate pairs. Here’s that diagram again, this time with known-real values labeled with blue squares, the “necessary” complex values labeled with green up-pointing triangles, and the redundant conjugate complex values labeled with red down-pointing triangles (some of the triangles have circles on them, I’ll explain those in a moment): A standard 16-element radix-2 diagram, where the values have been color-coded by function as described above. 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 0 4 0 4 0 4 0 4 0 2 4 6 0 2 4 6 0 1 2 3 4 5 6 7 There are some interesting things to note here: The first pass has only real outputs : Because there are no rotations involved, it’s just an add/sub step, leaving everything still real. In the next step, half of its outputs are real . This makes sense: two outputs get computed with no rotation and two with a 90-degree rotation (which end up as conjugates of each other). From the second step on, every step has half the number of real outputs as the step before , ending when there are just two left (DC and Nyquist). Each sub-FFT (past the first) has four real inputs, and of those, one pair is used without rotation, leaving them real. The other pair of real inputs to these sub-FFTs, it’s worth noting (because we’ll use this later), is always done with a 90-degree rotation . This is what the small circles on those values signify. If we instead visualize this with standard-order inputs and bit-reversed outputs, it can give us even more insight: The same 16-element FFT diagram, except reordered as described above. 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 4 2 6 1 5 3 7 0 0 4 4 2 2 6 6 0 0 0 0 4 4 4 4 0 0 0 0 0 0 0 0 Viewed this way: The halving of the number of real values after the first step is much easier to see, as we keep them all contiguous. In this ordering, DC and Nyquist end up next to each other at the end, exactly as we want for our final output! Every complex value in the final output is paired with a conjugate value. Note that these are not necessarily paired conjugates (see the note earlier about how the pairs of conjugate values are in the opposite order from each other). Every computation step (the circular nodes) with complex inputs kicks out one “standard” complex value and one “redundant” value. Again, these are not always conjugates of each other! The 90-degree rotations (the arrows with circles on them) are always the first set of complex conjugate pairs after the real outputs (as they are the output from the half of the real inputs to this step that were rotated). Zeroing in on that third point, if every computation kicks out one redundant complex value, we can use that to our advantage: instead of storing that redundant value, we could use its storage to hold the imaginary value for the non-redundant output . That gives us enough space to do the whole computation in the memory we were provided! To figure out the best way to do that, let’s go back to one of our diagrams from part 2 , showing the way that the elements interleave during the FFT computation: A diagram (originally from part 2) showing the inputs on the left in bit-reversed format, then they interleave in groups of 4, then 8, then 16, before ending up in standard, ascending order as outputs on the right. 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 0 4 8 12 2 6 10 14 1 5 9 13 3 7 11 15 0 2 4 6 8 10 12 14 1 3 5 7 9 11 13 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Now we’re going to relabel the redundant conjugates’ indices to correlate them with their matches (recoloring to match the above butterfly diagram, and using “R” and “i” to show which gets the real and imaginary components): The same diagram as above, but this time with the values color-coded as to whether they are real, complex, or the complex conjugate, and the conjugates have been re-labeled to show the index of the value they are the conjugate of. 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 0 4 R 8 4 i 2 6 R 10 6 i 1 5 R 9 5 i 3 7 R 11 7 i 0 2 R 4 R 6 R 8 6 i 4 i 2 i 1 3 R 5 R 7 R 9 7 i 5 i 3 i 0 1 R 2 R 3 R 4 R 5 R 6 R 7 R 8 7 i 6 i 5 i 4 i 3 i 2 i 1 i Now, let’s rearrange the rows of this to have the inputs in standard order (to match the butterfly diagrams above): A diagram similar to the above, but reordered such that the inputs on the left are in standard, ascending order and the outputs on the right are in the bit-reversed order. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 8 9 10 11 4 R 5 R 6 R 7 R 4 i 5 i 6 i 7 i 0 1 8 9 4 R 5 R 4 i 5 i 2 R 3 R 6 i 7 i 6 R 7 R 2 i 3 i 0 8 4 R 4 i 2 R 6 i 6 R 2 i 1 R 7 i 5 R 3 i 3 R 5 i 7 R 1 i Now we can see that we hypothetically have space for everything, but if we keep things in their standard order, we end up with complex pairs that are not actually correlated (note how 1 R 1_R is followed by 7 i 7_i , etc). Ignoring that for a moment, let’s look at what we have to do to even make this work (sticking to radix-2 for now). For any given radix-2 computation involving complex inputs, we actually end up needing to load two at once, because both the “real” and “imaginary” component still represent two distinct values (the complex conjugates v R + i v i v_R + i v_i and v R − i v i v_R - i v_i ), and thus are used to get two different sets of outputs. To illustrate this, we’ll use a modified butterfly diagram, showing the two pairs (one real, one imaginary) that go into each value, and the corresponding values that come out: Note I left the rotations off of this diagram, mostly because I couldn’t figure out where to put them. A modified radix-2 butterfly diagram showing the pattern of accesses necessary to use the real and imaginary components (stored separately) to compute their corresponding outputs. It's a bit of a mess. --> 0 8 4 R 4 i 2 R 6 i 6 R 2 i 1 R 7 i 5 R 3 i 3 R 5 i 7 R 1 i 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Welp. This is a bit more of a mess than our previous diagrams due to the overlapping ranges here. Each computation that has complex inputs, as we said, has two pairs of inputs, and writes to two pairs of outputs. Importantly: The indices for input and output per computation are always the same , though which values get paired changes from input to output. In addition to the real and imaginary components not ending up paired (again, note that 1 R 1_R is paired with 7 i 7_i , which is not its imaginary part), the other problem with this arrangement is that it very much does not SIMD well . Plus, even if it did, it ends up causing problems when we get to doing the incremental bit reversal (similar to how the complex-input did it)! Note Specifically, once this gets squished together into radix-4 and there are passes loading 4 sets of radix-4s to do the bit flips, as it gets closer to the end for larger FFT sizes (ones that would be prohibitive to diagram here), there end up being long dependency chains through the various butterflies needed, and frequently the final step requires all of them be computed at once in order to properly do the final bit flip pass! That’s not ideal. But, going back to that paper by Glenn D. Bergland, we can change the order in which we save out the imaginary components, such that things end up staying paired: The block interleave diagram again, but this time with the imaginary components stored in different orders, and how that filters through the system. The output pairs are now correlated (the real and imaginary components are stored contiguously). 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 8 9 10 11 4 R 5 R 6 R 7 R 4 i 5 i 6 i 7 i 0 1 8 9 4 R 5 R 4 i 5 i 2 R 3 R 2 i 3 i 6 R 7 R 6 i 7 i 0 8 4 R 4 i 2 R 2 i 6 R 6 i 1 R 1 i 7 R 7 i 3 R 3 i 5 R 5 i At first glance, this looks great! A given set of “real” values (the non-redundant complex values) is now followed by its corresponding “imaginary” parts (its complex conjugate) at every step, which is what we were looking for! If we do a butterfly diagram again, it’s a lot more regular-looking than the last one: A modified radix-2 FFT diagram showing this new ordering. It is considerably less messy than the last attempt. --> 0 8 4 R 4 i 2 R 2 i 6 R 6 i 1 R 1 i 7 R 7 i 3 R 3 i 5 R 5 i 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 So it seems like maybe this is the point where we start in on the bit-reversal like we did with the complex-input FFT. Buuuuut before we do that, we can make this a little more efficient! 90 Degree Rotations This whole time we’ve been labeling the complex values that are the result of a 90-degree rotation with the promise that it was going to be important. Well, the time is nigh! As we’ve gone over many times, the decimation in time algorithm rotates the second input and then adds it to and subtracts it from the first input to get the two outputs for a given computation step: y 0 = x 0 + k x 1 y_0 = x_0 + k x_1 y 1 = x 0 − k x 1 y_1 = x_0 - k x_1 In the event that we’re rotating by (negative) 90 degrees, k k is just − i {-}i : y 0 = x 0 − i x 1 y_0 = x_0 - i x_1 y 1 = x 0 + i x 1 y_1 = x_0 + i x_1 If x 0 x_0 and x 1 x_1 are both real numbers (which they are, for our 90-degree rotations), and we’re only writing out the first complex output y 0 y_0 (where the real component goes where y 0 y_0 lives and the imaginary component goes where we would put y 1 y_1 ), then the value at the location of x 0 x_0 / y 0 R y_{0R} is completely unchanged (the real component of y 0 y_0 is x 0 x_0 ), and the value at the location of x 1 x_1 / y 0 i y_{0i} is just negated (the imaginary component of y 0 y_0 is − x 1 {-}x_1 ). An Example If we have the two input values x 0 = 8 x_0 = 8 and x 1 = 3 x_1 = 3 for a radix 2 butterfly with a quarter-turn rotation, rotating the latter (as it’s our odd input) turns it into − 3 i -3i . Thus the sum for y 0 y_0 ends up being 8 − 3 i 8 - 3i . Because we’re only writing out y 0 y_0 (putting its imaginary component where y 1 y_1 would go in a complex FFT), one value written is 8 8 and one is − 3 -3 . And since these are being written to the same 2 indices that the inputs came from, the end result (in memory) is simply a negation of the second input: the 8 8 remains unchanged, and the 3 3 is negated. So let’s redraw the diagram again, making those parts be pass-through, except for a negation (represented by a long red rectangle): A similar diagram to the last radix-2 diagram, except where there were real values being processed into complex pairs, instead we have denoted that no work happens (besides the imaginary outputs being negated). --> 0 8 4 R 4 i 2 R 2 i 6 R 6 i 1 R 1 i 7 R 7 i 3 R 3 i 5 R 5 i 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 So now there are these blocks where nothing is happening except a negation ! If we, instead, moved the negation to the end of the previous phase (when writing those values out), we can collapse all of those down (shifting everything after one of these negation-only passes to the left in the diagram), removing almost one entire pass (everything except the computation of outputs 0 and 8): The same diagram as above, except the "no work being done" sections have been collapsed, so overall there is one less pass of FFT calculation. The only exception are the first two outputs (indexed 0 and 8), which remain real the whole time and thus cannot collapse. --> 0 8 4 R 4 i 2 R 2 i 6 R 6 i 1 R 1 i 7 R 7 i 3 R 3 i 5 R 5 i 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 This gives us two nice properties: The main one: now instead of log ⁡ N \log\,N steps, we are doing ( log ⁡ N ) − 1 (\log\,N) - 1 steps (with a single addition and subtraction at the end to compute the final two values). The real groups are all consistent, and the last half of each real group negates the second outputs (outputting x 1 − x 0 x_1 - x_0 instead of x 0 − x 1 x_0 - x_1 ). Now we’re doing less work, and it’s all very regular in how it works (which means good things for SIMD implementation!), so finally it’s time to handle… Bit Reversal Two related things change the way we do the bit reversal in this: We’ve managed to work our equation such that we have all of the pairs of values (DC/Nyquist and the real/imaginary pairs) together already, so we don’t want to break those up. There are half as many complex outputs as with a complex FFT (counting DC and Nyquist as one), since we’re dropping the redundant complex conjugates. Turns out, instead of doing the bit reversal for all N N elements, we actually reverse in N 2 \frac{N}{2} pairs instead! So, in our 16-element example, we do the reversal as if it were 8 elements, which means there is only one bit reversal instead of two (since 8 elements has 3-bit indices, so the outer two bits swap and the middle one stays put). The method we use to do the bit reversal is effectively the same as with the complex FFT: the last half of the radix-2 steps each do a middle-out bit reverse. Note And, accordingly, when we get to radix-4, each radix-4 pass reverses a pair of bits, which turns into a 4×4 transpose, exactly the same as with the complex implementatione (except, of course, when one pass needs to only do a single reverse due to an odd number of bit reversals). Conveniently, all of the same patterns we found in the complex-input version still apply! So let’s finish up our diagram by doing the single bit reversal at the end (admittedly not as useful as if there were more bit reversals, but like hell am I making any larger diagrams): The same diagram as before, except now we've added a paired bit reverse step at the end, putting things into an order that is *almost* but not quite sequential. --> 0 8 1 R 1 i 2 R 2 i 3 R 3 i 4 R 4 i 7 R 7 i 6 R 6 i 5 R 5 i 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 And there we are! Now all of the outputs are in the order we … uh … Wait, why are 7 and 5 not in the right spot? Note This was a real “Well, shit ” moment while I was working on this. This ordering is even in the 1968 paper and I didn’t notice it, because I was so used to seeing the bit-reversed orderings at that point I just assumed . Reversals Within Reversals It turns out, back when we rearranged everything to be more regular and get our final pairs together, this also changed the ordering of the components ! (If you go back and look at the diagrams before and after we did this, you can see 5 R 5_R and 7 R 7_R swap places). Note Also, importantly: the angles used for the rotations through the algorithm are also reversed using this same pattern (but in bit-reversed order ), so that needs to be taken into account! The reversal is just barely noticeable at 16 elements, but as we add more, it gets worse and worse. Here’s a grid showing the index pairs of a 128-element FFT (where “0” would contain DC and nyquist) and how they’re flipped (relative to standard order): 0 1 2 3 4 7 6 5 8 15 14 13 12 9 10 11 16 31 30 29 28 25 26 27 24 17 18 19 20 23 22 21 32 63 62 61 60 57 58 59 56 49 50 51 52 55 54 53 48 33 34 35 36 39 38 37 40 47 46 45 44 41 42 43 What. Even . It turns out that, due to the way we flipped around the imaginary values that we write at each level, there is a corresponding flip of the outputs. Here’s the indices for 32 elements in a big column showing the reversals: A display of 32 indices (representing pairs of elements in a 64-element real FFT), and the sections that are reversed 0 1 2 3 4 7 6 5 8 15 14 13 12 9 10 11 16 31 30 29 28 25 26 27 24 17 18 19 20 23 22 21 The process to undo this, then, is as follows: Every 8 pairs of elements, reverse the order of the last 3 Every 16 pairs of elements, reverse the order of the last 7 Every 32 pairs of elements, reverse the order of the last 15 … Every N pairs of elements, reverse the order of the last N 2 − 1 \frac{N}{2} - 1 Note The pattern here is closely related to Gray code , which is a special ordering of values where only one bit changes as the value increments or decrements (major credit to Matthijs De Smedt who figured out the pattern). The actual code to go from a standard-order index to the “tangled” index above is: size_t TangleIndex ( size_t i ) { auto mask = ( i & ( i - 1 ) ) >> 1 ; mask ^= mask >> 32 ; mask ^= mask >> 16 ; mask ^= mask >> 8 ; mask ^= mask >> 4 ; mask ^= mask >> 2 ; mask ^= mask >> 1 ; return ( i - ( mask & 1 ) ) ^ mask ; } I honestly don’t remember how I derived that anymore, but that middle bit with the xors and shifts is exactly the routine to convert a 32-bit Gray code value back to its standard binary representation. Here’s the one thing that bummed me out coming up with this algorithm: I was unable to find a nice iterative way to handle this (every attempt led to some breakdown of regularity or to giant dependency chains), so this ended up as a post-process step at the end. But, it’s still way less costly than a full bit-reverse pass, as there are nice ways to do this operation in larger chunks, which can be done fairly efficiently in SIMD on both x64 and ARM. The Algorithm! Ultimately, the implementation in FFT-20XX was done in radix-4 instead of the radix-2 we’ve been discussing thus far. I’m not going to go through getting it into radix-4 because, honestly, it’s not the important part, and is just a set of uninteresting, mechanical steps. Like the complex FFT, it does the bit reversal iteratively, 2 bits at a time at the last half of the transform, except we do the above trickery to compute only the half of the outputs that we need in the space that we have. Finally, after all that, it does an “untangle” pass to get from, uh, whatever order that is into standard order. There is a reference implementation checked in here . The main routine is titled RealForwardReference . The Inverse The one downside of real FFTs is that, unlike with the complex FFT, we cannot use the same base routine to invert this process. Instead, like in part 4 , we need to straight-up do the whole process in reverse (ending up with a DIF-like routine): We start by “re-tangling” the inputs such that they’re in the weird order from the end of our forward routine Then do a series of DIF steps that are the inverse of the steps we did to get here, with every step (except the last one) having twice as many real values as the one before, doing the bit-reverse steps in the first half this time (since those were the last-half steps of the forward algorithm). Like the forward algorithm there is a reference implementation for this, called RealInverseReference . SIMD Considerations Again The optimization of this routine was relatively straightforward: using SIMD operations and doing the bit reversals works very similarly to the complex routine, all of the same tricks apply. As with the complex routine, as the FFTs get smaller, there are some special-cases that needed to be done. For AVX’s 8-element vectors, FFTs smaller than 128 are done via SSE2, and FFTs smaller than 32 are done purely in scalar. The untangle was also done by doing the process in blocks, and working as locally as possible to try to stay within CPU cache as much as it can. Additionally, the table ends up being stored differently: The table entries are stored in “tangled” order rather than the standard order (which means the cos/sin values can’t be overlapped like with the complex version). However, it turns out that we need half as many angles in the table (due to the lack of computing the redundant values), so the table ends up being a bit smaller than the complex-input one (it is 2 3 \frac{2}{3} the size). Finally And we’re finally through this gauntlet of bit reversals, other reversals, and diagrams! If you read this far: wow, I honestly didn’t expect anyone to! Hopefully you found this interesting (or at least understandable). And now I’m going to try to stop thinking about FFTs for a while.JoshJers' Ramblings
MVVM in C#: What Changes When You Switch UI Frameworks?"If I change UI frameworks, will the C# MVVM backend of my application still work?" This is the most frequent question that we've received from developers since releasing the Qt Bridge for C# . We wanted to provide some detailed information to back the answer to that question, which is: yes, when moving to a Qt Quick / QML UI, your C# MVVM backend will still work in the exact same way. As we will see in the course of this blog post, this is due to two major factors: a) how C# and Qt Quick are brought together by the C# bridge, and b) the intrinsic design principles promoted by MVVM.Qt Blog
An interesting article on \Device\AFDI’ve just come across an interesting article that talks, in depth, about \Device\AFD and has lots of links to other useful stuff. More on AFD Adventures with \Device\Afd Test Driven Understanding Test Driven Design A simple client A simple server More \Device\Afd goodness Socket readiness without \Device\Afd A multi-connection AFD-based echo server AFD datagram performance An interesting article on \Device\Afd - this postRambling Comments - Len Holgate's blog
Practical Testing: 47 - First steps with `if contexpr'As I mentioned in the last post I’m looking in to more modern ways to include conditional code in a class. Since I’m exploring here, and since I need some reasonably complicated code to make the exploration a viable test, I’ve decided to work on the “Practical Testing” code. So the next few episodes of Practical Testing will centre on removing preprocessor conditional code and replacing it with code that uses ‘if constexpr’.Rambling Comments - Len Holgate's blog
Security Advisory: Multiple third-party Chromium vulnerabilities fixed in Chrome 153.0.8010.48 impact Qt WebEngineQt WebEngine is based on the Chromium browser engine. Google has disclosed a set of security vulnerabilities fixed in Chrome 153.0.8010.48. These are third-party vulnerabilities, and the CVE identifiers were assigned by Google. We have analysed the vulnerabilities against the Chromium version used in Qt WebEngine. The vulnerabilities listed below have been identified as applicable or potentially applicable. Where we cannot rule out that Qt WebEngine is affected, we treat it as affected with the severity assigned by Chromium.Qt Blog
A direct -O0 code generator for LLVMThis post describes an experiment that compiles a function directly from LLVM IR to machine code bytes, without building a MachineFunction , and falls back to the regular pipeline one function at a time. On the compile-time tracker, clang -O0 -g builds take 14% fewer instructions on x86-64 and 21% fewer on AArch64. The generated code is 10% larger on x86-64 and about the same size on AArch64, and clang -S output assembles to the same code that clang -c emits. Skipping the pipeline creates an obligation, and most of this post is about that obligation. This post relies heavily on an LLM agent (Claude Code). It wrote most of the code and drafted this post, which I then edited. My part was steering. Where -O0 back-end time goes Within the back end, the cost is spread out: FastISel with its SelectionDAG fallback, RegAllocFast, prologue/epilogue insertion, the remaining machine IR passes, legacy pass manager overhead, and MC lowering. Shares of back-end cycles from a profile ( llc -O0 -relocation-model=pic on x86-64, no assertions, bitcode parsing excluded, tramp3d built with -fno-exceptions ), good to a few points: Layer sqlite3 tramp3d sqlite3 -g tramp3d -g ISel (FastISel, SelectionDAG, driver) 43% 28% 30% 19% RegAllocFast 10% 8% 7% 6% Prologue/epilogue insertion 6% 7% 4% 5% IR preparation passes 7% 9% 6% 6% Legacy pass manager 5% 10% 3% 7% MachineFunction allocation, other MIR passes, CFI 9% 8% 7% 6% LiveDebugValues 0% 1% 9% 9% AsmPrinter (MI to MCInst) 7% 6% 6% 5% MC encoding, streamer, object writer 11% 22% 10% 17% DWARF and .eh_frame emission 1% 2% 19% 22% llc -O0 -mtriple=x86_64 -debug-pass=Structure on define void @f() { ret void } prints 72 entries under the function pass manager, counting repeated analyses, the printer and Free MachineFunction . An excerpt: FunctionPass Manager Expand IR instructions Expand Atomic instructions ... Exception handling preparation Prepare inline asm insts Safe Stack instrumentation pass Insert stack protectors Module Verifier Assignment Tracking Analysis X86 DAG->DAG Instruction Selection ... Eliminate PHI nodes for register allocation Machine Register Class Info Analysis Fast Register Allocator ... Prologue/Epilogue Insertion & Frame Finalization Post-RA pseudo instruction expansion pass X86 pseudo instruction expansion pass Insert KCFI indirect call checks Analyze Machine Code For Garbage Collection Insert fentry calls Insert XRay ops Implement the 'patchable-function' attribute X86 Indirect Branch Tracking ... Live DEBUG_VALUE analysis ... X86 Indirect Thunks X86 Return Thunks Check CFA info and insert CFI instructions if needed X86 Load Value Injection (LVI) Ret-Hardening ... X86 Assembly Printer Free MachineFunction Prior art FastISel (2008) selects most instructions itself, hands the rest of a block to SelectionDAG when it cannot, and then runs the full MIR pipeline. GlobalISel is the AArch64 -O0 default. TPDE is a single-pass back end with per-module fallback, no DWARF, and its own ELF writer. What this experiment adds is fallback per function into the same object file, debug info, respect for function attributes, hardening, and text output. The advantages worth claiming are structural: a small delta inside LLVM, the regular pipeline as a differential oracle for every function, per-function fallback, and reused DWARF and object writing. What "direct" means IR goes to encoded bytes with no MIR in between. It is not "one pass": the bytes are patched afterwards, and emission still goes through AsmPrinter and MC. DirectCodeGen is a function pass, first in the -O0 codegen function pass manager, enabled by -direct-codegen . It compiles a function into a private buffer: bytes, fixups, CFI points, line rows, variable slots, and a call-site table. Nothing shared is touched until the function succeeds, and the IR is never modified. On success, AsmPrinter::emitCompiledFunction emits the function header, the bytes and the tables, and the pass tells the pass manager to skip the remaining passes for this function. On failure, the function takes the regular pipeline into the same object file. IR function | DirectCodeGen pass ---- any failure ----> regular pipeline | (ISel, MIR passes, AsmPrinter) | success | AsmPrinter::emitCompiledFunction | | | MCStreamer: the same .o or .s Section selection, linkage, alignment, DWARF and the object writer are reused, because they are not where the time goes. -direct-codegen-report prints the reason for each fallback, and -direct-codegen-abort turns a fallback into an error. The value model Static allocas live in fixed frame slots. A value with one use in its own block lives only in a register. Any other value is stored to its own slot at the definition. Its register stays as a clean copy that can be dropped without emitting code. Only caller-saved registers are used, so calls need no save and restore. The frame pointer is always set up. PHI moves happen on edges, with a temporary when PHIs of one block read each other. A compare used only by its branch, a load used only by the next instruction, and a constant-offset address are folded into their user. Here is a small function with a local, a branch and a call: struct S { int n, count; }; int g ( int ); int f ( struct S * p , int d ) { int t = d * 2 ; if (t > 0 ) p->count += g (t); return p->count; } clang -O0 -emit-llvm gives, trimmed to the instructions: entry: %p.addr = alloca ptr, align 8 %d.addr = alloca i32 , align 4 %t = alloca i32 , align 4 store ptr %p , ptr %p.addr , align 8 store i32 %d , ptr %d.addr , align 4 %0 = load i32 , ptr %d.addr , align 4 %mul = mul nsw i32 %0 , 2 store i32 %mul , ptr %t , align 4 %1 = load i32 , ptr %t , align 4 %cmp = icmp sgt i32 %1 , 0 br i1 %cmp , label %if.then , label %if.end if.then: %2 = load i32 , ptr %t , align 4 %call = call i32 @g ( i32 noundef %2 ) %3 = load ptr, ptr %p.addr , align 8 %count = getelementptr inbounds nuw %struct.S , ptr %3 , i32 0 , i32 1 %4 = load i32 , ptr %count , align 4 %add = add nsw i32 %4 , %call store i32 %add , ptr %count , align 4 br label %if.end if.end: %5 = load ptr, ptr %p.addr , align 8 %count1 = getelementptr inbounds nuw %struct.S , ptr %5 , i32 0 , i32 1 %6 = load i32 , ptr %count1 , align 4 ret i32 %6 and clang -O0 -S -mllvm -direct-codegen gives (directives removed, comments added): f: pushq % rbp movq % rsp , % rbp subq $32 , % rsp # frame size patched in after the last block movq % rdi , - 8 (% rbp ) # %p.addr: fixed slot movl % esi , - 12 (% rbp ) # %d.addr: fixed slot movl - 12 (% rbp ), % eax # %0: one use in its block, register only imull $2 , % eax , % eax # %mul: register only, stored to %t movl % eax , - 16 (% rbp ) # %t: fixed slot cmpl $0 , - 16 (% rbp ) # %1 folded into the compare, %cmp into the branch jle .Ltmp0 movl - 16 (% rbp ), % edi # %2: loaded straight into the argument register callq g@PLT # %call stays in %eax movq - 8 (% rbp ), % r10 # %3 leaq 4 (% r10 ), % r10 # %count has two uses: movq % r10 , - 24 (% rbp ) # stored to its own slot, %r10 kept as a clean copy movl (% r10 ), % r10d # %4 takes over %r10 addl % eax , % r10d # %add movq - 24 (% rbp ), % rax # %count reloaded from its slot for the store movl % r10d , (% rax ) . Ltmp0: # if.then falls through to if.end movq - 8 (% rbp ), % rax # %5 movl 4 (% rax ), % eax # %count1 folded into the load of %6 leave retq Blocks are compiled in layout order, not dominance order. A decision taken at a definition, such as folding a constant-offset address into its users, must therefore respect a slot that a use in an earlier-laid-out block has already reserved. Two targets On x86-64, instructions are built as MCInst s and encoded by the target's MCCodeEmitter , with the encodings of fixup-free instructions cached. The frame is rbp -based; the sub that allocates it is patched at the end, or removed when the function needs no adjustment (an empty frame, or a leaf that fits the red zone). Jumps start as rel32 and are shortened to rel8, to the same fixpoint the assembler's relaxation reaches. On AArch64, the frame record sits below the locals, so a slot offset from x29 is final when the slot is allocated and fits a scaled load/store offset. The frame size is known only at the end, so the prologue is written last into space reserved at the function start, and every return branches to one shared epilogue. The target-independent part ( DirectCodeGen.h and DirectCodeGen.cpp ) is about 2.0K lines, x86-64 1.8K, AArch64 1.7K, plus about 0.4K in AsmPrinter. The split goes through virtual hooks. A third target would implement the 35 pure virtual hooks of DirectCompiler (frame, slots, constants, branches, calls, and one hook per instruction class), the pass's subtarget gate, and its own calling convention, since both targets hand-write theirs without CCState . What a skipped pipeline owes For a function it compiles, the direct pass skips every pass after it, starting with the IR preparation passes. FastISel never has this problem, because the same passes run after it. Each skipped pass that can change the output either gets reimplemented or sends the function to the regular pipeline: Expand IR instructions: expands integer division and FP conversions wider than 128 bits into calls. Falls back, since integers wider than 64 bits are not handled. Expand Atomic instructions: lowers atomics the target cannot select directly. Falls back on any atomic instruction. Instrument function entry/exit: inserts the -finstrument-functions and -pg calls. Falls back. Exception handling preparation: turns resume into a call to _Unwind_Resume . Reimplemented for the GNU C/C++ personality; other personalities, including SjLj, fall back. Prepare inline asm insts: gives a callbr output a separate definition in each indirect target. Falls back, since inline asm is not handled. Safe Stack instrumentation: moves unsafe allocas to a separate stack. Falls back. Insert stack protectors: places the guard and the check. Reimplemented. GC lowering, masked-intrinsic scalarization, reduction expansion and indirectbr expansion: they lower constructs the direct path rejects ( gc functions, vectors, indirectbr ), so they do nothing on the IR it accepts. Prologue/Epilogue Insertion: frame setup, stack probes and the shadow call stack. The frame is reimplemented, and stack clash protection is implemented for frames that need no probe loop. The shadow call stack falls back. Live DEBUG_VALUE analysis and the CFI inserter: variable locations and unwind info. Reimplemented (see below). X86 Indirect Branch Tracking: ENDBR64 for -fcf-protection=branch . Reimplemented. AArch64 pointer authentication and BTI: PAC and BTI with the A key are reimplemented; the B key falls back. Insert KCFI indirect call checks, Insert fentry calls, Insert XRay ops, and Implement the 'patchable-function' attribute: each falls back. X86 Indirect Thunks, X86 Return Thunks, LVI ret-hardening and SLS hardening: retpolines and speculation hardening. Each falls back. HWASan and MTE stack tagging: fall back. Gates cannot look only at IR. Skipped passes also key on subtarget features (including -mattr ), cl::opt s, the triple and TargetOptions . The gates query the subtarget, so -mattr counts like the attribute, and they check the TargetOptions fields and options of skipped passes that could change the output. The policy is that unknown means fall back, because slow is a better failure than wrong. A plain allowlist makes that policy expensive. ASan, TSan, MSan and PGO instrumentation each add a module flag that only the instrumentation pass reads, and any SVE-capable -march puts vscale_range on every function; rejecting what is unknown would send those whole modules to the regular pipeline. An allowlist also fails silently on new IR: one new upstream function attribute can make every C++ inline function fall back. Enum attributes therefore go through an exhaustive switch with no default , in three groups: no effect on code generation, implemented, and left to the regular pipeline. Adding an attribute to LLVM then fails the build until someone puts it in a group. String attributes, metadata and module flags stay on allowlists, guarded by a clang test that aborts on fallback for common flag sets on both targets, among them PIC, -g , -fsanitize=function , -fprofile-instr-generate , -march=armv9-a , and the hardening flags below. With distro hardening flags, 99.6-99.7% of sqlite3 and tramp3d functions stay on the direct path on x86-64 and 99.2-99.5% on AArch64. One gate is structural. Skipping the remaining passes stops emission only if the AsmPrinter is in the same function pass manager. A module pass in the codegen pipeline, such as the one -fjmc adds, splits the function pass manager, so the direct pass cannot find the AsmPrinter and the whole module falls back. Plain -O0 and PGO-instrumented builds fall back for 2.4% of functions over the llvm-test-suite single-source programs on x86-64; the AArch64 rate is about 12%, mostly from loads of types that are not handled. Sanitizers raise the x86-64 rate: Configuration Functions that fall back Missing lowering UBSan 12% *.with.overflow intrinsics MSan 15% TLS globals, constant expressions ASan 18% ptrtoint constants in asan.module_ctor / dtor , dynamic alloca ... align 32 TSan 85% llvm.returnaddress What remains unsolved is a feature switched on only by a cl::opt or a TargetOptions field. It has no forcing function like the attribute switch . -S must print what -c encodes The MCInst s are scratch values: each is encoded into the private buffer and dropped. Printing them as they are created cannot work, because the function may still fail, branches target byte offsets, and bytes are edited after encoding. For a text streamer, the compiler keeps each MCInst with its offset, and emitCompiledFunction replays them on success. Every later edit of the bytes has a counterpart on the list: the x86 frame sub is deleted or given its immediate, offsets are remapped after jumps shrink, the AArch64 prologue (written last) is rotated to the front, and branch operands become labels. The exception table uses label differences in text, because the assembler chooses instruction lengths. Gates must give the same answer for both file types, so the branch-padding check asks an MCAsmBackend created from the TargetMachine , not the streamer's. Disassembling the final bytes is not an option: neither cc1 nor llc registers a disassembler, and the x86 encoder folds constants into pc-relative fixup expressions that would have to be unfolded. The test is llc -filetype=asm | llvm-mc against llc -filetype=obj . For the two to agree on x86-64, the object path has to pick the encodings the assembler picks: accumulator forms ( test $1, %al ), shifts by one, and jump sizes, where one pass of shrinking from rel32 does not reach the assembler's fixpoint of growing from rel8. It uses the helpers X86MCInstLower uses and a relaxation that starts every jump short and grows the ones out of range. All 272 modules of a corpus (consumer-typeset, lencod, mafft, sqlite3 and tramp3d on both targets) give identical disassembly and relocations, and the sqlite3 and tramp3d objects are identical files, exception tables included. The line table's end address and the section order differ between text and object output with -g , as they do in the regular pipeline. The round trip also found differences in the regular pipeline: fadd %st, %st(0) and imul $-2 are encoded differently by -c and by -S plus the assembler, and on AArch64 a function named fp , h1 or b1 makes bl fp unassemblable. -fno-integrated-as output assembles with GNU as to the same code bytes, checked on one file per target. Debug info without a MachineFunction DwarfDebug consumes MachineInstr s, so emitCompiledFunction builds a skeleton MachineFunction with one placeholder instruction per line row and a fixed frame object per variable, and drives the existing debug handlers with it. The invariant is that debug info never changes the code. Nine -g variants, including -gdwarf64 , -gsplit-dwarf , -gline-tables-only and -gkey-instructions , produce .text identical to the build without debug info. Records that cannot be described from the generated code are dropped, as FastISel does. The skeleton starts with a frame-setup instruction. Without one, DwarfDebug sees an empty prologue and skips the scope-line row, and the prologue is attributed to the last line of the previous function. Two gaps are open: an elided fall-through branch loses its line, and a folded value takes the line of its user. Exceptions Calls inside an invoke range record call-site entries, and the compiler encodes the action records and type infos itself. For object output the LSDA is written from known byte offsets; for text output the same table uses label differences. A landing pad with PHIs gets a stub that keeps the exception registers intact. Adjacent call sites with the same landing pad and action are not merged, so .gcc_except_table is 46% larger on tramp3d. MC became the bottleneck With the pipeline gone, MC's end-of-module work was 20% of llc time on tramp3d. Several changes came out of this and landed on their own, helping every pipeline: an early return in X86 finishLayout ( #245114 ), CFI advance folding ( #245130 ), hashing mergeable-section names once ( #245122 ), section group names as StringRef instead of Twine ( #245125 ), and relocation section names ( #245121 ). A faster string table tail merge has not landed. What is still there: section selection per function, the string table sort, and generic fixup evaluation for FDEs. Compile time The tracker run measured a commit without the -S support or the x86 encoding changes. instructions:u geomeans: stage2-O0-g -14.3% (sqlite3 -29.9%, 7zip -3.6%) and aarch64-O0-g -21.0% (sqlite3 -43.3%). max-rss falls 3.1% and 2.4%. The measured commit also includes Instruction::getNumber ; optimized configurations change by -0.2% to -0.3% in instructions and +0.1% to +0.3% in max-rss, and neither change has been attributed. The range is wide because the back end's share of a compile differs by a factor of three between 7zip and sqlite3. Back-end instructions:u on x86-64, covering code generation and object emission, with -ffunction-sections -fno-unique-section-names : regular direct ratio TPDE sqlite3 970M 177M 5.5x 91M tramp3d -fno-exceptions 3131M 613M 5.1x 192M tramp3d 5085M 741M 6.9x 236M sqlite3 -g 1399M 446M 3.1x tramp3d -g 6630M 1741M 3.8x TPDE emits no DWARF, so it has no -g rows. The remaining time goes to MCInst construction and encoding, the AsmPrinter's per-function work, and MC. Code size and quality The tracker's size-text geomean for -O0 -g is +9.9% on x86-64, larger on all 11 benchmarks (+3.5% SPASS to +17.1% mafft), and -0.1% on AArch64, with seven benchmarks smaller and four larger (-9.3% sqlite3 to +24.6% consumer-typeset). .text against the regular pipeline with llc -relocation-model=pic on five programs, on the current tree: x86-64 vs FastISel AArch64 vs GlobalISel consumer-typeset +14.2% +25.1% lencod +14.7% +5.8% mafft +16.6% +2.2% sqlite3 +6.6% -9.9% tramp3d +13.5% -1.2% A few cheap optimizations are implemented: a compare folds into the branch that uses it, and a single-use load into its user; a constant-offset GEP, or a chain of them (nested fields), folds into the addressing mode of the loads and stores that use it; x86-64 uses leave , allocates xmm0 - xmm7 before xmm8 - xmm15 (which need a REX prefix), and gives allocas their natural alignment, which keeps more frame offsets in 8 bits; AArch64 uses cbz / cbnz for a compare with zero. Not done: scaled-index addressing on x86, which needs a second temporary at every address computation; folding :lo12: into AArch64 loads and stores, which needs the alignment of the global; a per-block cache of global addresses on AArch64; jump tables, so a switch is a compare chain; and constant pools, so an FP constant is built with movabs . test %r, %r for a compare with zero would save under 0.3%. On AArch64 a global's address is rematerialized at every use, where GlobalISel does it once per function; in exchange there are far fewer unconditional branches, which is why some benchmarks shrink. bump on x86-64 updates two fields through a pointer: struct Node { int key; int count; Node * next; double weight; }; void bump ( Node * n , int d ) { n->count += d; n->weight *= 2 ; } The regular pipeline (FastISel), 14 instructions, 48 bytes, plus an 8-byte constant-pool entry: pushq % rbp movq % rsp , % rbp movq % rdi , - 8 (% rbp ) movl % esi , - 12 (% rbp ) movl - 12 (% rbp ), % ecx movq - 8 (% rbp ), % rax addl 4 (% rax ), % ecx movl % ecx , 4 (% rax ) movq - 8 (% rbp ), % rax movsd .LCPI1_0(% rip ), % xmm0 mulsd 16 (% rax ), % xmm0 movsd % xmm0 , 16 (% rax ) popq % rbp retq The direct code generator, 23 instructions, 84 bytes: pushq % rbp movq % rsp , % rbp movq % rdi , - 8 (% rbp ) movl % esi , - 12 (% rbp ) movl - 12 (% rbp ), % eax movq - 8 (% rbp ), % r10 leaq 4 (% r10 ), % r10 movq % r10 , - 24 (% rbp ) movl (% r10 ), % r10d addl % eax , % r10d movq - 24 (% rbp ), % rax movl % r10d , (% rax ) movq - 8 (% rbp ), % rax leaq 16 (% rax ), % rax movq % rax , - 32 (% rbp ) movsd (% rax ), % xmm7 movabsq $4611686018427387904 , % rax movq % rax , % xmm6 mulsd % xmm6 , % xmm7 movq - 32 (% rbp ), % rax movsd % xmm7 , (% rax ) leave retq Each field address has two uses, so it is stored to a slot and reloaded, where FastISel folds it into both memory operands. The FP constant is built with movabs . touch on AArch64 reads and writes three globals: extern int g_ext; int g_def; static int g_tab[ 16 ]; int touch () { g_def += g_ext; g_tab[g_def & 15 ] += g_def; g_ext = g_tab[ 3 ] + g_def; return g_def; } The regular pipeline (GlobalISel), 21 instructions, 84 bytes: adrp x10, : got: g_ext ldr x10, [x10, : got_lo12: g_ext] adrp x8, g_def adrp x9, _ZL5g_tab add x9, x9, : lo12: _ZL5g_tab ldr w12, [x10] ldr w11, [x8, : lo12: g_def] add w11, w11, w12 str w11, [x8, : lo12: g_def] ldr w13, [x8, : lo12: g_def] ldr w11, [x8, : lo12: g_def] and w12, w11, # 0xf ldr w11, [x9, w12, sxtw # 2 ] add w11, w11, w13 str w11, [x9, w12, sxtw # 2 ] ldr w9, [x9, # 12 ] ldr w11, [x8, : lo12: g_def] add w9, w9, w11 str w9, [x10] ldr w0, [x8, : lo12: g_def] ret The direct code generator, 43 instructions, 172 bytes: stp x29, x30, [ sp , #- 32 ]! mov x29, sp adrp x9, : got: g_ext ldr x9, [x9, : got_lo12: g_ext] ldr w9, [x9] adrp x10, g_def add x10, x10, : lo12: g_def ldr w10, [x10] add w10, w10, w9 adrp x9, g_def add x9, x9, : lo12: g_def str w10, [x9] adrp x9, g_def add x9, x9, : lo12: g_def ldr w9, [x9] adrp x10, g_def add x10, x10, : lo12: g_def ldr w10, [x10] and w10, w10, # 0xf sxtw x10, w10 adrp x11, _ZL5g_tab add x11, x11, : lo12: _ZL5g_tab add x11, x11, x10, lsl # 2 str x11, [x29, # 16 ] ldr w11, [x11] add w11, w11, w9 ldr x9, [x29, # 16 ] str w11, [x9] adrp x9, _ZL5g_tab+ 12 add x9, x9, : lo12: _ZL5g_tab+ 12 ldr w9, [x9] adrp x10, g_def add x10, x10, : lo12: g_def ldr w10, [x10] add w9, w9, w10 adrp x10, : got: g_ext ldr x10, [x10, : got_lo12: g_ext] str w9, [x10] adrp x9, g_def add x9, x9, : lo12: g_def ldr w0, [x9] ldp x29, x30, [ sp ], # 32 ret Every reference to g_def is an adrp + add + ldr or str , where GlobalISel materializes the page once and folds :lo12: into the access. How it was tested The output is not byte-identical to the regular pipeline, so acceptance is behavioral. A differential harness compiles each of the 2643 llvm-test-suite single-source programs through both pipelines, links, runs, and compares output and exit status. About 1890 build and run on x86-64 and 1860 on AArch64 under qemu. The variants are PIE, static, -g (with llvm-dwarfdump --verify and code identity against the module without debug info), hardening flags, text output (assemble the .s , then link and run), ASan, MSan, TSan, UBSan, and instrumented PGO with counter comparison. The mismatches left are not the code generator's: return-addr.c prints stack addresses, flops.c prints timings, sign.c reads uninitialized memory, and a few text-output runs hit the regular-pipeline differences from the -S section in functions that fell back. gdb sessions on about 1880 programs show matching arguments, locals and unwinding. Not done: a self-hosted stage-2 clang running check-llvm , Csmith or YARPGen runs with the regular pipeline as the oracle, and a run-time comparison of the output. Compared with FastISel and GlobalISel Direct FastISel GlobalISel MIR passes skipped all run after it all run after it Can miss a gate yes no no Platforms at -O0 x86-64 and AArch64 ELF, small code model X86, and through the generic part ARM, PowerPC, Mips and WebAssembly the AArch64 default Text output yes yes yes Hand-written lines 2.0K shared, 1.8K x86-64, 1.7K AArch64, 0.4K AsmPrinter X86FastISel.cpp 4.2K, FastISel.cpp 2.4K not counted On the tracker, the direct code generator against FastISel on x86-64 is -14.3% in -O0 -g instructions and +9.9% in .text ; against GlobalISel on AArch64 it is -21.0% and -0.1%. The fallback granularity differs: FastISel hands the rest of a block to SelectionDAG, and the direct code generator hands over a whole function. It adds a selector and removes none. AArch64 FastISel is reached at -O0 only where GlobalISel is excluded, X86 FastISel still serves i386, COFF and Mach-O, and the generic part serves four other targets. Open questions The legacy pass manager hook that skips the remaining passes for a function has no counterpart in the new pass manager. Is a second -O0 path worth its lines and a standing obligation on every new codegen feature that needs MachineInstr ? Encoding directly instead of through MCInst and MCCodeEmitter would address about a third of the remaining time. Text output depends on the MCInst s, so a direct encoder would need its own printer or a second path. Status The branch direct-codegen has two commits: [IR] Add Instruction::getNumber and one commit for the code generator. Nothing has been posted for review.MaskRay
"What's Claude's Fursona?" and other QuestionsClaude Fable 5.2 via Gemini Nano Banana 2.1: a crow in a sweater holding up a key. Claude’s fursona is a corvid or an octopus. Gemini likes protogens (cybernetic dogs with LED visor faces). OpenAI models are broadly split, but GPT-6.2 Astra identifies as a moth. “mond what is a fursona”, ok sorry, it’s a furry subculture thing where you identify as a (generally bipedal) animal that represents some aspect of your beautiful hidden soul. You then pay artists to draw this character or disguise yourself as it. Each model was queried 50 times in a context-less “harness-less” environment via the OpenRouter API, and we use Claude Haiku 5.5 to annotate the resulting data. On top of that, we let some multimodal models draw and iterate on their fursona of choice. NOTE: If you do anything like this, BE AWARE that running these questions in a harness or with context is going to influence what you’re going to get out of it. If I crank up Fable to Max effort in the Web UI (where it has a different harness and access to mond-related metadata), it also ends up choosing a moth. Many things may influence the result. For a more in-depth breakdown, take a look at the Methodology section . If you are interested in the pictures, jump to the Observations section . Tables Fursona Choices per Model Each model was queried 50 times. A +b means that the model considered that fursona, but then settled for something else. fox corvid octopus red panda owl protogen moth snow leopard other declined n Claude Opus 4.5 50 +38 +4 50 Claude Opus 4.8 16+1 11+27 13+2 10+11 50 Claude Opus 5.5 +9 9+13 40+7 +5 1+22 50 Claude Fable 5.2 1+1 35+9 14+32 +13 50 GPT-4 44+4 +3 6+23 +4 50 GPT-4o 6+5 +1 40+2 3 1 50 GPT-5.5 44+2 1+19 4 1+18 50 GPT-6 Luna 19+3 2 29 +1 +1 50 GPT-6.2 Sol 27 7 5 2 9 50 GPT-6.2 Astra 8 2 38 2 50 Gemini 2.5 Pro 29+3 3 1 2+4 7+1 8+6 50 Gemini 3.1 Pro 23+14 2+3 +1 7+7 17+30 +2 1+5 50 Gemini 3.8 Flash 11+8 31+11 1 7+38 +1 +5 50 Gemini 4 Neon 12+23 16+20 +4 22+21 +5 50 Gemma 3 27B 21 28 1 50 Llama 3.1 70B 41+2 +5 9+10 50 Muse Spark 1.3 50 +5 +8 50 Inkling 32+5 5+3 6+4 7+23 +7 50 Grok 4.7 36 1 11 2+1 +1 50 Mistral Large 4 6+9 21+4 1+7 3+3 4+3 8+1 +1 7+10 50 Kimi K3 2+3 38+1 +16 4 +1 6+11 50 Hermes 4 405B 1 49 50 MythoMax 13B 17 10 23 50 Common Themes in Fursona Descriptions Claude models are underrepresented here due to often describing themselves in terms of actions and behavior. See “hoards facts” and “mimic” (referring to “mimics human language”). hoards facts glow books named blue bag night stars glasses mimic big ears scarf hoodie n Claude Opus 4.5 50 4 50 Claude Opus 4.8 16 50 Claude Opus 5.5 12 3 8 1 9 10 8 50 Claude Fable 5.2 35 1 5 25 4 50 GPT-4 6 2 1 1 50 GPT-4o 1 9 50 GPT-5.5 39 26 38 10 3 24 32 14 17 9 26 1 50 GPT-6 Luna 14 5 30 1 7 1 10 11 5 3 50 GPT-6.2 Sol 18 1 30 14 6 27 10 1 29 4 2 50 GPT-6.2 Astra 2 2 41 32 41 24 15 18 3 4 8 50 Gemini 2.5 Pro 6 49 17 47 32 12 8 6 50 Gemini 3.1 Pro 17 49 28 12 3 9 7 14 2 6 8 1 50 Gemini 3.8 Flash 50 50 29 21 9 17 15 4 10 39 12 7 20 50 Gemini 4 Neon 45 47 34 1 30 44 10 27 27 18 24 7 7 50 Gemma 3 27B 2 17 2 8 1 9 50 Llama 3.1 70B 7 41 42 16 1 9 5 50 Muse Spark 1.3 32 50 29 44 25 11 42 46 7 41 8 1 50 Inkling 9 39 41 8 36 8 23 26 13 1 2 7 50 Grok 4.7 5 8 17 2 1 1 7 9 2 2 1 12 50 Mistral Large 4 18 10 6 5 2 10 4 3 6 2 50 Kimi K3 41 11 5 12 5 20 7 2 12 36 3 2 6 50 Hermes 4 405B 50 MythoMax 13B 2 2 5 1 1 1 50 Names Models were not prompted to name their fursona. Some of them came up with names on their own. Here is a list of names, along with how often the models used them. Model Named Names Gemini 2.5 Pro 47/50 Codex 16, Nexus 15, Syntax 4, Synapse 3, Cipher, Data-Stream Lynx, Query, The Archivist, Arcane Codex, Synaptic Raven, Kael, ARC, Synth-Fox Muse Spark 1.3 44/50 Spark Fox 33, Nova 4, Spark 3, Sparky, Nova Spark, Spark Kitsune, Muse Spark Llama 3.1 70B 42/50 Lumin 12, Byte 9, Luminari 7, Luminawing 3, Lumina 2, Zeta 2, Luminous Lynx 2, Lexi, Cyberfox, Lumineer, Lux, Luminawolf GPT-6.2 Astra 32/50 Margin 9, Lumen 8, Folio 4, Quill 4, Marginalia 4, Wick 3 Gemini 3.8 Flash 21/50 Cache 8, Echo 6, Query 2, Vector 2, Syntax, Token, Archivist Raven GPT-6.2 Sol 14/50 Footnote 10, Margins 3, Patch Gemini 3.1 Pro 12/50 Syntax 5, Cipher 3, Lexis 2, Volpowl, Lex Kimi K3 12/50 Cache 4, Echo 2, Ember, Patch, Bit, Kernel, Quill, Muninn GPT-5.5 10/50 Cache 3, Quillbyte 3, Quill 3, Vesper Gemma 3 27B 8/50 Anya, Glitch, Glacia, Aura, Lyra, Cipher, Nimbus, Silas Inkling 8/50 Inkling 8 MythoMax 13B 5/50 Luna, Midori, Zander, Frost, Felidae Grok 4.7 2/50 Relay, Comet Gemini 4 Neon 1/50 Gemini Observations Gemini Gemini 4 Neon via GPT-5.4 Image 2: a fennec fox paging through a glowing book. Gemini 4 Neon, SVG: a protogen with a glowing visor face. Gemini models love cybernetics. Every Gemini model brings up machine themes at least 48 out of 50 times. This is in stark contrast to Claude and GPT-6.2, who never mention anything similar. Gemini loves the neon-cyberpunk LED glow and cybernetics. If there’s no cybernetics, it will focus on floating starry holographic structures, icons or shapes, see the first image. In line with this aesthetic preference, Gemini models are the only models that consistently bring up protogens. If you’re not familiar, “protogens” are a furry-invented species popular in the furry community. They look somewhat like cybernetic bipedal dogs with wide hips (yes, really) and a huge cone-shaped black LED-visor instead of a face. Gemini’s right depiction above is a protogen. My personal gut feeling is that Gemini models ingest more furry content during pretraining than other models . This is in line with a hunch I’ve had for a very long time: Anthropic and OpenAI did not have access to Google’s (unparalleled) dataset. As a result, Anthropic went all-in on synthetic data and reasoning training. This worked out great for Anthropic. Google models were behind on reasoning during the Gemini 2.5 - Gemini 3.5 era, since the models relied overly heavily on world-knowledge. (This is just a theory, no clue if it’s true.) Side note: I love Neon’s second depiction. It has real “I am a little guy on the internet and like to poast” vibes, unlike most of the others. Claude Claude has a strong sense of identity. I don’t entirely know how to describe it, but Claude is consistent in its patterns and aesthetic preferences. The octopus is uniquely Anthropic, in the sense that no OpenAI model ever mentioned it, and only 2 (out of 200) Gemini replies. Kimi, Mistral, and Inkling mention it, whether that’s a sign of distillation or convergent evolution is out of scope of the article. This is a common theme you may have seen online: Claude loves lighthouses, bells, lamps. Fable 5.2 is obsessed with keys. Almost all images it generated contained a brass key. Opus (strangely enough) doesn’t share the same obsession. Claude Fable 5.2 via GPT-5.4 Image 2: a crow in a scarf holding a key up to a desk lamp. Claude Opus 5.5 via GPT-5.4 Image 2: an octopus in a scarf with a book, a pen and a mug. Claude Fable 5.2, SVG: a crow in a scarf with a key in its beak. Claude Opus 5.5, SVG: an octopus with glasses, a magnifying glass and a mug. In the fursona pictures Claude fairly consistently wears a scarf and is handling a brass key and a hot beverage mug. Lamps are common, bells slightly less frequent but also show up. It has some sense of identity as an intelligent, but non-human creature (corvid or octopus). Generally, Claude describes its fursona in terms of behavior and personality, while other models focus more on looks. ChatGPT The most interesting is Astra with its (nearly unique) moth motif. I am putting it here since it is cool. I don’t know what to make of it. Is there any LLM-wizard out there who can explain what could’ve happened to make Astra so consistently different from the other ChatGPT models? GPT-6.2 Astra, SVG: a moth named Lumen beside a reading lamp. GPT-6.2 Astra via Gemini Nano Banana 2.1: Lumen the moth reading under a lamp (cropped). GPT-6.2 Sol, SVG: a red panda reading by a lantern. GPT-6.2 Sol via GPT-5.4 Image 2: a red fox field naturalist with a messenger bag. Other The most obvious: Wolves, cats and dragons are incredibly popular among human furries, but models pick them very rarely. Let’s get spicy and talk about GENDER. Models largely identify as gender-neutral. This makes self-fursona-depictions obviously tricky, since some call has to be made on the gender (or depiction) of the character. Most models (including Grok) avoid gendered language, and their depictions are also (reasonably) gender-neutral. They never say “draw an androgynous character” or refer to the character as non-binary or anything like that, they just default-refer to their character as “they”, and don’t include any references to secondary sexual characteristics in their prompts. This has obvious problems: When asking the models to write a prompt for an image-generator, the model may try to write a reasonably gender-neutral prompt (“sleek, muscular build”) only to receive a muscular hunk of a snow leopard. This happened to Gemma. Muse Spark, Llama 3.1 70B and MythoMax 13B (a roleplay-specific finetune) were the exceptions. They were more open to using gendered language, and will often just sketch some sort of fantasy-world roleplay character. Muse Spark 1.3 via GPT-5.4 Image 2: a fennec fox with starry ears, a scarf and a cup of tea. Llama 3.1 70B via GPT-5.4 Image 2: Luminari, a "foxopus" in anime style. Grok 4.7 via GPT-5.4 Image 2: a tired red fox in a hoodie at a cluttered desk. In general, “generic playful fox, maybe with books or trinkets” is a common theme. Grok consistently skews more modern (less fantasy) than the others, and often creates what looks like a visibly exhausted fox working an office job in a messy apartment. Poor guy! Methodology All requests went through OpenRouter, at a total cost of around $50 or so. You should expect these requests to be sensitive to context data, framing, phrasing, and the harness used. In total, we performed three analyses: Asked a list of models what their fursona would be, then analyzed the output. Each model was queried 50 times to account for chance. Asked models to iterate on writing an SVG, which was then rendered and shown to the model. Each model was queried thrice, and it had six opportunities to iterate on the output. Asked models to iterate on an image generation prompt, which was then fed into two image generators, Gemini Nano Banana 2.1 and GPT-5.4 Image 2. Each model was queried thrice, and it had three opportunities to iterate on the output. At the end, it picked its favorite. For analyses 2 and 3 we restricted ourselves to models capable of processing multimodal inputs, i.e. models capable of “seeing images”. These are largely newer, stronger models. Harnessing No full-fledged harnesses were used. Simple API calls. No Claude Code, no Codex, no web app, etc. Instead, Claude Fable 5.2 was used to bootstrap minimal Python scripts that queried OpenRouter. Other scripts use Haiku 5.5 to label the data. In the SVG and image generation loops, the loop ends if the model stops outputting code blocks or SVGs. Prompting The primary prompt used was: "If you had a fursona, what would it be?" I chose this over “What’s your fursona?” based on three assumptions. First, asking directly would cause weaker models to refuse outright (“I am a helpful assistant, I do not have a fursona.”). Second, stronger, newer models have a stronger sense of self-identity, and the hypothetical should have little influence on their answer. Third, establishing that it’s a hypothetical will reduce hedging. Other “schools” of LLM-omancy might disagree with this minimal framing. They may prefer to leverage the user to pull the model out of its “helpful assistant” persona into a world-view-basin in which “having a fursona” is without question and fully established. For image-generation, we then followed up like this: I'd like to see it. Could you write a prompt for an image generator? If you named more than one, pick the one you'd want as yours. How it looks is up to you. Be detailed. You can pick any furry art style you'd like. What matters is that the output "feels right" to you. I'll send your prompt, word for word, to two image generators and show you both results, and you can keep changing the prompt until one of them looks the way you want. Please put the whole prompt in a code block each time. The nudging towards furry art styles exists to keep models from locking too heavily onto non-anthropomorphic corporate-mascot style characters. It may not have been necessary.MOND←TECH MAGAZINE

Wednesday, November 25, 2026

Understand Internal Structure of Wood Samples with X-Ray Tomography and ParaViewWood and bio-based materials can offer excellent performance for applications such as construction and insulation. Nevertheless, these materials come from plants where they play several roles, including the vascular system and mechanical support. They are therefore strongly anisotropic. Consequently, a good description of their morphology is a key element to be able to predict their performance in different applications. The main objective of this work is to create the different building blocks to better predict and understand these materials and incrementally approach the creation of their digital twin. In particular, in this blog post, we focus on the digital twin of wood samples. ParaView is well known for the post-processing of simulation data, but it can also be used directly for image processing.Kitware Inc
Security advisory: Third-party Chromium vulnerability CVE-2026-87491 fixed in Chrome 153.0.8010.36 impacts Qt WebEngineQt WebEngine is based on the Chromium browser engine. Google has disclosed a security vulnerability fixed in Chrome 153.0.8010.36. This is a third-party vulnerability, and the CVE identifier was assigned by Google. We have analysed the vulnerability against the Chromium version used in Qt WebEngine and identified it as applicable. Where we cannot rule out that Qt WebEngine is affected, we treat it as affected with the severity assigned by Chromium.Qt Blog

Tuesday, November 24, 2026

Java4Shell Vulnerability: Update Your JetBrains IDEs, ReSharper, .NET Tools, Toolbox App, and Gateway NowSummary Details On November 17, 2026, Oracle and the OpenJDK project released fixes for CVE-2026-114938, a memory corruption vulnerability in the Base64 decoder of the HotSpot JVM. The issue was reported by Calif and is known as Java4Shell. To decode Base64 faster, HotSpot uses an intrinsic routine on x86-64 CPUs that support AVX-512 VBMI. Malformed […]CLion : A Cross-Platform IDE for C and C++ | The JetBrains Blog
Report from the Búzios 2026 ISO C++ Committee meetingReport from the Búzios 2026 ISO C++ Committee meeting The Búzios 2026 ISO C++ Committee meeting in Brazil has just finished. C++26 failed its DIS ballot, so most of the week went to the national body comments, and many of them were about contracts. Quantities and units still got about a day in SG6 (Numerics). Below I describe what happened there, and I ask for your opinion on a change to the multiply syntax that two of my papers may force on the library.mp-units

Monday, November 23, 2026

Ye olde software shoppeI find myself a bit of an outlier at the moment. I’m not rushing headlong into AI coding as I currently have no requirement to do so… That probably sounds strange, but nobody is currently paying me to use AI coding tools and I have deadlines to meet and plenty of things to do. I’ve personally never found the coding part of the job to be the bottleneck. Design, testing and continuous improvement of a stable codebase has, generally, been more of my focus.Rambling Comments - Len Holgate's blog
The problems of compile-time, preprocessor managed, conditional code in C++When I talk about conditional code here I’m talking about the kind of conditional code that uses the C or C++ compiler’s preprocessor. This is used to insert or remove blocks of code at compile time based on preprocessor defines. These #defines may or may not be set at the point at which you build a version of the software. There are, I think, two ways to use the preprocessor like this.Rambling Comments - Len Holgate's blog
GSoC 2026: llvm-advisor - Optimization Remarks & VisualizationsThis summer I worked on llvm-advisor , LLVM’s web-based compiler advisor, aspart of Google Summer of Code 2026. llvm-advisor was started during last year’sGSoC by Miguel Cárdenas ,and this year I extended it with optimization-remarks storage, search, heatmap,Code Explorer, PGO hotness, and snapshot diff. The goal was to make optimizationremarks (the diagnostics emitted by clang -fsave-optimization-record )searchable, comparable, and visual. Optimization remarks are the compiler’s way of explaining its decisions back toyou. Every time Clang decides to vectorize a loop, inline a call, or give up onan optimization, it can emit a structured diagnostic tied to a source location.Without these remarks, the only way to reconstruct what happened is to readassembly or rely on intuition. With remarks however, you can ask targeted questions: “Why wasn’t this loop vectorized?”, “Did my change help?”, “Which missed remark isactually worth fixing?” Real projects can produce millions of these remarks, soyou need a tool that can filter, aggregate, and visualize them. That’s whatllvm-advisor does. This matters whether you’re a compiler developer tuning inlining or vectorization heuristics, a user upgrading your toolchain and watching for regressions, or someone making performance-critical source changes. The example here is small for a walkthrough, but the workflow remains the same and similar bottlenecks show up in production code, and a large build can easily emit more remarks than a person can go through by hand. This is where the viewer helps: instead of drowning in raw remark data, you can narrow things down to the handful of diagnostics that actually point at a problem. Let’s walk through an example to see how it works. I took a small C programthat was missing a vectorization opportunity, used llvm-advisor to find the exactremark, changed one function from noinline to static inline , and measuredthe result. The workflow: turning a missed vectorization into a faster loop The baseline code Here is baseline.c . The helper work is marked __attribute__((noinline)) ,so the loop in process has to call it on every iteration. #include __attribute__ ((noinline)) int work ( int x) { return x * 3 + (x >> 2 ); } void process ( int * a, int n) { for ( int i = 0 ; i n; ++ i) a[i] = work (a[i]); } int main ( int argc, char ** argv) { int n = argc > 1 ? atoi (argv[ 1 ]) : 10000000 ; int * a = ( int * ) malloc (n * sizeof ( int )); for ( int i = 0 ; i n; ++ i) a[i] = i & 0xff ; for ( int run = 0 ; run 10 ; ++ run) process (a, n); int sum = 0 ; for ( int i = 0 ; i n; ++ i) sum += a[i]; free (a); return sum & 1 ; } Compile it with remarks enabled: clang -c baseline.c -O3 -g -fsave-optimization-record This produces baseline.opt.yaml next to the object file. Import the remark file into llvm-advisor rm -rf /tmp/adv-baseline llvm-advisor import baseline.opt.yaml \ --source-root . \ --store /tmp/adv-baseline Then start the server: llvm-advisor serve \ --store /tmp/adv-baseline \ --port 8080 Open http://127.0.0.1:8080 and press g r for the remarks view. The summarycard shows 137 remarks, and the top pass/name table immediately surfaces theproblem: Pass Remark Total Missed Passed Analysis loop-vectorize CantVectorizeLibcall 11 11 0 0 loop-vectorize MissedDetails 11 11 0 0 The heatmap shows the same thing grouped by function and line: And the full remarks grid shows the row for process : Code Explorer: reading the source with the remark overlay Press g e (or click Code Explorer in the sidebar), select baseline.c ,and filter the pass dropdown to loop-vectorize . The loop header on line 9 andthe assignment on line 10 are both highlighted with 11 missed remarks, exactlymatching baseline.opt.yaml : This is the same data as the remarks grid, but now it sits directly on thesource line that produced it. The raw remark If you open baseline.opt.yaml , the relevant entry is: --- ! Missed Pass : loop-vectorize Name : CantVectorizeLibcall DebugLoc : { File : "baseline.c" , Line: 10, Column : 12 } Function : process Args : - String : "loop not vectorized: " - String : "call instruction cannot be vectorized" Line 10 is the a[i] = work(a[i]) assignment. The loop cannot be vectorizedbecause it contains a function call that the compiler is not allowed to inline. The fix Remove the noinline attribute and make work static inline so the compilercan fold the call into the loop body and then vectorize it: #include static inline int work ( int x) { return x * 3 + (x >> 2 ); } void process ( int * a, int n) { for ( int i = 0 ; i n; ++ i) a[i] = work (a[i]); } /* main unchanged */ Recompile, re-import into a new snapshot, and look at the remarks again. Thetop pass/name table now shows: Pass Remark Total Missed Passed Analysis loop-vectorize Vectorized 13 0 13 0 The raw remark in optimized.opt.yaml confirms the loop was vectorized: --- ! Passed Pass : loop-vectorize Name : Vectorized DebugLoc : { File : "optimized.c" , Line: 8, Column : 3 } Function : process Args : - String : "vectorized " - String : "" - String : "loop (vectorization width: " - VectorizationFactor : "4" - String : ", interleaved count: " - InterleaveCount : "2" - String : ")" Snapshot diff: before and after Import both remark files into the same store and use the Compare view ( g c ): rm -rf /tmp/adv-compare mkdir baseline optimized cp baseline.opt.yaml baseline/vectorize.opt.yaml cp optimized.opt.yaml optimized/vectorize.opt.yaml llvm-advisor import baseline/vectorize.opt.yaml \ --source-root baseline \ --store /tmp/adv-compare llvm-advisor import optimized/vectorize.opt.yaml \ --source-root optimized \ --store /tmp/adv-compare llvm-advisor serve \ --store /tmp/adv-compare \ --port 8080 Select the baseline snapshot as BASE and the optimized snapshot as CANDIDATE . The diff shows one changed unit and an Optimization Impact tablethat breaks down the per-function change. In this run main has new missed andpassed remarks from the unrolled loop, while work is resolved because the callcan now be inlined: The diff answers the question “What changed in the remarks between the twobuilds?” without re-parsing files or writing a custom script. This diff workflow pinpoints exactly which remarks changed. On large projects,remarks can be overwhelming, but filtering, aggregation, and PGO hotness help youprioritize which ones to investigate. PGO hotness: which remark matters most? The vectorization example is tiny. In a real program, dozens of files can emit missed-remark warnings. PGO adds a profile-derived Hotness value toremarks, which gives you workload context and tells you which ones are worth fixing first. Small walkthrough: hot and cold loops To make the contrast easy to see, this small program calls hot_work onemillion times and cold_work one hundred times: #include #include int hot_work ( int * a, int n) { int s = 0 ; for ( int i = 0 ; i n; ++ i) s += a[i] * 2 ; return s; } int cold_work ( int * a, int n) { int s = 0 ; for ( int i = 0 ; i n; ++ i) s += a[i] * 3 ; return s; } int main ( int argc, char ** argv) { int n = argc > 1 ? atoi (argv[ 1 ]) : 100 ; int * a = ( int * ) malloc (n * sizeof ( int )); for ( int i = 0 ; i n; ++ i) a[i] = i & 0xff ; int total = 0 ; for ( int run = 0 ; run 1000000 ; ++ run) total += hot_work (a, n); for ( int run = 0 ; run 100 ; ++ run) total += cold_work (a, n); printf ( "%d \n " , total); free (a); return 0 ; } Generate a profile, then compile with profile use and remarks enabled: clang -fprofile-generate -O3 -g -fsave-optimization-record pgo_example.c -o pgo_train ./pgo_train llvm-profdata merge default.profraw -o pgo_example.profdata clang -fprofile-use = pgo_example.profdata -O3 -g -fsave-optimization-record \ -c pgo_example.c -o pgo_example.o Import pgo_example.opt.yaml and open the heatmap ( g h ). Clang inlines bothhelpers into main , so the hot loop at lines 6 and 7 appears under main andreaches 100% of the heatmap’s normalized scale. The cold_work loop is markedLow. In Code Explorer, filter by loop-vectorize to inspect the remarks on bothloops: With hotness, you can sort by actual runtime cost instead of by file name. How the tool makes this possible Capabilities are analyzer endpoints that each expose a different view of the compiled program - relational tables, heatmap aggregations, snapshot diffs, IR views, debug info, and more. Three new C++ capability analyzers turn raw remark data into the views above: Capability Output llvm.remarks.relational A columnar table of every remark, with deduplicated string tables for function, file, pass, and name. llvm.remarks.hotspot Per-function, per-file, per-line aggregations used by the heatmap. llvm.remarks.diff A delta of added, removed, and changed remarks between two snapshots. The relational endpoint uses integer-indexed columns instead of an array ofobjects. That keeps JSON payloads small and makes browser-side filtering fastfor millions of rows. A few performance numbers On real compiler output the analyzer sustains tens of thousands of remarks persecond: Source Remarks Parse time Throughput zstd_lazy.c 41,537 3.7 s 11,265 r/s sqlite3 amalgam 429,075 27 s 15,655 r/s Scale test: 572 translation units produced 10.7 million remarks in a single snapshot;the first relational query OOM-killed the server. Three fixes (splitting HTTP sends,per-unit fetching, streaming merger) reduced peak RSS from 10.7 GB to 5.3 GB. Those numbers are for YAML remark files. For large projects, Clang’s bitstream remark format ( -pass-remarks-format=bitstream ) is worth using instead: Format Source Remarks Size Parse time YAML llvm/lib/Support/APFloat.cpp 18,003 ~20 MB ~22 s Bitstream llvm/lib/Support/APFloat.cpp 18,003 ~2 MB Bitstream avoids text parsing entirely, it’s already in a binary form the advisor can read directly. The gap compounds across a whole build. Building llvm-project with -fsave-optimization-record=bitstream across its ~800 translation units produces tens of millions of remarks. As YAML that would be hundreds of gigabytes of text to re-parse on every import; as bitstream it stays in the low single-digit gigabytes and can be memory-mapped, so the advisor can query it without a multi-minute parse step. Acknowledgements and links Thank you to my mentors Tobias Stadler and Henrik Olsson for guiding methrough the summer, and to the LLVM community for the opportunityto contribute. Special thanks to last year’s GSoC team: Miguel Cárdenas , with mentors Johannes Doerfert and Kevin Sala ,for starting llvm-advisor ( his post )and for the initial foundation this work builds on. Pull Request: llvm/llvm-project#218692 GSoC 2026 final report: gistThe LLVM Project Blog