hg-git-sign

With the help of Claude I just published my first project to PyPI! It's an extension to Mercurial that works in concert with hg-git that allows you to sign commits the same way as Git. It's called hg-git-sign. It can also be found on github where you can see that the commits I made in Mercurial are indeed Verified:

My House Sale

Mercurial already has the gpg extension that signs commits, but it does them in separate commits: first you commit new code, and then do a code signing step as another commit. With this extension, the signing happens at the same time as the first and only commit, which honestly makes much more sense than two commits.

My company is moving to requiring all commits to be signed in the Git way, which would have been impossible with the default Mercurial method. I know how to use Git, but I don't like it. With this extension I can keep using Mercurial, which is great. I hope it is useful for other people.


Why No RPi

For a few years I used a Raspberry Pi 4 (RPi) as a Pi-hole and Wireguard server on my home network. An RPi 4 is overpowered for that sort of thing, but I had it, so I figured I might as well use it.

Over the last few weeks I noticed increasing problems with it. The best I can tell is that the RPi Micro SD card reading/writing hardware was somehow broken. The Micro SD card I had in it originally proved bad when I tried imaging it with a fresh OS install. A different card could successfully be imaged, but when I booted the RPi from it, some programs wouldn't run because they were corrupt.

I thought about buying a replacement RPi, but because of the RAMpocalypse, prices have gone through the roof. An equivalent new RPi 4 would cost $55, when I'm sure I purchased the original one for much less than that. With shipping it was looking like a $70-80 purchase, which seemed ridiculous.

In the end, I decided to simply run the Pi-hole and Wireguard services as Docker containers on the Mac Mini M4 I use as a media center. I leave the Mac Mini running all the time anyway, it uses only 4 Watts at idle, and it's more than capable of running these services.

Looking at pricing of new RPis, including the newest RPi 5, it got me thinking about the value proposition of the RPi 5 at the moment. The RPi was developed to be a low-cost, versatile single-board computer with many applications. All RPis can be used for various general and specialty computing projects, see the wide variety of RPi HATs available. However, with the newest RPi 5, they are trying to make the argument that it's becoming a general purpose computer for everyday use. They even highlight that the RPi 5 can drive dual 4K monitors at 60 Hz, not something I would associate with cheap computing.

Dual 4k

Let's look at this complete RPi 5 kit. It comes with all you need to get up and running, minus a monitor, keyboard, and mouse. A 256GB SSD kit with 8GB of RAM costs $320. The kit includes active cooling, which is required to achieve maximum performance. A base RPi 5 with 8Gb of RAM costs $175, which means the rest of the kit costs $145.

Let's compare this to a base Mac Mini M6. This comes with 256 GB of SSD storage and 16GB of RAM for $899. Like the RPi kit, it comes with everything you need save a monitor, keyboard, and mouse.

Using a $305 RPi 5 with 16GB of RAM to match the Mini (making the RPi kit $305 + $145 = $450), below I compare the speeds of these computers. I'm using this Mac Mini M6 benchmark and this RPi 5 benchmark.

Product Single Core Multicore Price
RPi 5 878 2,089 $450
Mini M6 4,661 20,525 $899
M6/RPi 5 5.3 9.8 2

We can see that the Mac Mini is over 5x faster in single core, and almost 10x faster in multicore, while the Mini costs only 2x more. That is a devastating price to performance ratio for the RPi. But wait!, you say, you can still buy two RPis for one Mini, which if you're on a limited budget (say, in a school), it really helps. But wait!, I respond, you still need to buy monitors, keyboards, and mice, which cost the same regardless if they're connected to a Mini or a RPi. The price savings with RPis isn't as big as you might think.

The true value proposition of an RPis are the GPIO pins which enables tons of fun and interesting computing projects. My solar water heater uses a RPi 3B+ and its GPIO pins to collect data and act as the thermostat. The tough spot that the RAMpocalypse has put RPi 5s is that this value proposition has been overtaken by component pricing, making the RPi 5 a poor choice for a general purpose computer. There might be situations where a faster RPi is needed when using the GPIO pins, but that's getting potentially niche. I would guess that most things you would need an RPi for could be done with one of the older and less expensive models.

Perhaps once the RAMpocalypse has passed the RPi 5 will again become an economical choice for hobby computing, but sadly, it isn't right now.


A Few More Command Line Utilities

I recently wrote about some useful command line utilities, and here are a few more I either forgot to add, or just discovered.

fd

I've never liked the find command. It's clunky to use, and worst of all often prints out hundreds of permission error lines. A good replacement is fd, which is faster and much nicer to use. For example, here's a search for this website's name starting from the root "/" of this Linode using find and fd, passed through wc (which counts characters and lines):

stderr/stdout line count, 1,301 for find, 19 for fd

You can see that find printed out 1,301 lines in 2.5 seconds, while fd output only 19 in 1.5 seconds. All of those 19 are useful lines, while most of those 1,301 lines are telling me where I can't search.

By the way, notice the red lock 🔒 symbol in the terminal above? That's Starship (which I mentioned previously) telling me that the user does not have write permission inside the current directory.

delta

Both mercurial and git feature the diff command, which shows you the difference in content between the current files on disk and the most recent commit. This is very useful as a way to see what's changed before you make a new commit. delta is a tool that (amazingly) works with both (mercurial is the often forgotten redheaded stepchild) and supercharges the diff command. It's language aware (like bat which I mentioned before), and offers a side-by-side viewing option. I haven't used it much, but I'm optimistic it will prove useful.

delta diff side-by-side

duf

For showing what disks are attached, and how much free space there is, duf is a pretty replacement for df.

delta diff side-by-side

Dust

