Or: why I spent hundreds of millions of tokens to write four versions of the same markdown file. I’m working on a complex project that’s just beyond what I know how to build, which is pretty fun! But also hard, especially when I try to speed things up by using LLMs. 1 As a result: Sometimes I don’t understand the problem well enough. Sometimes I don’t know that . Sometimes…
Recently: Zig is considering a safe, Fil-C -like compilation target. Fil-C is a “memory safe implementation of C”, and the Zig issue claims this will be “truly memory safe”. This is presented as “unlike Rust” because Rust has escape hatches a.k.a. Unsafe Rust . But it turns out Fil-C’s definition of memory safety is different from Rust’s. So maybe…
LLMs are exhausting because they require spending precious social energy to operate them. Energy that might be better spent on people . When you use a good tool, your brain pretends that the tool is a part of your body : when you drive a car, when you type on a keyboard or when you hit that key chord to do that thing in Vim or VSCode. In contrast, when you talk to somebody, you are participating…
Or rather, of elephants 🐘 and men. At $work , we use PostgreSQL a lot . So much in fact, that we tend to be paranoid frugal when adding even more stuff to it. In this case, we wanted to add a new index to speed up a query (with an eye-watering p99 latency of several seconds). We have a single, big table that is shared between a few different features, but we are only interested in a tiny subset…
While adding a failing test to the Rust compiler, I stumbled upon a peculiar code generation test : pub fn thirteen_ref ( input: &&&&&&&&&&&&& str ) -> String { // CHECK-NOT: {{(call|invoke)}}{{.*}}@{{.*}}core{{.*}}fmt{{.*}} input . to_string () } // This is a known performance cliff because of the macro-generated // specialized impl. If this test suddenly starts failing, // consider removing the…
This is a follow-up to making the rav1d video decoder 1% faster , where we compared profiler snapshots of rav1d (the Rust implementation) and dav1d (the C baseline) to find specific functions that were slower in the Rust implementation 1 . Today, we are going to pay off a small debt from that post: since dav1d and rav1d share the same hand-written assembly functions, we used them as anchors to…
How can you build Python code with Bazel ? Why would you even want to do that? This is the topic of a lightning talk I gave at PyCon IL this year. Below are the slides and a transcript, starting with why this is a problem that you might have. You can also jump right into the part about how Bazel can solve that problem , or check the GitHub repo .
*on macOS with an M3 chip *slightly more than 1%, on a specific benchmark, without any new unsafe code A while ago, memorysafety.org announced a contest for improving performance of rav1d , a Rust port of the dav1d AV1 decoder. As this literally has my name written on it, I thought it would be fun to give it a try (even though I probably can’t participate in the contest). This is a write-up…
It’s not. I’m not saying that’s inherently bad . It’s just what it is. Consider the following code: var gpa = std . heap . GeneralPurposeAllocator (.{}){}; const allocator = gpa . allocator (); var list = try std . ArrayList ( u8 ). initCapacity ( allocator , 4 ); try list . appendSlice ( 'Hell' ); const c = & list . items [ 0 ]; try list . append ( 'o' ); try list . append…
Years ago, I worked on reimplementing some Python code in Rust and needed to adapt Python’s dynamic reflection capabilities (aka __getattr__ ) to the strict and compiled world of Rust…
Whenever I get into a new technology, I try to build myself a mental model of how it works. Let’s do that for full text search engines , by writing a minimal implementation in Rust
After updating the TensorRT version we use to compile ML models at work, I got a failure in a test: the test feeds a video to a model expecting a specific classification, but the model produced complete garbage. This led me on an unusual debugging quest, dissecting a Vision Transformer layer by layer.
One of the best things about Rust is that there are so many high-quality crates for everything and anything you want. It can be hard to choose, so I wanted to share some of the crates I used this year at $work and explain why. You can also jump to the end for the final Cargo.toml . For context, we’re a small-ish Rust & Python shop handling compute-heavy workloads on-prem. Our system is split…
Sometimes, I get mad at someone on the internet. It’s just so easy, isn’t it? Then, I remember my most downvoted StackOverflow answer, and I become less angry. I wrote the actual answer many years ago, but the angry-ness is much more recent. Apparently, I angered someone on a topic that is so controversial that my answer became part of a StackOverflow Meta (!) discussion about how to deal with…
There are some things you keep learning and forgetting (or perhaps you’ve never learned them in the first place?). For me, one of those things is Pin/Unpin in Rust. Every time I read an explanation about pinning , my brain is like 👍, and a few weeks later is like 🤔🤨. So, I’m writing this as a way to force my brain to retain (pin?) this knowledge. We’ll see how it goes! Pin Pin…
An unexpected error A friend was experimenting with Rust and asked if I could help decipher an error message for them: PS Z:\Projects\aoc\src\bin > cargo build --bin=2021_day19 Compiling aoc v0.1.0 (Z: \ Projects \ aoc) error [ E0210 ] : type parameter `T` must be covered by another type when it appears before the first local type (`VecN<T, N>`) -- > src\vec.rs:65:6 | 65 | impl < T: MulAssign,…
Update: I gave a talk on this topic at P99 CONF 2023 and at PyCon IL 2024 (Hebrew) . A while ago at $work , we had a performance issue with one of our core Python libraries. This particular library forms the backbone of our 3D processing pipeline. It’s a rather big and complex library which uses NumPy and other scientific Python packages to do a wide range of mathematical and geometrical…
Hi! This is my blog. I write about software, performance, Rust, Python and the like. Usual disclaimer: views are my own. Everything here is written entirely by me: LLMs are cool and all, but writing is like going to the gym , and sharing an LLM’s writing on the internet without disclosure is rude .