The command "du" is used to sum up the disk spaced used in a directory. Dust does the same thing, but faster, and shows a hierarchical and sorted view of what files and subdirectories are taking the most space. Of all the tools I've featured here, this is the one I'm least sure about. I could see using it on a remote computer, but on my Mac I think prefer using something like OmniDiskSweeper that has a nice GUI and allows you to delete things interactively.

delta diff side-by-side


More LLM Commentary

I've already posted twice about using AI/LLMs, and buckle up for another exciting installment. But! Before I get into the meat of the topic, I need to lay some groundwork.

The company I work for uses Amazon Web Services (AWS) for compute and storage. Within AWS you're very much encouraged to set up a Virtual Private Cloud (VPC) which is a way of isolating your cloud infrastructure away from the internet and other AWS users. Part of the VPC is a firewall that prevents outside access to the Virtual Private Network. Of course, as an employee, I need to be able to get inside the firewall, so we have a VPN Gateway that allows outside users on the public internet to access resources inside the VPC, but only if you can successfully authenticate with the gateway.

Below is a diagram showing this. My laptop connects to the VPN gateway, and from the gateway I can access a Linux machine. For example, if I want to ssh into a Linux box, that connection gets wrapped via the VPN connection to the gateway, which then unwraps it and passes the ssh connection to the Linux box.

                 ┌─────────────────────────────────────────┐
                 │                VPC                      │
                 │                                         │
┌─────────┐      │ ┌──────────────┐       ┌──────────────┐ │
│ Laptop  ├──────â”ŧâ–ē│ VPN Gateway  ├──────â–ē│  Linux Box   │ │
└─────────┘      │ └──────────────┘  ssh  └──────────────┘ │
         VPN(ssh)└─────────────────────────────────────────┘

For reasons that are not important here, we are overhauling how we do various things with respect to security. One part of this is we are turning off the ability to ssh into Linux machines in favor of AWS SSM. SSM gives you an encrypted shell/terminal connection to a host, just like ssh, but it doesn't use ssh at all. One motivation is that AWS SSM allows convenient logging of who connected to a particular machine, when they did, and what shell commands they ran. Another is that access to resources can be defined at the AWS permissions level, away from the individual Linux machines. With SSM we don't need a gateway to access things inside the VPN. It works like this: When the Linux box boots, an agent on the machine registers itself with SSM, which lives outside the VPN (it's run by AWS, not us). Next, when I wish to connect to the box, my laptop authenticates with SSM, which checks if I'm allowed to connect. If I am, SSM connects me to the machine inside the VPN by forwarding data between my laptop and the Linux box. At the same time, logs are kept of the connection and commands I run. See the diagram below.

                    ┌─────────────┐  ┌─────────────┐
      ┌────────────â–ē│   AWS SSM   ├─â–ē│  AWS Logs   │
      │             └─────────▲───┘  └─────────────┘
      │                       │                     
┌─────┴─────┐                 │                     
│  Laptop   │    ┌────────────â”ŧ───────┐             
└───────────┘    │   VPC      │       │             
                 │  ┌─────────┴────┐  │             
                 │  │  Linux Box   │  │             
                 │  └──────────────┘  │             
                 └────────────────────┘             

The official way to connect is via the AWS CLI tool, which is written in Python. Somewhat oddly, the command to connect, aws ssm start-session --target instance-id --profile somename --region us-east-1, actually hands off to the Go binary session-manager-plugin after authentication is completed. This all works, but it wasn't satisfactory. I found it clunky and inconvenient — just compare the long aws ssm command above to the much shorter command ssh user@host-ip!

Much of that clunky command can be scripted away, but the official client has some broken functionality. For example, I don't use the nano text editor often, but it's useful for quick edits (I also use vi, if you're wondering). It uses "Ctrl-key" actions, such as searching ("Ctrl-w"), saving ("Ctrl-o"), and quitting ("Ctrl-x"). There may be something wrong on my end I never diagnosed, but I couldn't get any of those "Ctrl-key" commands to work. Additionally, ssh has its companion program scp that transfers files between computers. You can imagine that this is a useful feature, and it's something that SSM doesn't include.

Because of this I decided to see what an LLM (Claude) could do. I asked it to write a program that worked with AWS SSM but acted more like ssh. I named it sshaws. I told it to write it in Rust because Rust is fast, secure, and I figured that all the required crates would already exist. To give away the ending, the LLM did a fine job! The program doesn't have any of the odd quirks (no "Ctrl-key" problems) that aws ssm start-session does. But more than that, I tailored it to work well with my workflow, and it's now more convenient than ssh ever was, amazingly. Here are a few examples of neat features it has:

  • I had it add a Terminal User Interface (TUI) that auto discovers all the Linux boxes I have access to (see the screenshot below1). It shows if the instance is running, or if I can access the instance (perhaps the SSM agent isn't set up on the Linux machine). Other metadata can also shown, such as instance type, IP address, or environment. I can filter the instances list with a simple text search. The instance listing is especially useful for me because much of my workflow uses temporary Linux machines that exist for minutes to hours, so being able to quickly narrow down to one is great.

machine picker

  • There is a "recent" hosts pane that is useful for reconnecting to a host I've worked with recently (bottom left). Instances I have connected to that have been deleted are shown with strike through text, while those simply powered off use greyed out text.

  • The application has a config file that allows me to define quick shortcuts for machines I access frequently. These shortcuts are available in a TUI pane (top left), and also from the command line, e.g. sshaws webhost.

  • Unlike VPN/ssh connections, SSM connections can time out after as little as six hours due to AWS authentication rules. Having a session die while using it is very annoying, so I added a feature where sshaws will auto-connect to a running tmux session, or start one if needed. This way, if you're cut off, what you were doing on the host is uninterrupted, and you can pick up where you left off by reconnecting.

  • To replace scp I had the LLM add flags to transfer files: sshaws put file.txt webhost:/home/user/ or sshaws get webhost:/home/user/file.txt .. But even better, I had it add a second TUI (see below) that allows me to browse my local machine and remote, and mark files and directories for transfer either direction. It auto compresses and decompresses files and directories transparently to speed up transfers.

machine picker

  • I added a command each which will run a command on more than one host in parallel and return the result, for example sshaws each 'boxname*' 'uptime' will print out the result of running the uptime command on all hosts that match boxname*, e.g. boxname01, boxname02, and boxname-prod would all match.

Why was the LLM so successful at this? The answer is simple: LLMs are advanced prediction engines, like Google autocomplete, but fancier. If you tell it where to start and where to go, you're giving it a path to follow, and that's when they work best. In this case I asked it to put to things together (SSM & ssh) that it knows about because it's all open source, and what functionality I wanted. It didn't have to invent anything new, it just had to mix two things together by following my instructions.

Am I okay with using LLM like this? Yes, yes I am. My job is not writing tooling for accessing AWS SSM. As I said above, nothing new is being created here; existing things were just smooshed together. My job as a human is to create new things with my biological creativity, and offloading this task to an LLM was a win.

Finally, I don't know if I will try to make sshaws open source. There's nothing proprietary about it, so I could. I'm not super worried about major issues. I've passed it through Claude Fable2, which has been reported as being excellent at finding code bugs, and it fixed a few minor ones. While the tool might be useful for people outside my company, I would feel more comfortable about releasing it if I and a few other humans went through it and audited it for hallucinations and confusing comments, Fable's findings notwithstanding.

  1. All the screenshots use fake data â†Šī¸Ž
  2. I mainly used Claude Opus to write the code because it's cheaper than Fable â†Šī¸Ž

Useful Command Line Utilities

Recently I've been doing a little tuning of my shell environment, swapping old tools for new ones and tweaking various settings. I thought I'd highlight a few of them.

Ghostty

For years I used iTerm2 as a replacement for the default Mac OS Terminal app. Recently I've switched to Ghostty. It's just as configurable in the ways I care about as iTerm2, but much, much faster. I sometimes have reason to paste a decent amount of text into the terminal and Ghostty handles it much faster than iTerm2. Overall it just feels more modern and slicker than iTerm2.

Starship

terminal with starship, z, zi examples

In the screenshot above you can see a few shell prompts showing what Starship can do. For example, when you're in a folder containing a programming project, it will show you the language in use. For example in the "sshaws_rust" folder you can see "đŸĻ€ v1.97.1", which shows my current version of Rust installed. Similarly you can see "â˜•ī¸ v17.0.8" for Java, "🆂 v3.8.4" for Scala, and "🐍 v3.12.12" for Python. It also shows you stats about your machine (e.g. free RAM), what directory you're currently in, or how long a command took to run.

In the screenshot below, you can see the "🌏 marzipan" which shows that this is a remote machine named "marzipan," which helps prevent confusion about what machine you're on.

terminal with remote starship

zoxide

I haven't been using this very long, and I'm still getting used to it, but zoxide is a handy way to navigate around your folder hierarchy. In the first screenshot above you can see that z core took me straight to that directory and zi opens an interactive search function.

fzf

Like most, I'm sure, I end up typing the same or very similar commands repeatedly. "Ctrl-r" is the standard way of searching for previous commands. fzf turbo-charges this and works very well.

bat

terminal with bat

The Unix/Linux command cat is over fifty years old, and I've been using it for almost thirty. bat replaces it and includes syntax highlighting and line numbers. Because I've been using cat for so long, and have muscle memory for cat, I've set an alias from cat to bat.

eza

terminal with eza

Combined with a Nerd Font (I use "Inconsolata Nerd Font Mono"), eza replaces the built in ls and ls -l with a much fancier directory listing. In the screenshot above you can see that each document type gets a little icon, and there are far more color codes than plain ls. The columns shown in the -l view can also be customized much more than vanilla ls.

ripgrep

terminal with ripgrep

Many years ago I started using grin which is (was?) a recursive grep utility. Being a Python 2 utility and Python 2 reached end-of-life in 2020, I switched to grin3. Now I'm getting used to using ripgrep, which A) is faster than grin3, and B) is maintained while grin3 is not.

oh my zsh

I've been using zsh for years, and oh my zsh helps configure it with all kinds of goodies.

Raycast

Raycast conversion

It's not a command line utilty, but Raycast has proven invaluable. It's a supercharged Spotlight replacement. It has many useful features, not least of which is the Clipboard History. The Calculator is great for quick math and unit conversion.

Confguration Files

If you want to see my configuration files, just drop me a line!


Thunderbird, PGP, etc...

I try to keep personal and professional accounts separate on my computer. For example I typically use Safari for work related things and Vivaldi for personal stuff. I know that Safari supports profiles that would accomplish the same thing, but using entirely different browsers makes it easier to keep things straight. Similarly to web browsers, I split up my email by application. I used the macOS mail application for professional email, and accessed my personal email via a web browser (i.e. Vivaldi).

Recently, I decided to try out Thunderbird and bring all my email into one application. It can handle multiple accounts and does it with pretty good separation. Also, I wanted to set up PGP for my email, and Thunderbird seemed like the easiest and best way to do it. Almost no one uses PGP with their email, but that doesn't mean I can't. PGP can send fully encrypted emails, but this only works when the recipient has PGP set up, too. Since most people have not set up PGP, instead I send emails with plain text content and a digital signature file attached. This means that PGP uses my private key to generate a cryptographically signed bit of text that, when combined with my public key, can prove (or disprove) I sent the message. It can also be used to confirm (or deny) that the content of the email wasn't changed between sending and delivery. Almost nothing I send is super important, but the effort involved was small, so why not? I've pasted my personal email public key on my About Me page if you want to use it.

Because Thunderbird is open source and is heavily based on Firefox, you can add extensions to it, just like Firefox. I decided I wanted an extension that adds random quotes to the bottom of my new messages. Some quick searching showed this didn't exist, so I decided to write one. And by "write one," I mean I asked an AI to write one for me. I don't know JavaScript, I don't know how to write Firefox extensions, and I didn't want to learn. The AI did a good enough job and only had one bug that needed fixing (which it fixed after being asked to). I've published the code on github, and it is simple enough to use if you're interested. The plugin has a few built-in quotes, and I have made a library of cycling quotes that will be added to my emails going forward.

Finally, I can endorse Choosy. This is a simple utility that allows you to choose which browser opens up a link. For example, I have it set to send all web links I get in Slack (which I use for work) to Safari. If there is no predefined behavior, it gives you the option to pick which browser to send the link to. It's $10, so it's not free, but if you're like me and want this kind of separation, it's worth it.


RadioX Streamer Update

RadioX

There is no new album in the top ten this week, nor next week. The holidays seems like a bad time to release a new album.

In the meantime, an application named RadioX I wrote about previously was updated (not sure when) and now includes automatic last.fm scrobbling that saves a play per each new song. Previously you had to manually click a button with each new song to scrobble. This was really the only feature missing from it and now it's basically perfect. I suggest you check it out!


ETL Pipeline Improvements

One of my primary responsibilities at my current job is ownership of the ETL pipeline that brings in the data upon which we run our business. Every day it processes hundreds of gigabytes of data, cleaning and normalizing it, and outputting it in several different forms.

For a few years I have been using a Hadoop-based mrjob pipeline on top of AWS EMR. It replaced a (I kid you not) Redshift-based pipeline that was hugely expensive (that I didn't write). It's been very reliable. For the last year or two the only failures have been when AWS's systems have had issues, something I can't do anything about. Despite this reliability, it hasn't been perfect. The biggest problem with it is that it's expensive to run. There are few reasons why it's been so expensive:

  • EMR adds a 25% upcharge on all resources used. It is reasonable for AWS to charge something because EMR is a useful service with added value. However, in my opinion, 25% is too high for what it does. AWS already gets paid plenty because you're using their other services underneath it (mainly EC2 virtual computers and EBS block storage), so the extra mark-up feels like a big cash-grab. It is, of course, entirely possible to run Hadoop on AWS without using EMR. But it is a hassle, and it's likely that AWS has figured out that 25% is the inflection point between too expensive and not worth the hassle

  • Hadoop isn't the most efficient way of doing things. Newer tools, notably Spark, have surpassed Hadoop in both speed and features. I originally used Hadoop because I wasn't happy with how Spark needed quite a bit more memory than Hadoop for a similar operation, but over time I became less and less satisfied with my inability to speed up certain parts of the process

  • AWS offers spot compute instances, which are virtual computers that are significantly cheaper than on-demand instances. The difference is that on-demand nodes are yours as long as you want them, while spot instances can be taken away at any time with only two minutes warning.

    One of Hadoop's killer features is that during a MapReduce cycle, if one or more worker nodes goes away (for whatever reason including spot node removal), in most cases it can recover and redo any lost results.

    However, the EMR pipeline used a multi-step MapReduce process. Unfortunately, Hadoop cannot recover lost results from earlier, fully completed MapReduce cycles. This means that in order to run the pipeline, it had to have enough on-demand instances that the data that needed to be preserved across cycles fit on them. This raised the cost considerably when compared to an all-spot pipeline run

Earlier this year I decided it was time to start looking at how to rewrite the pipeline to dramatically lower costs. I saw two possible ways forward:

  • Choose a modern, high performance tool like Spark/PySpark or Dask that would still run on EMR but hopefully would be much faster

  • Abandon EMR entirely (and its 25% surcharge) and write something that could run completely on spot instances and use S3 for storage, which is four to five times cheaper than EBS

After some thought, I decided that the second option was the better choice. If I could figure it out, it offered the best possible outcome. The pipeline runs once per day, meaning that it has 24 hours to finish before the next run needs to start. Ultimately, high performance was less important than lowering costs.

I have been using Polars quite a bit and have been (mostly1) impressed with its speed and functionality. It is written in Rust, which is one of the fastest programming languages. Polars has a Python-facing API as a first-class member of the project. Rust has an ever-growing library of packages that I've found are high-quality and well documented (in contrast to my experience with cough R packages). The crucial difference between Polars and Hadoop/Spark/Dask is that Polars runs on only one node at a time (it can and does use all the CPU cores), while all of the others can run on multiple nodes. If I could figure out how to slice up the pipeline into chunks that would work on separate instances, I believed I could use Polars in place of Hadoop.

Jumping to the end of the story, I was able to convert the pipeline to use Polars, and to great success. I use a simple pattern for each step. An orchestration process builds a list of work which is submitted to SQS. An EC2 spot fleet is created which launches workers that consume the work. The input and output of the work is stored on S3. The workers send success or failure messages to a callback queue on SQS, which is monitored by the orchestration process. If a spot node goes away interrupting work, the work will be picked up by a different node once the message returns to availability. Once the work is done for a step (i.e. all work has generated a callback), the orchestration process kills the spot fleet and continues to the next step (or sends an error message for a human to figure out).

The bottom line is that the cost has dropped by roughly 85%, primarily due to the following reasons:

  • Polars has the concept of LazyFrames which are data objects that are not realized in memory nor computation until Polars is told to do so. Operations and filtering can be applied to them and Polars can do the work in parallel with efficiency tricks that overall increases speed without loading the whole dataset into memory at once. The combination of sink_parquet with PartitionByKey is effectively a MapReduce operation that is much faster than Hadoop on similar hardware

  • AWS has "regions" and "availability zones (AZs)" which are the physical locations where cloud compute happens. Each AZ is a distinct data center (or close by data centers) within a region. When running an EMR job, you are restricted to a single AZ largely because AWS charges for cross-AZ data transfer, and EMR jobs are very loquacious across the network. There's also increased network latency between AZs. Running and EMR job in multiple AZs would hugely impact performance and cost.

    Because the new pipeline reads from and saves data to S3, and there are no cross-AZ charges for accessing S3 within a region, it doesn't matter which AZ the workers run in. This means that the spot fleets can target all AZs within the region, unlike EMR

  • When launching an EC2 fleet, you must specify one or more launch templates, which describe how to launch each instance in terms of OS and installed software. AWS EC2 offers instances using x86 processors from Intel and AMD, and ARM instances using AWS Graviton processors. Conveniently, the pipeline doesn't require any processor-specific features. Therefore, I created two AMIs, one for each of x86 and ARM, which allows the spot fleet to target any and all of Intel, AMD, and Graviton instances

  • The pipeline requirements for each step basically comes down to number of CPU cores and amount of RAM, more or less of each depending on what the step is doing. The upshot of all of the above is that for a given step all the pipeline cares about is the resources of the node, not what kind of node it is. Of course, not all instances are the same speed, but the cost of an instance is roughly proportional with its speed, so it all works out. This means that for a given step, across all AZs and EC2 instance types, there can be over 100 distinct resource combinations to pick from. This basically guarantees spot availability at all times

  • The pipeline uses a fair number of User Defined Functions. Polars supports UDFs written in Python, Numba, and Rust using PyO3. By using the latter two, basically all of the inner loops and heavy computation in the pipeline happens in compiled C or Rust. This, in my opinion, is a really nice way of doing things. Let Python handle moving data around and high-level stuff, and run all the heavy computation in compiled code.

Overall, I'm very pleased about the results of this work. The goal was to save money, and it has done that. I wasn't expecting 85% savings (I'm not sure what I was hoping for), but I feel quite good about that.

  1. Polars definitely has some frustrating issues, like this one or this one â†Šī¸Ž

Agument Code

Last month the company I work for purchased a subscription to Augment Code for all its developers. Augment Code is an AI coding engine that is broadly similar to Claude Code, which I played around with a few months ago. You can read the linked post, but the summary is that I came away mostly skeptical about AI coding. However, I am not a luddite, and am willing to learn new tools and try things again, so I installed the Visual Studio Code Augment plugin and have been giving AI coding another shot.

What I've learned is that AI coding agents are more useful than I gave them credit previously if you give them small enough jobs that are well-defined. Asking it to do too much, which perhaps I did in my earlier blog post, is not (yet) what it's good at. Augment code has a few modes. There is a chat box in which you can conversationally interact with the AI, asking it questions or giving it tasks to complete. The agent will also give autocomplete suggestions as you type new code, which I'd say is mostly helpful, but not always. Sometimes the suggestions are just plain wrong, but a few times the suggestions have been subtly wrong, which is dangerous.

Here are some example tasks that Augment Code has been at least 90% successful at:

  • In one of my Python projects, I asked it to create a file that tries to import all the packages used in the project, and output which packages do and do not import successfully. This project uses a few custom & private packages I keep elsewhere, so a requirements.txt file doesn't work with pip. Having a file I can run to quickly check I installed all the packages is useful. It did a pretty good job of this, but it did miss one import from one file, probably because the import wasn't near the top of the file (which is an anti-pattern, but it's there for reasons)
  • It is quite good at adding type hinting to Python projects. You can ask it to "add type hinting to all functions in all Python files in this directory" and it does it
  • I have a PyO3 project that it successfully threaded/parallelized using Rayon. I had to be very specific about how the inputs and outputs would change, but with that it did a good job. It wasn't perfect. Instead of using lightweight vector slices, it was creating new vectors for each chunk of parallel work, which involves copying memory. When I suggested a change, it did a good job fixing that oversight
  • I am an unapologetic user of Mercurial. The rest of the world uses Git. Kind of like Mac and Windows, Mercurial and Git are 99% the same in what you can do with them, but they differ in methods and style. In fact, there is a Mercurial plugin that allows perfect 1:1 interoperability between the two, which I use. Sometimes I don't want to bother installing Mercurial on a temporary virtual instance that already has Git installed, and I want to do something quick in Git. I've asked the AI agent to translate a Mercurial command to Git and it's done a fine job

It appears that my company has a (grandfathered) $50/mo/user plan, which has jumped to $60/mo/user now for new purchases. I would say that it has saved me enough time to justify that price. The real question is how much the service actually costs? The AI industry is spending so much money that "to recoup their existing and announced investments, AI companies will have to bring in $2 trillion (every 2-3 years), more than the combined revenue of Amazon, Google, Microsoft, Apple, Nvidia and Meta." It feels like the early days of Uber, where the fares were subsidized by venture capital, and once most competitors were vanquished, prices went up. To reach $2 trillion in revenue, how high would prices have to go? There are currently a bit over 8 billion humans on earth, which means that over 3 years, the whole AI industry will need to take in about $80 from each and every person on earth per year. That is a ridiculous number and will not be reached any time soon.

My opinion is that AI does has some value, but not nearly as much as it costs in real terms. I'll use it if it works for me. But I won't rely on it.


A Polars Memory Leak Trick

I am a big proponent of Polars for data analysis. It combines the ease of Python with the speed of Rust. In many cases it allows working with very large datasets very convenient. I have even written about it before on this blog.

Despite the nice things I wrote above about Polars above, it is still a work in progress. One big issue it has is less than ideal memory management when working with very large dataframes as discussed in this ticket on github. I have seen similar issues with Polars, where for no explicable reason it will run my machine out of memory. Below is a simplified example of a situation that I have run into this problem.

This example is in the middle of a processing pipeline. I have created a set of Parquet files in which I am including an ff column because I want to be able to filter on it. The entire set of Parquet files in dirname would not fit in memory, but a subset will, and I can process these subsets separately and combine the reduced dataframes at the end to achieve the same result. The distribution of values in ff is very even, meaning that each subset uses very closely the same amount of memory. Because ff is in the Parquet files, Polars can use predicate pushdown to filter on ff at the read step, meaning that the full dataset is never read into memory.

Indeed, the first few loops of this process work quite well. The filtered subsets fit into memory, and reduced dataframes are calculated. However, eventually Polars stops managing memory correctly and things go bad, and the machine runs out of memory.

import polars as pl

data = pl.scan_parquet(dirname)

reduced = []

# this will eventually run out of memory
for ff in range(N):
    print("doing", ff)
    # note that data is untouched each cycle
    data1 = data.filter(pl.col("ff") == ff)
    # Do some various LazyFrame manipulations on data1; we don't call
    # .collect() until below
    reduced.append(data1.collect())

reduced_data = pl.concat(reduced)

If the situation is amenable, there is a way around this. By running the Polars steps in a subprocess using multiprocessing, we can force Polars to free memory after each cycle by shutting down the process that runs Polars every cycle. Of course, there is a little bit of additional overhead here. Starting the subprocess takes a little time, as does re-scanning the directory of files in scan_parquet(). There is also some cost in un/pickling the reduced dataframe between the main process and the Polars subprocess. But if the data is large enough to resort to chunking like this, these extra costs are rounding errors, and are not worth worrying about.

from multiprocessing import Process, Queue, set_start_method

def worker(dirname, ff, out_q):
    data = pl.scan_parquet(dirname)
    data = data.filter(pl.col("ff") == ff)
    # Do some various LazyFrame manipulations on data; we don't call
    # .collect() until below
    out_q.put(data.collect())

if __name__ == "__main__":
    set_start_method("spawn")

    out_q = Queue()

    # this works to completion
    for ff in range(N):
        print("doing", ff)
        p = Process(target=worker, args=(dirname, ff, out_q), daemon=True)
        p.start()
        reduced.append(out_q.get())
        p.join()

    reduced_data = pl.concat(reduced)

I think this trick very simply illustrates the way that Polars is currently mismanaging memory. The two examples above are doing the same basic thing, but one works and the other doesn't. In fact, if I run the two methods above and watch memory use in real time, the two methods have similar behavior for some number of cycles. The memory use goes up and down as the filtered data is processed and cleaned up each cycle. This indicates that Polars can do memory management correctly, but for some reason after too many cycles, Polars stops freeing memory. In the github ticket linked above, it's suggested that a fix might have a performance cost. Hopefully something can be done about this that both prevents the memory leak and doesn't cost too much in performance. For now, this trick can be useful in the right situations.


Go Big To Go Home

The first step of data science when working with new a dataset is to understand the high-level facts and relationships within the data. This is often done by exploring the data interactively by using something like Python, R, or Matlab.

Recently I've been exploring a new dataset. It's a pretty big dataset: a few hundred gigabytes of data in compressed Parquet format. A rule of thumb is that reading data off disk into memory takes ten or twenty times the memory than the storage the data uses on disk. For this dataset, that could equal more than ten terabytes of memory, which in 2025 is still a pretty ridiculous amount of memory on a single machine. It is for this reason that working with data this size requires tools that allow you to work with the data without loading all of it into memory at once.

One of these tools is Polars. Quoting the Polars home page: "Want to process large data sets that are bigger than your memory? Our streaming API allows you to process your results efficiently, eliminating the need to keep all data in memory." It's still a bit rough around the edges with some unfinished and missing features, but overall it's a powerful and capable tool for data analysis. Lately I've been using Polars more and more, taking advantage of this "streaming" ability.

On the other hand, sometimes it's easiest to do things directly and skip all the low-memory "streaming" tricks. If I can get an answer more quickly by simply using lots of memory, especially if it's something I'm doing only once and not putting into a repeated process, then this can be the right choice. Polars can do "streaming" analysis, but at a certain point it has to coalesce things into an answer, and sometimes that answer can use a significant amount of memory.

There are many negative aspects of cloud computing that I won't get into here. However, there are some good things, and one of them is that you can scale up and down resources as needed. All cloud providers, like Amazon Web Services and Google Cloud Platform offer many services and in particular Virtual Machines. When running a virtual machine you can choose the hardware specifications in terms of CPU kind and core count, amount of RAM, and other features like network speeds, GPUs, or SSDs. A virtual machine can be booted on one hardware configuration, shut down, and the rebooted on a different configuration as needed. It's as if you took the hard drive out of your laptop and put it in a big workstation. All your data and settings are still there, but you've upgraded the hardware. This is something I take advantage of frequently!

I was attempting to do a certain analysis of the new dataset on an EC2 virtual machine and I kept running out of memory. Instead of switching to some low-memory tricks, I decided to see if I could save some time by simply rebooting my virtual machine on one of the larger instances AWS offers: a r7i.48xlarge. This has 192 CPU cores and 1,536 GB of RAM. It costs $12.70 per hour. I get paid more than $12.70 per hour, so if booting up a huge machine like this saves me even a little time, it's worth it.

btop view of a large linux instance

Above is a screenshot of btop running on the r7i.48xlarge instance while I attempted to run my analysis. If you click on the image, you'll see the full size screenshot. You'll see that I'm about to run out of memory: 1.41TB used of 1.45TB. You'll also see that I'm using all 192 cores at 100% load (the cores are labeled 0-191). Unfortunately, throwing all this memory at the problem didn't work, I ran out of memory, and I had to resort to being more clever. Being clever took more time, of course, but if the high-RAM instance had worked, it would have paid off.

Playing with various server configuration tools (like this one) shows that the r7i.48xlarge would cost at least $60,000. This is not something that I need very often, and purchasing something this large would be ridiculous. However, renting it for half an hour, if it saves me a few hours, is definitely worth it. Also, it's kind of fun to say "yeah, I used 1.5TB of memory and 192 cores and it wasn't enough."


Polars scan_csv and sink_parquet

The documentation for polars is not the best, and figuring out how to do this below took me over an hour. Here's how to read in a headerless csv file into a LazyFrame using scan_csv and write it to a parquet file using sink_parquet. The key is to use with_column_names and schema_overrides. Despite what the documentation says, using schema doesn't work as you might imagine and sink_parquet returns with a cryptic error about the dataframe missing column a.

This is just a simplified version of what I actually am trying to do, but that's the best way to drill down to the issue. Maybe the search engines will find this and save someone else an hour of frustration.

import numpy as np
import polars as pl

df = pl.DataFrame(
    {"a": [str(i) for i in np.arange(10)], "b": np.random.random(10)},
)
df.write_csv("/tmp/stuff.csv", include_header=False)

lf = pl.scan_csv(
    "/tmp/stuff.csv",
    has_header=False,
    schema_overrides={
        "a": pl.String,
        "b": pl.Float64,
    },
    with_column_names=lambda _: ["a", "b"],
)

lf.sink_parquet("/tmp/stuff.parquet")

Claude Code

A few weeks ago I started playing with Claude Code, which is an AI tool that can help build software projects for/with you. Like ChatGPT, you interact with the AI conversationally, using whole sentences. You can tell it what programming language and which software packages to use, and what you want the new program to do.

Advanced Mortgage Funding Calculator

I started by asking it to build a mortgage calculator using Python and Dash. Python is one of the most popular programming languages and Dash is an open source Python package that combines Flask, a tool to build websites using Python, and Plotly, a tool that builds high-quality interactive web plots. The killer feature of Dash is that it handles all the nasty and tedious parts of an interactive webpage (meaning Javascript, eeeek!). It deals with webpage button clicks and form submissions for you, and you, the coder, can write things in lovely Python.

With a fair amount of back and forth Claude Code built this advanced mortgage calculator, which is only sorta kinda functional. It does a fair amount of what I asked it to do, but it also doesn't do a fair amount of what I asked it to do, and it has a decent number of bugs. The good things it did was handle some of the tedious boiler plate stuff like creating the necessary directory hierarchy and files, including a README.md detailing how to run the software. Creating a Dash webpage requires writing Python function(s) and a template detailing how to insert the output of the function(s) into a webpage, and Claude Code handled that with aplomb.

What it didn't handle well was more complicated things, like asking it to write an optimizer for funding/paying off a mortgage considering various funding sources and economic factors. It also didn't write the code using standard Python practices. The first time I looked at the code using VS Code and Ruff, Ruff reported over 1,000 style violations. If I found a bug in the code, some of the time I could tell Claude to fix it, and it would, but other times, it would simply fail. Altogether there's about 6,000 lines of code, and as the project got bigger it was clear that Claude was struggling. Simply put, there's a limit of the size or complexity of a codebase that Claude can handle. Humans are not going to be replaced, yet.

At this point I'm not sure what I'll do with the financial calculator. I don't think Claude can help me any more, so I'd have to manually dive in to fix bugs and improve it, and I haven't decided if I will. In summary, my impression of Claude is that it's decent at creating the base of a project or application, but then anything truly creative and complicated is beyond what it can do.

Claude Code isn't free (they give you $5 to start) and I had to deposit money to make this tool. I still have a bit of money to spend, so let's try a few tasks and see how Claude does. I've uploaded all of the code generated below to this repository.

Simple Calculator

I asked it to create a simple web-based calculator, and at a cost of $0.17, here is what it created that works well (that's not a picture below, try clicking on the buttons!).

Simple C Hello World!

Create a template for a program in C. Include a makefile and a main.c file with a main function that prints a simple "hello world!". $0.08 later it performed this simple task flawlessly.

Excel Telescope Angular Resolution

Create an Excel file that can calculate the angular resolution of a reflector telescope as a function of A) the diameter of the primary mirror and B) the altitude of the telescope. It went off and thought for a bit, and spent another $0.17 of my money. It output a file with a ".xlsx" extension, but the file can't be opened. Looking at the output of Claude, I suspect that this may be a file formatting issue because Claude is designed to handle text file output rather than binary.

Text to Speech

Seeing that Claude struggled with creating binary output, next I asked it to create a Jupyter notebook (Jupyter notebooks have the extension .ipynb but they're actually text files) that uses Python and any required packages and can take a block of text and use text to speech to output the text to a sound file. This succeeded ($0.12), and in particular used gTTS (Google Text To Speech) to do the heavy lifting.

Rust Parallel Pi Calculator

Write a program in Rust that uses Monte Carlo techniques to calculate pi. Use multithreading. The input to the program should be the desired number of digits of pi, and the output is pi to that many digits. $0.11 later, I got a Rust program that crashes with a "attempt to multiply with overflow" error. Not great! I could interact with Claude and ask it to try to fix the error, but I haven't.

Baseball Scoresheet Web App

Create a web app for keeping score of a baseball game. Make the page resemble a baseball scoresheet. Use a SQLite database file to store the data. Make the page responsive such that each scoring action is saved immediately to the database. At a cost of $0.93, it output almost 2,000 lines of code. The resulting npm web app doesn't work. Upon initial page load it asks the user to enter player names, numbers, and positions, but no matter what you do, you cannot get past that. Bummer!

Baseball App Interface Doesn't Work

Random Number Generator

It looks like the more complicated the ask gets, the worse Claude gets. Here's one more thing I'll try that I have no idea how to do myself. We'll see how well Claude does at it. Create a Mac OS program that generates a truly random floating point number. It should not use a pseudo-random number generator. It should capture random input from the user as the source of randomness. It should give the user the option of typing random keyboard keys, or mouse movements, or making noises captured by the microphone. Please use the swift programming language. Create a Xcode compatible development stack. Create a stylish GUI that looks like a first-class Mac OS program. $0.81 later, and asking it to fix one bug, led to a second try that was also broken with 10 bugs. Clearly, I've pushed Claude past its breaking point.

Random Number Generator App Doesn't Work

I'm guessing that all of the broken code can be fixed, maybe by Claude itself, but it ultimately might require human intervention in some cases. I'm optimistic that it could fix the Rust/pi bug, but I'm not optimistic that it can fix the baseball nor random number generator stuff. AI code generation might be coming for us eventually, but not today.


RadioX Streamer

RadioX Now Playing

Almost a year ago I linked to Finale which is an iOS app that listens to the music you're playing and auto-scrobbles to last.fm using song recognition methods similar to Shazam or SoundHound. It works decently well, but it requires two devices: your iOS device (which can't be playing music), and something playing music over speakers. With these limitations its utility is somewhat stunted.

Recently I discovered RadioX 5, which is a Mac OS internet radio streaming application that includes the ability to scrobble plays to last.fm. It has many other features but this one is key for me. It lives in the menubar so it's very unobtrusive. The one disappointment is that it doesn't automatically scrobble songs — you need to manually hit the red circular last.fm icon in the app to save the play. At first this seems like a a huge omission, but without some external way of knowing what is a song and isn't, the application would end up scrobbling non-songs. For example, below is what the application shows when the DJ is speaking between songs on The Colorado Sound (I don't know why the cover art is for Lynyrd Skynyrd, it wasn't played before or after the DJ interlude). I wouldn't want to scrobble the non-song "The Colorado Sound" by the non-artist "The Colorado Sound."

RadioX DJ Speaking

Short of access to a comprehensive database of global artists+songs titles, which if it exists I'll bet wouldn't be cheap for programmatic use, I can think of one way that might allow for auto-scrobbling. If the application had a way to prevent scrobbling for a particular artist+song combination set by the user, probably custom to each radio station, then auto-scrobbling everything else might be practical.


Infinite Mac

Sometime in 1994 me and my father went to a small computer show in the UC Berkeley Student Union building (which appears to now be named The MLK Jr. Building). It was probably a Macintosh oriented event, and among the various tables there was a Power Macintosh 6100 on display. The first Macintosh computers used Motorola 68000 series chips, and in 1994 Apple was making a transition to PowerPC chips. The 6100 was the first Mac to use a PowerPC chip, and seeing one in person was exciting. PowerPC chips promised a leap in performance, and I wanted one very badly. I had to wait at least a year to enter the PowerPC world when my father bought a PowerMac 8500.

Some time ago a Mac enthusiast released a website, Infinte Mac, that allows you to run old Mac operating systems in your browser. It starts with System 1.0, and has many releases all the way up to MacOS 9, the last version of the original Macintosh OS before they made the switch to the Unix-based OS that's still in use today. I suggest you try it out, it's really fun! I like playing with the various options because it reminds me of using and playing with computers from my childhood. The machines include quite a bit of pre-installed software. Many of the games I played actually work, which is impressive. It also shows how interfaces have evolved and mostly improved over the last 30-40 years.

The website uses various software emulators (including Basilisk II and SheepShaver) to simulate specific CPUs. To rephrase, what's happening is that the classic Macintosh system is running inside of a bit of software that, on the fly, translates old CPU instructions so that they run on a different CPU type. This is naturally less efficient than running instructions directly on a real CPU.

Recently I tried running a benchmark program (Macbench) in the emulator. Below is what I got on my M1 Max MacBook Pro. As you can see, the processor score is nearly five times faster than the PowerMac 6100 I wanted so long ago. Considering that my laptop has ten cores, my laptop is roughly 50 times faster than the PowerMac 6100 while running in emulated mode. It's been 30 years and of course progress progresses, but I still find it super impressive how much faster my laptop is using software emulation. Sitting here on my lap is a machine that's orders of magnitude better than what my 14 year old self wanted so badly. Huzzah!

Macbench M1 Max

Earlier this month I bought a Mac Mini M4 to replace our six year old Mac Mini i3. As you can see, the M4 is over seven times faster than the PowerMac 6100. Being three generations newer than my laptop, it naturally gets a better score.

Macbench M4

As an aside, I think that the floating point functions must be emulated in a less efficient way than the main processor functions. I don't think that the relatively low floating point scores are representative of the actual M1/M4 CPU performance.