Some Bits: Nelson's log

120 posts in 2023

Post-virtualization thoughts

Phew, my physical to virtual server migration using Proxmox mostly worked. I’ve now moved my main life server, the one I’ve been maintaining or evolving over 25+ years, for the first time into a VM. And it mostly works! Some collected thoughts after the fact.

Checkpoints and backups at the VM level are nice. Really looking forward to that.

This plan of virtualizing a server by first making one giant VM is nice. I can now hive off services to run in specific containers or VMs at my leisure.

Jeff N talked me into trying ZFS on the Proxmox host and so far I’m glad for it. ZFS seems complicated to me but Proxmox is clearly built to take advantage of it. Checkpoints already work better than on BTRFS.

I’m still working out where stuff should live and how it should be shared once I start containerizing services. The obvious thing is to put the primary home for everything in a ZFS pool maintained by the Proxmox server itself (just with ZFS, no Ceph.) My home directory, my Music library, my Video library, a place for backups. Share to containers via bindmounts. Sharing to VMs is harder. I think NFS is the best solution for now until virtiofs in Proxmox is a bit more finished.

Yes, I said NFS. Ugh. I’ve got it working with an NFS server on the Proxmox host itself and the VM mounting it. Setting up automount gave me bad flashbacks to the 1990s, although of course systemd has its own way of doing things. But NFS implies a lot of overhead. Also the confusion of user ID mappings. I’ve never really administered NFSv4 which has some nice things but I may gouge my eyeballs out of I have to set up Kerberos. OTOH I’m really not comfortable letting anything on my LAN mount stuff with root privileges. A work in progress.

Syncthing is working OK in the VM right now. Syncthing is peer to peer but I think of it as hub-and-spoke, with this server being the hub. I think I want to hive that Syncthing hub off to its own container. I see myself possibly also setting up a separate Syncthing instance in some containers or VMs but that sure seems dumb. More work in progress.

Syncthing + NFS is scary. The risk is that NFS is unreliable, so the directory for a synced folder might disappear. And in a bad case Syncthing might interpret that as a command “Delete all the files” and propagate that to all the clients. This really happens in practice and is very bad. They have a sentinel file to protect against this, the .stfolder. I still can’t help but think that syncthing is best run on a local filesystem and not a networked one.

I’ve got Plex running in a VM. Right now it doesn’t have access to the Intel GPU, so it can’t do hardware acceleration of transcoding with Quicksync. There’s ways to make that work but I think I should prioritize moving Plex first into a container, the tteck scripts work with hardware transcoding.

Backups are a big question mark. I’ve generally used rsnapshot but that requires root access to work well, since it’s setting file ownership. And root access to NFS is a no. I’m thinking of switching to Restic for backups instead. How this will work depends a bit on my “who should own what files” question.

I also want to make VM and container backups in Proxmox itself, separate from my personal data. And I’d like to back up the Proxmox server configuration itself; it’s crazy there’s no tool for that.

I need to rethink using RAM for tmpfs in the VM. Also using a swapfile. It’s all working but I bet it’s not optimal.

Proxmox physical to virtual take two (QCOW2 and tar)

I had so much success with Proxmox for my little home server that I decided to install it for my big home server, the one doing the important stuff. Like before I’m going to ease the transition by first cloning the whole Ubuntu server into a VM in Proxmox, then work on migrating individual services out to their own containers or VMs one at a time. Much thanks to Jeff N for email support learning how to do this.

The interesting thing here is various methods for cloning a physical Linux system into a Proxmox VM and making it bootable. I did this once already using Clonezilla. This time I’m trying two other methods: cloning with a QEMU disk image and cloning using tar on the root filesystem. I’ve now gotten all 3 methods to work. I think the QEMU disk image is my favorite route, it’s relatively compact and straightforward. Every method could be useful though.

Battle plan

The server I’m starting with is this one, with this hardware. The challenge is I want to replace the Ubuntu server OS on the machine with Proxmox, with the former server now running as a VM under Proxmox. The nerds call this a P2V clone. The general challenge is how do you clone a Linux system and make it bootable? A particular challenge is I’m trying to do it in-place, I don’t have a second server to clone to. And in particular I want to re-use the existing 2TB SSD, and even though I’m only using 80GB or so of that any simple full mirror will take forever and waste the other 1920GB.

I’m particularly scared of the moment where I install Proxmox over the old server’s filesystem. Once that’s done the clock is ticking to get the new VM up and running so I have my important services back. So first I did a couple of dry runs installing Proxmox on an external USB drive I had lying around. Here’s the plan I came up with:

  1. Remove unneeded files from the server like the apt cache or the systemd journal.
  2. Make simple tar and/or rsync backups of all the files and put them in a safe place. This is the “in case of disaster” recovery option.
  3. Turn off some services on the server that I don’t want to start immediately when the server wakes up as a VM.
  4. Shut down the server and boot a Linux system rescue disk.
  5. Use the rescue disk to clone the old system disk via either qemu (path 1) or tar (path 2) to an external USB disc. See below for details.
  6. Install Proxmox on an external USB disc on the server hardware. Don’t wipe the old server system! We’re going to test stuff is basically going to work before committing.
  7. Create a VM in Proxmox for the newly virtualized server
  8. Copy the clone into the disk for the virtualized server. See below for details.
  9. Boot the clone VM and get it working.
  10. Once satisfied, repeat the whole process but install Proxmox onto the SSD instead. Burn the boats!

It helps to have some spare fast SSD USB discs lying around for these 80GB copies of things. I used several. One for copying server clone images to. One to install Proxmox on (temporarily). And a couple of small jump drives for booting Proxmox and rescue disk images.

What I’m not doing is what I did last time using Clonezilla to make the clone. That requires two running servers (the original and Proxmox). Also the destination disk needs to be as big as the source disk and have room left over for Proxmox; not possible with my replace-in-place plan.

One thing I mostly didn’t do was try to resize the root partition or disk image to be smaller, closer to the 80GB I actually need instead of the 2TB of the source disk. It would probably make things go smoother but all the various resize options are a little scary. I did experiment with this once I got the VM working, see notes here. For the real thing I did resize the btrfs filesystem itself to 200GB, but the partition and the disk are both still 2TB.

OVMF bios notes

I’m trying to do all this with EFI and Secure Boot. It worked on my physical server, it should work on the Proxmox VM too. Some notes on that:

  • For EFI you must select the OVMF BIOS when creating the VM in Proxmox. It’s not the default.
  • The OVMF EFI shell is weird. It’s a 5 second timeout, then a command line I didn’t understand, and then if you exit that you get to a simple TUI BIOS menu like you’d expect. You can also hit ESC to bypass the 5 seconds and command line.
  • There’s a bunch of confusing boot config options. If you’re just trying to boot a specific thing, try Boot Maintenance Manager / Boot From File and then browse the filesystems. Ubuntu’s boot works from EFI/ubuntu/shimx64.efi
  • I could not get OVMF secure boot to work in a VM with the System Rescue ISO. You’d try to launch it and it’d just return. It works if you turn off secure boot in OVMF. Maybe it’s an issue with the ISO virtualization.

Path 1: QEMU image clone of the whole disk

This method creates a .qcow2 file which is conceptually an image of every block on the source disk. I got the idea to try this from a Reddit discussion. You make the .qcow2 file and load that in to QEMU/KVM on Proxmox and you’re done. It’s pretty straightforward but some details tripped me up.

Making the QCOW2 file was relatively easy with these directions. The key command is qemu-img convert -O qcow2 /dev/sda disk.qcow2. Note this clones the entire disc, not just one partition, which means the partition table, GRUB, and the EFI stuff stays intact. Fortunately the QCOW2 format is smart about unused sectors so my 2TB disc resulted in a 80GB QCOW2 file and was relatively quick (10 or 20 minutes?). (There’s also a -c to compress which might help?)

Using the QCOW2 file on Proxmox was a bit trickier. These notes were useful to me. Basically you create a new empty VM in Proxmox with no install media, no virtual hard drive. Then you use qm disk import to create a new disk from your clone. It converts the QCOW2 file into whatever format Proxmox wants. In my case that was a 2TB raw file on BTRFS. Thankfully it’s a sparse file so it only uses 80GB of the disk. (ls -l shows 2TB, du and btrfs filesystem du show 80G. ZFS also makes sparse files.) This new disk had two partitions cloned from my Ubuntu install: /boot and /. But I didn’t have to do anything special for each partition to make them work.

There’s some subtle configuration things I had to do in Proxmox:

  • It’s essential to select the OVMF BIOS for the VM so that EFI booting works.
  • Proxmox wants an “EFI disk” configured. That seemed to be the default once I told it to use the OVMF BIOS. It’s only 500KB, not sure what’s in it, maybe the BIOS? It’s not your system’s boot partition.
  • It’s important to specify a cache policy for a BTRFS disk image. The default is “no cache” which apparently causes corruption issues; I used “write back”. No need if you’re using ZFS on Proxmox.
  • I had to fiddle with the boot order of things in both Proxmox and maybe the BIOS to get it to actually boot the partition for the cloned Linux system.
  • I did not have to disable secure boot. It worked with my virtualized GRUB setup from the clone without changes.
  • I had to set the CPU type to “host” for KVM virtualization to work, so that my Ubuntu system could load the kvm_intel module that snapd wanted. This might cause a problem if you want to migrate a VM to another host in a Proxmox cluster. But it might also give a performance boost.
  • The graphical console was a bit wonky under Ubuntu; sometimes it’d be distorted early in the boot and then fix itself in a couple of seconds. I tried setting the graphics hardware to “VMWare Compatible” and that fixed the distortion, but then sometimes boot would fail mysteriously. See below.

With all that in place, the cloned system booted in a VM! The old familiar GRUB menu and Ubuntu loaded like a champ. Really this was pretty easy.

I initially created a VM with no network device because I knew that DHCP meant my Proxmox server had now stolen the IP address the old server was using. Not good having a VM boot and use the same IP as its host! Fortunately systemd boots pretty nicely if there are no network devices. It gets messier if there are network devices that aren’t configuring themselves; there’s a 120 second timeout for that.

I had to make some changes to the newly virtualized Ubuntu server to make it cooperate better. I did this with Ubuntu’s own recovery mode, a rescue disk would also work. I did these without networking, then rebooted for networking.

  • setfont Uni1-VGA32x16 to make the font readable in the Proxmox graphical console
  • Remove fstab entries for other physical disks. (Note this can prevent your system from booting if you don’t, in which case you need a rescue shell.) In the new setup I’m going to mount those disks in the Proxmox server and then NFS mount them in to the Ubuntu guest.
  • Edit /etc/netplan configs to use DHCP (for now). Also the new VM ethernet device is named ens18.
  • Disable Syncthing in the guest VM. The Syncthing data is no longer mounted and I was scared it’d propagate a “delete all files!” message. I’ll need to get this set up again eventually, ideally as a new Proxmox container just for Syncthing.
  • Disable all my cron jobs for things like blog updates, backups, etc. Again these need to be set up eventually or migrated to special purpose containers.
  • Eventually I should install the qemu-guest-agent and enable it in the Proxmox config so everything plays nice together.

Update on Path 1

I redid this whole process for the real server and ran in to some new problems.

The graphical console was giving me trouble. As noted above, there’s some bug in the default graphics hardware where the Ubuntu boot has a corrupted display for the first couple of seconds. That was hiding an error message, so I switched to “VMWare Compatible” graphics hardware. That looked fine but then my main Ubuntu system wouldn’t boot, displaying an error “hardware has no pitchlock” which froze everything in the Ubuntu boot sequence after about 0.6 seconds. Note this error was only findable in journalctl, it had long since scrolled off the screen. Switching back to “Default” display console the system boots. I should learn about SPICE and serial consoles.

The underlying error I was trying to find in the console is my restored virtual disk wasn’t mounting cleanly. There was a complaint about the GPT tables. I’m very grateful I went through the partition shrinking exercise because I sort of understood this; somehow the virtual disk changed size just a bit (a few megabytes?) from the physical disk, which breaks the secondary GPT table at the end of the disk. Fixing this isn’t too hard, this time I did it just by running fdisk and then issuing the w command with no changes. That rewrites the partition table and all seems well. gdisk is another option for fixing it, and maybe parted could. All this is very spooky. I can’t think why it failed the second time. I did resize the btrfs partition to 200GB before taking the new QCOW2 snapshot. But that shouldn’t change the full disk size and certainly not by just a few MB.

Path 2: tar clone of the root filesystem

Disk images are unwieldy; why not just clone the Linux root filesystem with tar or rsync or cpio? In theory this should work just like it would have in 1975. In practice it’s tricky because EFI booting and GRUB are such a mystery.

I found a nice blog post laying out how it should work. Basically you use tar on the whole system to create a snapshot (ideally when it’s offline). Then make a new disk with a bootable EFI partition and a root partition. Unpack the tar into the root partition, then ✨ just use grub-install ✨ to magically populate the EFI partition.

The GRUB step is the confusing bit. The guide above recommends using a chroot to run grub-install as if your old system were live. That’s what ended up working for me. (SystemRescue has its own idea for repairing GRUB. I couldn’t make either method work and it looks like the docs there may be several years out of date.)

Here’s the steps I followed.

Clone the old machine

  • Boot the system with the server to a rescue shell so the filesystem is not live.
  • Mount the rescue filesystem somewhere out of the way like /tmp/source
  • Tar the entire filesystem to an archive on an external USB drive. IIRC this is really as easy as cd /tmp/source; tar caf /mnt/usb/disc.tar.zst --one-file-system . The /dev/ files are harmless, tar is smart about those. Because the disk is not being used live there’s no need to exclude sys, proc, etc, even the one-file-system is probably redundant (but harmless).

At this point you have a clean tar archive of your server. It’s a nice backup!

Create the new VM and get it ready

  • Create the VM. I used systemrescue as the ISO for the boot media, then configured an empty disc for my new virtual server. See notes from Path 1 about OVMF BIOS, disk cache policy, and “host” CPU type.
  • On the Proxmox server command line set it up so the USB device containing your root filesystem tar file is passed through to the new VM. (There’s no doubt other ways to get the data into the VM.)
  • Boot the VM. In the OVMF bios menu, disable Secure boot in OVMF bios. Shouldn’t be necessary but it was the only way I could get the system rescue ISO to boot.
  • Boot system rescue and get to a Linux shell
  • Use parted to set up the new virtual disc. It starts completely empty.
    • Label the disk as GPT partition
    • Create one EFI system partition of 1GB. (See here).
      mkpart p fat32 0% 1GiB
      set 1 esp on
    • Create a BTRFS partition for the rest of the disc
      mkpart p btrfs 1GiB 100%
    • Create filesystems on the partitions
      mkfs.fat -F 32 /dev/sda1
      mkfs.btrfs /dev/sda2

Now you have an empty Proxmox VM all ready to go to have your filesystem transplanted into it.

Copy the filesystem in

  • While still in the rescue shell, mount the guest VM’s disc (/dev/sda2 in above) to somewhere like /tmp/dest and mount the USB source with the tarball.
  • Use tar to unpack the entire root filesystem from the USB disc. cd /tmp/dest; tar -xaf disc.tar.zst should do it.

At this point your VM’s disc has a clone of the server, from the tar file. All we have to do is get it to boot! In theory you can do this from a rescue disk right away, but let’s go ahead and install a proper boot system. But first...

Fix the block IDs

First it’s necessary to fix a few files in your new virtualized server’s root partition. The problem is the block IDs of your filesystems have changed and anything that refers to them by ID has to be updated.

  • Boot a rescue disk and mount the root filesystem to /tmp/dest
  • use blkid to identify the new blockids of the newly prepared filesystems.
  • edit /tmp/dest/etc/fstab to refer to these new block IDs. (or just use the /dev/sda names for now.)
  • edit /tmp/dest/etc/grub to include a line naming the block ID for the new filesystem.

Make the VM disk bootable

The last part is to let grub-install do its thing to set up the boot partition.

  • Boot the rescue disk and mount /tmp/dest
  • Prepare bind-mounts into /tmp/dest per step 7 of the guide.
  • chroot /tmp/dest and get a new shell in the Upside Down
  • Mount the boot partition: mount /dev/sda1 /boot/efi
  • Cast a magic spell for the ✨ EFI variables ✨
    mount -t efivarfs none /sys/firmware/efi/efivars
  • Run update-grub to pick up the new block ID you configured in /etc/grub
  • Run grub-install /dev/sda to install the EFI partition needed to boot
  • Exit the chroot shell and shut down the VM
  • In the Proxmox VM config, remove the SystemRescue ISO and the USB
  • Edit the VM options to include your new boot device
  • Boot!

This all actually worked and I had a working system. The downside is you have to make new partitions, new filesystems, and then install grub in a very weird way. The changed block IDs complicate things too. Overall this was much more complex than just making a disk image clone with QEMU or Clonezilla. But conceptually it might be “better”. I’m glad I learned how to do this but it’s not going to be my preferred method.

Path 3: restore from Proxmox backup

This is cheating, it’s not cloning a physical system. But just for comparison I tried using the Proxmox GUI to back up a working VM of my server to a USB disc and then restore it. It was very easy! This is the reward at the end of the tunnel. Next time I upgrade hardware I won’t have to reinstall anything other than Proxmox. Then I can just backup and restore VMs and containers. Or migrate them live in a cluster, maybe.

The backup of the ~80GB of actual disk data (160GB disk) was fairly quick (10 minutes?) and created a 56GB .vma.zst file. The restore took 20 minutes and took up 62GB of data on a ZFS volume.

Everything static was restored but the system had to be rebooted. Proxmox does support live system migration but that’s not what the backup does.

Thoughts

So that’s it, I now have tried four ways of migrating a working Linux server to new hardware. I’ve made all this sound very complicated. Honestly, it was complicated while I was figuring it out. I imagine half the readers are rolling their eyes saying “duh” and the other half are saying “wut?”. I’m not quite at the “duh” stage but I’m glad I’ve gotten past “wut?”. In particular I’m much more comfortable with manipulating Proxmox VMs, adding and editing hardware and disks and the like. And maybe GRUB is a little less of a mystery to me.

It’s remarkable how resilient a Linux install is to the hardware it’s running on. Virtualizing like this means changing every single hardware device, replacing them with virtual ones. Discs are entirely different. And yet everything still mostly works; putting in the new name for the network adapter was the only manual change required.

Shrinking a VM disk image: loss and recovery

A small experiment. I have a 2TB physical disk (SSD) with about 80GB of real data on it. I want to shrink that 2TB to a virtual disk that’s 150GB; 80GB of data and 70GB of free space. The disc has two GPT partitions, almost all of the space allocated to the second partition. That partition is formatted with BTRFS.

I managed to do this but it was kinda scary all the way, particularly the part where I broke everything and lost all my disk partitions. I did recover it in the end but I do not recommend the experience. I was playing around on a test VM so it wasn’t a catastrophe, but if this were a precious system I would have been very unhappy.

To cut to the chase: resizing the filesystem and the partition were easy. But shrinking the virtual disk with qemu-img caused big problems. The underlying problem is that GPT has two copies of the paritition table: a primary at the start of the disk and a secondary at the end. Changing the disk size screws up the secondary and Linux gets angry and won’t recognize the partitions. You can repair the GPT partition table manually with gdisk but it’s scary. This may not be an issue with old fashioned MBR partitions.

Battle plan

The simple way to do start is gparted’s GUI; it will resize a btrfs filesystem and partition for you. But I’m stubborn and using command line tools. The plan is roughly:

  1. Clone the physical disc to a QCOW2 image
  2. Clone the QCOW2 image with qm import disk to whatever raw format Proxmox wants.
  3. Build a VM around that Proxmox clone.
  4. Boot the VM
  5. Use btrfs filesystem resize to resize the filesystem inside the live VM.
  6. Use parted on the disk to shrink the partition for the filesystem we resized.
  7. Reboot and test it’s basically working but the partition is now really smaller
  8. Shut down and use qm resize on Proxmox to make the disc smaller. This is the part that broke.
  9. Repair the damage with gdisk
  10. Reboot and you’re done!

The first few steps are documented in other blog posts and are about moving a physical disc to a VM. The rest of this post is about resizing a Proxmox VM disk in QEMU raw format.

btrfs filesystem resize

The goal here is to make btrfs think the partition is smaller than it used to be, moving all the data to the front of it so you can then lop off the rest of the partition. It’s pretty straightforward and can (must) be done on a mounted disk.

# time btrfs filesystem resize 150G /

Resize device id 1 (/dev/vda2) from 1.82TiB to 150.00GiB
real 0m21.361s
# btrfs filesystem show /
Total devices 1 FS bytes used 72.25GiB
devid 1 size 150.00GiB used 95.02GiB path /dev/vda2
# df -h /
/dev/vda2 150G 74G 75G 50% /

The filesystem resize was quick and easy! As far as everything is concerned the filesystem is now 150GB big, not 2TB. However the partition is still 2TB.

Parted

Now I want to repartition the disk so nothing is using space beyond 150GB. I’m using parted to edit the partition table on the live disk, the one that is running the OS I’m running parted from. That’s not a good idea, it’d be safer to boot from rescue media. But I’m feeling spicy and this is a test VM.

It’s very important to separate “GB” (1,000,000,000 bytes) from “GiB” (1,073,741,824 bytes). btrfs filesystem is explicit about talking in GiB. parted understands both but seems to prefer the base 10 smaller numbers. You can change that with unit GiB in parted.

unit GiB print
Number Start End Size File system Name Flags
1 0.00GiB 1.05GiB 1.05GiB fat32 boot, esp
2 1.05GiB 1863GiB 1862GiB btrfs

(parted) resizepart 2 155GiB
Warning: Partition /dev/vda2 is being used. Are you sure you want to continue?
Yes/No? y
Warning: Shrinking a partition can cause data loss, are you sure you want to continue?
Yes/No? y

(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 1863GiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 0.00GiB 1.05GiB 1.05GiB fat32 boot, esp
2 1.05GiB 155GiB 154GiB btrfs

Note I chickened out and made the new partition 154 GiB, a few GiB bigger than the filesystem. I don’t trust my math. The correct number for the end of the partition would be 1.05GiB + 150GiB. (But oh god does parted round down by a few bytes?)

I rebooted and verified everything worked. I now have a 2TB disk with only 155GiB of partitions on it.

Resizing the QEMU virtual disc

This is the part where I broke things. I wanted to make the actual VM disk smaller, to shrink it from 2TB to 150GiB (or a bit bigger)

Proxmox explicitly does not allow shrinking a desk with the GUI or qm command line tool. The docs just say “that’s dangerous and we won’t help you”.

However it’s still possible to do it with command line tools. I did this with qemu-img on a raw image. That linked page talks about LVM as well. Note that both qm and qemu-img seem to work in binary sizes. Ie: 1G is 1GiB, 1,073,741,824 bytes. I sure hope this is consistent everywhere since it’s not explicit.

First, I shut down the VM. I did some experiments on a scratch monkey while the VM was still up and bad things happened. The file size of the .raw changed on the Proxmox host, but even after rebooting the size looked like the old size inside the VM. It must only work to resize a disk if the VM is offline.

# ls -l disk.raw
-rw-r----- 1 root root 2000398934016 Dec 30 18:49 disk.raw

# qemu-img resize --shrink -f raw disk.raw 156G
Image resized.

# ls -l disk.raw
-rw-r----- 1 root root 167503724544 Dec 30 19:18 disk.raw

# qm rescan
# rescan volumes...
VM 100 (virtio0): size of disk 'local-btrfs:100/vm-100-disk-1.raw' updated from 1953514584K to 156G

Looks like it worked! Note the qm rescan is necessary.

But then disaster. Reboot failed. Getting to a rescue disk , blkid didn’t show any of my partitions. fdisk and parted on /dev/vda showed scary errors like “GPT PMBR size mismatch (3907029167 != 327155711) will be corrected by write.”

I was able to correct things somewhat by using qemu-img resize again to grow the disk back to 2TB, its original size (to the exact byte). Even then nothing was working. But now parted and fdisk reported “The backup GPT table is corrupt, but the primary appears OK so that will be used.” I used gdisk (a new-to-me program) to interactively repair things. It used the primary GPT table for the info and rewrote everything. And it worked! But this was all super scary. And I’m back to a 2TB disk.

I have a theory for what went wrong here. Apparently GPT writes two copies of the partition table; a primary at the front of the disk and a secondary at the back. When I shrunk the disk the second copy was removed, then when I made the disk bigger again it was “back” but now zeros instead of data. And so there was a minor complaint with the secondary and gdisk could work around it. Not a big deal to recover from but spooky.

But I really wanted the disk smaller. So I resized it again, booted to rescue, and used gdisk. And ran the v command. Look at all these errors!

Not only is it unhappy about the secondary partition table being wrong but also it is aware that the disk used to be bigger and stuff is inconsistent.

I used the suggested e command (or was it r?) as suggested. That basically says “trust the primary” and generate a new partition table. Then w to write the change. That all worked fine; both gdisk and parted no longer reported errors. Is it done?

Reader, the system rebooted with no problems. Ubuntu was saved!

Ideas for doing this more safely.

gdisk has options to back up GPT partition data to a file and restore it. I’d definitely use that before monkeying around with any of this.

I would use the gparted GUI tool for most of the work. It handles both the btrfs resize and the repartitioning. It’s not going to anticipate the GPT partition weirdness of a qemu-img shrunk disk, but maybe it has nice tools for recovering from the mess too.

Phone migration: what I think should happen

Lots of responses to my rant about the bad experience of getting a new Android phone. A real mix. Some folks saying “worked for me!”. Some folks saying “I had those same issues but they didn’t bother me”. Not so many people just saying “I feel your pain, it should be better” but then my post was ranty enough that I expected aggressive responses.

Here’s what I would like for a phone migration experience.

Requirements

Every app should transfer all settings and data. Every preference and config. All data, including cached data you could download over the Internet again. The migration process should be more comprehensive than restoring from a cloud backup; the data is already available locally. (I’ve seen hints that Android does better with a USB wired migration vs. wireless. The Pixel 8 never prompted me to plug in a cable so I didn’t try it.)

Every single app should be aware I migrated. Most apps probably shouldn’t care but some may need to respond to a migration event so the product needs to adapt to the new hardware somehow.

Low stakes apps like Spotify should keep me logged in. The migration was a secure process, my login tokens should transfer too.

High stakes apps like banking or a password store might choose to reauthenticate me after migration, for extra security. But the app on the new phone should already know who I am, already have my username pre-filled. Apps that require two factors for login on a new install should only require one of those factors on a migrated phone.

Some apps require you do something on the old phone to migrate, like de-register it. Those apps need to treat that requirement as a serious thing requiring explicit user action. Notify me during the migration if I need to do something on the old phone. “Hey, you need to do something special for this product”. As it stands now for some apps (Volvo, WhatsApp, Battle.net, ...) you only notice you have to do something on your old phone when you get around to launching it on the new phone. That may be several days later, after you’ve already wiped and sold your own phone. That’s not acceptable. (I literally spent a couple of hours launching every single app to make sure it worked. Don’t make me do that. I’m still scared to wipe and sell the old phone.)

Google needs to work with cell providers to migrate cell service better. This used to be great on iOS, not sure if it still is. All Android says is “lol contact your cell provider”. Maybe the Google Fi version is nicer?

Google should respect my ad privacy settings on migration. As it stands now Android uses a migration as an opportunity to trick you in to agreeing to being tracked.

I’m on the fence whether Android should copy over app permissions. It doesn’t seem to, at least for location, file access, and biometrics. OTOH a migration is a chance to fight the proliferation of promiscuous permissions. That e-commerce app really doesn’t need my precise location.

Commentary

A lot of people responded “it’s an inconvenient experience because of security”. Sure, security-vs-usability tradeoffs are often tricky. But make the tradeoff explicitly, on purpose! Not just this lazy mess. And for security, wouldn’t it be better if the product recognized that it’s not a new install, but rather a secure transfer from an old install? A migration is a different, lower risk. Most of the apps I used don’t do anything that nice, they just reset me back to zero. I suspect they do this because it’s easy and they trust that process is relatively secure rather than building a special migration experience. They didn’t put any product effort into the tradeoff during migration, they just made it inconvenient.

Many of my requirements are predicated on the assumption that the migration itself is a secure process. That no hacker can produce an unauthorized clone of my phone and use that to access my bank account. I am pretty sure Google designs for secure migration and trusts it. But I can understand why my bank might not trust Android. So fine, require I log in again if the stakes are high. But at least design that process nicely. The bare minimum is not making me type my username again.

Secure hardware enclaves complicate migration: it may not be possible to move some data. I don’t know Android well enough to know how prevalent that is. I don’t think it explains most of the problems I saw.

Both 1Password and Aegis did a good job on migration. These are some of the most sensitive apps I own; both migrated my data in a way that I trust is secure. They did require me to reauthenticate but that process was simple. Both already had my data and knew who I was. This proves that secure convenient migration is possible on Android. My guess is their product teams put a lot of effort into making migration work well, it’s a primary feature for both.

Several simpler apps also migrated well. (Yay Paprika!) And Google’s apps also mostly did a good job on migration. Not exactly a surprise, they control the whole platform. Also they have a very clear authentication and account model, most of their apps just trust the system’s Google login. I logged in once to Google during the setup process and then my Gmail, etc was already available. Wallet and GPay were exceptions, both had problems.

Special shout-out to the Wikipedia app which kept all my tabs during the transition. That was a nice surprise!

Migrating to a new Android phone sucks

I upgraded my Pixel 6 Pro to a Pixel 8. I just spent some five hours getting the new phone working the way the old one did. It was a terrible experience. Getting a new phone isn’t a delight, it’s an awful chore to be avoided. Every product manager and engineer involved in this mess should feel bad. FWIW it was bad two years ago when I did this last time, too. My impression is the iOS migration experience is much better. (Update: mixed opinions about iOS on the Fediverse.)

Update: see this followup.

(Content warning: this note is a bit ranty. I felt it was important to capture the emotional experience.)

Broadly speaking, the problems fall into several categories:

  1. Data not copied over to the new phone
  2. Random app settings not being configured
  3. Having to log in to every app
  4. Security critical stuff
  5. Getting the cellular contract to work
  6. Google being sleazy with surveillance

I think the underlying problem is the Android platform must not specify how migration is supposed to work well enough that every app gets it right. No one owns the whole migration product: it’s partly Google/Android’s responsibility, partly the phone manufacturer’s (Google in my case), partly the carrier, and partly the apps’.

Also I can imagine each app / product owner not thinking it’s a big deal. “Migration only happens every two years, no need to worry about it”. I bet these products lose 5–10% of their customers every two years. Also the problem is much worse for the individual because they have to manage 100+ app migrations all on the same day.

It’s not like it’s not possible for migrating to a new phone to work. Some things even do work in Android. The little mom & pop Paprika app migrated perfectly. All my recipes on the new phone, still logged in. So did Libby, the public library book borrowing platform. But many other well funded apps sucked. High stakes things like my banks or Uber, but also low stakes things like my Spotify account. My suspicion is the product people for most of these apps just don’t care enough to make it work.

Details

Do I have detailed notes? You bet I do!

Data not copied over to the new phone

Android has a fancy migration tool for new phones. It’s pretty slick! Wireless, auto-discovery, relatively quick considering what it’s doing. And it does successfully copy a lot of data over. But not everything. For instance all of my music files copied over. But the 3GB of map databases Organic Maps had? Have to download those again. Also the 80GB of Wikipedia database from Kiwix. I suspect there’s a deliberate decision here not to copy this data since it can be downloaded again. It may be tied to the set of data that’s backed up. But re-downloading 80GB over the Internet is a big burden and the data is right there for the copying.

Google Wallet kept my credit card, the most sensitive item it had. But it lost my Clipper transit card. Also lost my Covid vaccination record (again). Maybe no one on the Google Wallet team cares enough to make sure the user’s cards in their wallet transfer over. Just empty the wallet into a fire and start over.

Random app settings not being configured

A whole lot of apps had to be reconfigured. A few apps copied their configs over entirely, worked great. Most didn’t even try, I started new. A few special apps copied some settings but not all. A whole lot of apps treated me to a New User experience, some condescending 8 page onboarding slideshow like I’d never used the product before. (Including, bafflingly, a few that had copied my configs.)

A related detail: all my system settings for app permissions had to be re-enabled. I had to manually tell the phone, again, to allow the maps app to know my location and the file manager app to access my files. I think my notifications preferences were kept though.

The notes from the Niagara Launcher app are possibly instructive here. “We’re currently using Google’s Backup implementation, which is not 100% reliable...” In my case I had to fully reconfigure Niagara. There’s a feature request for Niagara to implement its own settings export / migration tool. Some of the apps I use have those but I didn’t use any of them because the process of juggling the settings file was too tricky. It should just sync to the Google Cloud Backup Drive Panopticon, why does this not work for every app consistently?

Having to log in to every app

A huge PITA is that most apps are basically just wrappers around a website. And almost all of them demanded I log in again. I suppose they think this is “for security reasons” but for 90% of the apps there’s very little risk. It doesn’t help that the login process is a PITA. I use 1Password for logins and for about half the apps it works very well, I just tap a button in the keyboard and it fills. The other half? I have to cut and paste across two apps. Or the new trend, the app doesn’t even let you use a password but insists on sending an SMS message with a login code. Which cuts 1Password out of the loop entirely.

Security critical stuff

A few apps have special security needs, I expected them to be awkward to migrate. Except: they aren’t! Both 1Password and Aegis (my 2FA store) worked great. I think I had to type a password into each one once on the new phone. All data, login tokens, etc transferred. Because they care to get it right.

By contrast the various bank apps and other things with material consequences to security all sucked. In all cases it was basically like I was installing a new app for the first time on a new device, no aspect of the transfer worked at all. Only because these are security conscious products the new app setup process is always onerous.

And then there are the special apps that insist I do something on my old phone to deregister it before it will let the new phone work. The geniuses at Volvo managed to build a car where if you lose your phone or uninstall the app you have to factory reset the entire car software in order to connect a different phone to it. Fortunately I have the old phone and could unpair it but I still haven’t paired the new phone because I have to have both physical car keys with me to pair a new phone. The Android migration tool did nothing to help me here.

I was going to check what happened to my Passkeys but hahaha I have no Passkeys because that technology rollout is going very poorly.

Getting the cellular contract to work

Another special case I have a little sympathy for: migrating cell service is tricky. And very security important, given how every app treats SMS to your phone number as a primary means of identification. I give Verizon credit here, the transfer process was actually pretty good. eSIMs should make this simpler but in practice make it more complicated since there’s no physical object to move your identity on. But it still worked mostly fine, although Verizon’s website and docs are wildly inconsistent on what you need to do to migrate. (The obvious thing worked for me without talking to anyone.)

But Android did nothing at all to help make my phone be a phone. Why not recognize I’m moving a phone with a Verizon contract and help migrate the eSIM service over at the same time?

Google being sleazy with surveillance

A special bonus here. Somehow Google forgot my ad privacy preferences. Google rolled out a whole new ad privacy setting this fall. I immediately opted out of all surveillance on my phone and my Google Account. But despite migrating a Google Account opted out on a phone opted out, the new phone demanded I set my ad preferences up again. Defaulted to full tracking. Twice: once for Chrome and once for the phone device itself.

Of course Google knows exactly what they’re doing, it’s not a bug. They want desperately to track users but they need to maintain the fig leaf that we somehow consented to the tracking. So the phone transfer doesn’t transfer the privacy settings and resets me to full tracking. But this game they’re playing undermines their goal. They clearly ignored my informed preferences and tried to trick me into undoing them. That’s not informed consent, that’s fraud. I know to pay close attention for this garbage but most users won’t follow it.

Conclusion

Phew, feel better getting that rant out. But seriously, the experience of migrating one Android phone to another is really bad. It’s a mess of a difficult problem, complicated tech that apparently doesn’t work right, and a product conundrum that no one cares enough about to fix.

xxhash notes

Following up on a post 7 years ago, there now seems to be a consensus for a hash / checksum algorithm that’s not cryptographic. xxhash. Some variants are literally faster than memcpy, which is quite a trick. (I assume it’s the SIMD instructions).

xxhash has a bunch of implementations, I’m using the Ubuntu version. It comes in four flavors: 32, 64, 128 bit, and an alternative 64 bit (H3) that’s the fastest. Oddly the 128 version is the fastest of the first three, then the 64 bit.

This reimplementation blog post has some details on the algorithm. The speed comes from a parallel design meant for SIMD calculation. The actual checksumming boils down to rotate(state + (data * prime2)) * prime1. I’m a little surprised it’s a multiply and not a shift and xor or something but I know nothing about modern CPU speed.

I did a very simplistic benchmark: time dd if=/dev/zero bs=1024k count=1024 | xxhsum -H3 and took the best time of several runs.

  • no hash (send to /dev/null): 30ms
  • H0: 245ms
  • H1: 222ms
  • H2: 224ms
  • H3: 224ms
  • md5sum: 1250ms

Safe to say xxhash in any of its forms is so fast that I/O speeds and overhead dominate the CPU for the calculation. No wonder people embed this thing in filesystems, etc. It has very little cost.

My own archive of tweets

I put my own Twitter archive online, hosted here with individual tweet URLs like here. The “server” is all static HTML but the list of tweets is an infinite scroll thing. Oct 2006 to Nov 2022.

I made this with Julia Evans setup, itself based on Darius Kazemi’s tool. Darius’ program generates its own HTML view but it’s got an idiosyncratic presentation. Julia’s code takes the tweet data (from searchDocuments.js) and the media files and constructs a new HTML archive borrowed broadly from Nitter’s UI. The Vue-based infinite scrolling wouldn’t be my first choice for an archive but it works fine and only took a half hour to set up. The main thing I miss is thread nesting.

I mostly just followed Julia’s instructions, getting something basically working is very easy. The scripts aren’t a polished product but if you are comfortable hacking a little code it’s not hard to get working. I’m glad she shared them! Some details:

Here are the specific edits to the code to customize my archive:

  • app.js: Replace two instances of b0rk with nelson
  • index.html: Replace four instances of “julia” or her full name with mine. Replace two instances of “b0rk” with “nelson”.
  • build.py: 5 instances of “b0rk” for “nelson”. 4 instances of “julia” for “Nelson”. (this page includes HTML similar to index.html).
  • profile.jpg: replaced with my own image

Deployed by rsyncing the entire github package, Julia’s scripts write stuff in that directory. Then on the web server I deleted things that weren’t necessary for the static HTML: .git, scripts,

The other thing I did was write a script to filter my tweets by date. I decided to cut off the archive at Nov 3 2022, the stuff I posted afterwards is all not something I care to preserve, just bearing witness to Elon Musk’s destruction of the company and product.

#!/usr/bin/python

import json, pytz
from datetime import datetime

cutoff_dt = datetime(2022, 11, 4, tzinfo=pytz.UTC)

def cutoff(item):
	created_at = item["created_at"]
	dt = datetime.strptime(created_at, "%a %b %d %H:%M:%S %z %Y")
	# print(dt, dt >= cutoff_dt, cutoff_dt)
	if dt >= cutoff_dt:
		return True
	else:
		return False

jsonp_header = 'const searchDocuments = '
data = open("searchDocuments.orig").read()
data = data[len(jsonp_header):]

tweets = json.loads(data)

filtered = tuple(t for t in tweets if not cutoff(t))

print(f'{len(tweets)} tweets in archive, {len(filtered)} passed filter')
with open('searchDocuments.js', 'w') as fp:
	fp.write(jsonp_header)
	json.dump(filtered, fp, separators=(',', ':'))

Proxmox: sharing files to container with snapshots

I finally figured out how to mount a directory in a container without making Proxmox refuse to do snapshots. The trick is to use lxc.mount.entry instead of a bindmount. Thanks to this Reddit hint. In detail...

I have a USB disc mounted on the Proxmox host as /mnt/usb-media. I want to share it to a container running a media server. When you look online for how to do this you quickly find that bindmounts are the way to do this. Basically it says “take this directory in the host and make it available to the guest”. This is the config in /etc/pve/nodes/pve/lxc/110.conf I was using:

mp0: /mnt/usb-media,mp=/mnt/usb-media

This works fine but has the side effect of Proxmox refusing to take a container snapshot. There’s an error in the GUI console saying “The current guest configuration does not support taking new snapshots”. I don’t know quite why that’s a problem, maybe it is concerned it can’t snapshot the contents of the mounted files? I’d be fine skipping those!

Anyway, the solution is a different config line:

lxc.mount.entry: /mnt/usb-media mnt/usb-media none bind,create=dir 0 0

This makes the files available, just like the bindmount did, but Proxmox will still take snapshots. The snapshots still seem to work. I didn’t test what they did with files on the mounted directory. In this particular application I should probably mark the mount read only...

The format is documented in the LXC man page but all it says it’s like an fstab entry. Note it’s very important that the third word, the destination directory, has no leading slash. It’s a relative path, relative to /, mnt/usb-media in this case. If you make it an absolute path there will be no error message but nothing is visibly mounted.

Proxmox’ docs are really not very helpful here. I have no idea what all a bindmount might do or how it’s more than the plain LXC entry. Someone else suggested trying to add replicate=0 to the bindmount options to make snapshots work. That didn’t work for me.

Anyway, I can play my mp3s and still snapshot the container, so mission accomplished.

Proxmox Linux container sizes (Alpine etc)

Continuing my Proxmox explorations, I’m looking for the smallest reasonable Linux container I can install to then do other things with. My starting point is Proxmox templates. Easiest to install with Proxmox tools but you can see the image sizes at the downloads here.

I’m mostly comparing the sizes of “df /”. That may not be a good measure. But for me it’s not just a measure of disk space, it’s also a proxy for memory usage and complexity. Of course I’m comparing systems without GUIs.

Alpine 3.18: 10MB

The gold standard for small Linux, really a lovely thing in just 10 MB. Hilariously almost half the storage (4MB) is in /lib/libcrypto.so.3, OpenSSL. I guess no one’s made a svelte SSL. Alpine gets to be so small by using libmusl instead of libc and replacing most of the userspace tools with busybox. The init is the very simple OpenRC. Despite that it has a huge number of packages you can easily install on top of it.

The downside is those replacements are very limited. The user space shell environment is enough to install something but can be frustrating. MUSL is also limited, see this post as an example of an obscure performance problem. It’s not bad, really it’s an impressive accomplishment, but it’d be nice to have an option that was both small and yet GNU libc based.

Debian 12: 540MB

Debian seems to be the default for a lot of Proxmox applications, but it’s half a gig on disk. From what I’ve read this is fairly pared down. Still it’s hard to quite understand where all the space is going. Some of it is just general system size. 136MB is shared libraries. 20MB for Perl, another 30MB for Python. Some of it seems superfluous: 50MB is locales (all of them?), 60 MB for the dpkg database, etc. It adds up.

One thing that’s encouraging is the Debian images keep getting smaller. Debian 12 is half the size of Debian 10!

Ubuntu: 640MB

No surprise, Ubuntu is bigger than Debian. More or less the same shape of things but just a little more of it.

Centos 9: 436MB

Not a fan of RedHat OSes but it’s a reasonable choice. Smaller than Debian but with similar sources of size. The locale library is 74MB! Also a 65MB GeoIP database that I bet isn’t necessary.

OpenSUSE 15.5: 178MB

I’d forgotten about OpenSUSE, to be honest, and am not sure whether it’s a good choice in 2023. It’s nicely small though! The bulk of it is binaries in /usr/lib64/ and /usr/bin. It’s still systemd and GNU libc. But there’s locale library at all, no python by default.. It meets the critera for “smaller”. Might be worth investigating what tradeoffs it implies.

Gentoo: 1800MB

Another distro I’d forgotten about, I picked this because in theory it supports musl. But not this template. And whoever built this was clearly not worried about size, it’s huge! There’s copies of package repos, SGML docbook, a 100MB test suite for Python, ... clearly no one spent time optimizing size here.

Other options

I should look beyond Proxmox templates. There’s a lot of other folks who’ve been working on the “smaller Linux for containers and VMs” idea. I should learn more about them. Docker’s got a bunch of them, in particular I keep seeing references to a “Debian Slim” that sounds promising. Docker’s overlay filesystem takes some of the sting out of bigger containers though, since the base OS storage can be shared.

Conclusions

I guess my ideal would be something with GNU libc but without systemd and without extra locales and binaries I don’t need. Ideally neither Perl nor Python required. Maybe what I want is “Alpine but with glibc and bash”. I’m willing to trade off some space for quality. I wonder if it’s realistic to be able to use pre-built Alpine MUSL packages for some things and glibc for others?

I’m probably overoptimizing. 540MB for Debian is probably what I should be using when Alpine won’t work, or maybe that 178MB OpenSUSE.

LXC by hand

Some rough notes on setting up LXC on a generic Ubuntu system with the command line tools. No Proxmox. I mostly followed this guide and made it difficult for myself by setting up an unprivileged container. This is easier if you’re root.

  1. sudo apt install lxc
  2. Follow the instructions in “Basic unprivileged usage” that have you creating a ~/.config/lxc/default.conf and as root adding permissions for networking to /etc/lxc/lxc-usernet.
  3. Run lxc-update-config -c ~/.config/lxc/default.conf
    This is not mentioned in the Ubuntu docs but seems necessary, I found it in a comment here.
  4. Create a container: lxc-create -t download -n u1 -h
  5. Configure it interactively (I couldn’t figure out command line switches). The list of containers is here. I chose alpine, 3.18, arm64.
  6. Start it: lxc-start -n u1
  7. Connect to it: lxc-attach -n u1

On the container:

  1. Verify networking works: ping 8.8.8.8 (note that “ping” can be fraught but it worked for me.) ip a shows me a 10.* address, not my usual LAN subnet. I guess some routing is involved?
  2. Verify you have process isolation: ps -axu. It’s a list of a few root processes just for the Alpine container, nothing for the host.

On the host:

  1. Verify user ID mapping: ps -axu | grep /sbin/init. I have some processes with a new user 100000.
  2. Learn some things about the container:
    lxc-info -n u1
  3. Check the container’s files in $HOME/local/share/lxc

I’m having a hard time getting any system stats about the containers. lxc-top reports nonsense, free inside the container shows the host system stats (yes, lxcfs is installed in the host), lxc-info does not show memory usage despite all the docs saying it should.

One thing I notice is all the help pages I find online in my searches are ~2014 era. I suspect most people have moved on from LXC to LXD or Docker or whatever. I’m only tinkering with LXC because that’s what Proxmox uses. But then they’ve built their own pct tool for managing things.

Proxmox what I installed

Following on my general post about Proxmox here’s a list of specific things I installed on my new home LAN server. As always this blog is mostly written for my own notes, but maybe other folks will find it interesting where I ended up.

Proxmox hypervisor

In general the idea is to customize the Proxmox host itself as little as possible, all my stuff should be going in guest operating systems. But Proxmox itself is a full Debian system with super cow powers and you can install other stuff. I kept it to a minimum just for administering the hypervisor:

  • apt install stress-tui stress-ng lm-sensors hwinfo joe sudo
  • Tailscale so I can access the management GUI from anywhere
  • The user “nelson” with my usual environment. Not really necessary.

I hand-mounted a USB disk of my media files by editing /etc/fstab. Proxmox seems to have no tool for managing USB disks. It doesn’t even automount them although I bet there’s some Debian thing you can install for that. As always be sure to use nofail in the fstab so it’ll boot without the disk.

I also wrote a script that uses pct list and pct exec to run a command in each container to print out their IP address. It’s kinda hard to find all your guest images in Proxmox’ UI if you’re using DHCP to assign addresses. (I wonder if there’s a way to get Proxmox to manage DHCP for its guests. Part of me wants a separate subnet for all the Proxmox hosted stuff.)

Ubuntu VM: old server clone (240GB, only 30GB used.)

My old server is virtualized now, see this blog post. I plan to migrate everything out of here and shut it down eventually but it’s real nice to not have to do that all at once.

Hacking container: Ubuntu template (1.4GB)

I have one container that’s just for general hacking projects. I suspect I’ll rebuild this from time to time other than preserving my home directory. I used the Proxmox Ubuntu template to make it, making sure to turn DHCP on. It’s unprivileged (which breaks ping). Here’s some stuff I did after install:

  • locale-gen en_US.UTF-8
  • apt install joe avahi-daemon git zip unzip rsync openssl webp ripgrep pigz python3 python-is-python3 python3-venv python3-dev pkg-config build-essential sqlite3 keychain curl
  • tailscale: have to enable tun access in Proxmox to make this work
  • My usual home directory environment.

Plex container: tteck (4.6GB)

I installed the Plex media server using tteck’s Proxmox helper scripts. These are a set of shell scripts to install a container in an OS and then the apps. Not sure why they don’t just distribute a template instead. I chose Ubuntu 22.04 instead of Debian and then it installed whatever Plex itself needs.

My media files are on the USB drive I mounted on the host OS. I used a bindmount to make the directory available in the container. Note that bindmounts break Proxmox’ snapshot mechanism, but backups still work.

The resulting image works great. Intel QuickSync, the GPU accelerator for transcoding, just worked with no effort on my end. Plex itself is easy to set up. I configured Plex to not run scans, intro detection, etc every night so it wouldn’t use all that CPU and disk I/O. But those jobs work fine.

4.6GB seems huge. over half of that is in Plex cache directories that were generated after it started running. I only gave this container 8GB, I wonder if it’ll run itself out.

Unifi container: tteck (2.1GB)

The Ubiquiti device management controller. Another tteck script, with Debian 12 this time. Also installed Tailscale myself. Ubiquiti’s system requires you migrate devices from an old controller to a new one which is fairly simple, basically making a backup of the config and copying it over. The actual migration process is a little scary, if it goes badly you might have to hard reset your devices.

Samba container: Alpine template (0.07GB)

A network fileserver for my music files, for Sonos. I did this one fully manually, starting with the Alpine 3.18 template. it was really easy, basically just apk add smb. I had to bindmount the media drive just like Plex. I wrote a new config file from scratch, smb.conf gets a lot more readable if you remove the hundreds of lines of comments from it. Dimly remembered the special downgrades Sonos requires to work (unix extensions = no).

Docker VM: manually (32GB not all used)

I set up a Debian VM to run Docker and Portainer using these instructions. I wanted to see how Portainer worked but I don’t know that I’ll keep using it. It’s not even running right now.

Monitoring container: TBD

The main thing left in my old server’s VM is a bunch of custom scripts I wrote to log monitoring data. I set this up a couple of year ago with Telegraf + InfluxDB + Grafana and it works well. So well I keep adding monitoring hacks without being careful about it, so now it’s a bit of a hairball.

I think the migration path is to set up Debian or Ubuntu on a new container, then install Telegraf + InfluxDB + Grafana there. Then somehow migrate all my Influx data and Grafana configs over. And all my monitoring scripts in Telegraf. That’ll let me turn off the VM versions of those things without much data loss.

But I’m sorely tempted to also improve things as I move them. Productize the monitoring scripts a bit so next time I move them it’s simpler. And maybe move off of Influx to TimescaleDB (a Postgres extension). That’d be more fun and having the VM working gives me time to do that.

I’m also unclear whether I should set up a separate container for each monitoring process, plus an extra for influx + grafana, and write the data with a network socket. That’s maximal containerization but seems like overkill, I probably won’t bother.

Backups and snapshots

One annoyance: there’s no tool for backing up the Proxmox server itself. Most people say “eh, just reinstall” but it’d sure be nice to have a copy of the configuration. Some folks have hacked things by copying off the config files with a script.

Proxmox does have backup tools for VMs and containers which are basically filesystem copies. I’m not certain how hard they are to restore but the web GUI has a “restore” button so presumably push-button. There’s a nice set of backup options trading off consistency vs disruption. If you stop the guest entirely you can make a cleaner backup but you don’t have to. Backups can be run manually or scheduled.

Proxmox also has “snapshots” which not only capture disk state but also memory. This seems to work great with a VM; I could snapshot, rollback, and my running processes are back in the old state. There’s also snapshots for containers but they don’t work as well. Bindmounts disable them entirely. And the restore of a container is not confidence inspiring; it took 30+ seconds and only restored file state, not memory or running processes. That all makes sense given what a container is, but makes me wonder whether container snapshots are useful.

Note that a backup run in “snapshot” mode is a different thing from a “snapshot”.

Proxmox, first impressions

So I’m setting up a new server and for the first time in my life I’m using containers and VMs instead of just installing a bunch of stuff into one Linux system and hoping for the best. It’s working pretty well so far, wanted to write down what I’ve learned so far. I’m new to all this, not an authority.

These notes are about the Proxmox Virtual Environment, a hypervisor OS you install directly on the bare metal. Its main purpose is to then host LXC Containers and/or KVM virtual machines which are running guest operating systems for your services. It also manages storage and some networking. Proxmox has been around 15 (!) years now.

Overall Proxmox has been a good experience. It hasn’t done anything dumb or frustrating and has some very useful capabilities. I’m glad I’m trying it.

Hypervisor choice

Why Proxmox? I picked it because it’s popular in the home lab / hacker communities and I have friends who use it. I definitely don’t want or need some enterprise-grade Kubernetes solution that’s designed for managing a fleet of hundreds of machines. I’ve got one $200 server, a couple of small disks, and very low requirements. But I do want it to be easy and fun to hack. Proxmox meets that market.

One special thing about Proxmox: it has equal support for full virtual machines and simpler LXC Linux containers. You can mix both with no problems. Of course you could run KVM in any Linux system, and you can also run containers in a VM with Docker or LXD or something. But Proxmox puts both front and center as equally supported options and I like that.

There’s a bunch of other choices for hypervisors or similar setups. I briefly looked at XCP-ng (a fork of XenServer), see this analysis. But it’s a little too new and I think doesn’t directly support containers. I also gave Portainer a quick try, it’s a GUI for Docker containers, but that’s really all it is and it doesn’t quite manage a whole system. Incus does have both VMs and containers, it’s a fork of LXD, but is too new for me. VMware ESXi is popular but proprietary, I wanted open source. There’s also a lot of solutions that are more command line / config file oriented, I was looking for something with a web GUI.

Finding guest systems

One thing that worried me in picking Proxmox was where I’d find images to use for containers. I want to install a Plex server: is it going to be a lot of work manually installing or can I just push a button? I think Docker Hub sets the standard for sharing images and was worried Proxmox’ use of LXC would be a problem.

No problem. Proxmox itself comes with some templates for generic Linux systems like Alpine or Ubuntu. tteck’s helper scripts are a popular way to install some complex products: I use it for Unifi and for Plex. Turnkey Linux also works well with Proxmox, it’s a set of cross-platform VM images.

Also creating a custom guest system from scratch is really not hard. For instance I wanted a guest Samba share for my music files. So I set up Alpine, then installed Samba in 15 seconds, then configured it with a text file and I was done. Now I have a 65MB container that’s serving my music. This was certainly no harder than installing Samba on bare metal and the ability to checkpoint and tear down / rebuild this one service made it easier than worrying I might break something.

BTW Alpine is a real pleasure if you want a lightweight Linux. It’s based on Busybox, so not a great general purpose environment, but plenty good enough to run a simple server or two. A new install in a container is 10MB of disk and 2MB of RAM and has almost nothing installed but you can bootstrap from there, there’s 20,000 packages or it. A VM install is 130MB of disk and 80MB of RAM.

There’s lots of other choices for Linux in a container. See this set of images and this discussion for some other ideas. I have a couple of Ubuntu guests for a richer experience. I haven’t tried doing anything GUI.

Various choices and learnings

I am trying to enforce a rule of one container per product / service. I currently have containers for Unifi, Plex, and Samba. I need to set one up for a collection of Grafana monitoring hacks I have. I currently have a grab-bag VM which is a virtualized clone of my old server that I’m migrating stuff off of. And I also have one scratch Ubuntu container for random hacks / interactive shell stuff and one VM that is running nothing but Portainer and Docker that I’ll probably end up never using. Creating a new container in Proxmox is under 10 seconds of effort, making new ones is fun!

Proxmox has a bunch of storage management options. RAID arrays, ZFS, LVM, Ceph. I opted out of all of that. I have one simple BTRFS partition for Proxmox and one external USB drive simply mounted into the host system and then bindmounted into the guests that need access to it. Guest systems are all on virtual disks, which Proxmox manages (files in the BTRFS partition, I presume.) I will revisit my storage setup at some point, the extra stuff adds complexity but I think there’s benefits. Maybe I’ll finally have a useful full system backup. There’s even options for migrating guests and something they call “high availability”.

I’ve almost exclusively been using Proxmox with its Web GUI. That’s remarkably complete, the only thing I’ve needed a shell command for so far was creating a bindmount. But Proxmox has an extensive command line interface which most of the docs treat as the primary product. I should learn it. It also has a rich API but I’m not sure what other clients that are that use it. I need to learn this. I haven’t even read the docs through yet! The GUI is good enough I can find my way to most things. (Except changing the font for the shell terminal emulator; that was hard to find.)

I’m mostly using containers for things instead of VMs, in the theory that they are lighter weight. The LXC containers are not really inescapably secure, something you mostly mitigate by not letting the containers have anything like root access on the hypervisor (“unprivileged”). VMs are fully virtualized and more secure but also add the overhead of running an extra kernel. I don’t really care about security; my alternative here is running all the processes in a single Linux system. But I do care about enough isolation to keep things understandable.

I’m not really clear on how much overhead all this encapsulation is costing. So far I haven’t come anywhere near the limit of my 16GB of RAM, 512GB of storage, or 4 relatively slow CPUs. Proxmox puts a cap on each guest’s resources but doesn’t preallocate them, so my various service containers are only using ~10–500MB of RAM each and no appreciable extra CPU. The one full Ubuntu VM is using most of the 2GB of RAM I gave it, but half of that is for disk cache (does a VM mean I cache the same disk blocks in both the host and the guest?).

There’s also latency and jitter overhead. But maybe not much? I run some 50 millisecond-scale timing code as part of my Starlink monitoring and I have no idea how much uncertainly the containers will add to those measurements. Just eyeballing the graphs, running in a VM (on an unloaded host) doesn’t add any noticeable delays. And I’m guessing LXC doesn’t add any significant delay either.

It’s annoying how every guest OS wants a root password. There is support for ssh or direct console login but that password is still there as a primary authentication. That feels very old fashioned.

File ownership and user IDs are a total mystery to me. The Unix user model is really not very helpful in the one-container-per-service model. I’ve been ignoring the problem and using root or whatever user the image I installed created. It’s going to be an issue when I share files on disks between containers though, like that USB drive with my media on it.

I’m not sure exactly what the containerization is really getting me. End of the day I have more complexity for the same services. But.. it feels right having each product isolated. Like that’s an important simplification. Also Proxmox has the ability to checkpoint and backup guests which could definitely be an improvement over what I used to do. I think it’s worth the investment and the overhead isn’t too high.

Things I’m missing

Here’s some things I haven’t figured out yet or that don’t exist. I haven’t read the Proxmox docs through yet, so maybe it’s there for me to discover.

Every container has its own IP and hostname. But Proxmox has no facility for helping you track those, does not provide any sort of automated DNS for them. I’ve been installing avahi-daemon in some containers so .local mDNS names work but that seems silly. I’m also a little worried about running out of addresses in my /24. I guess I could expand the home subnet.

It feels like Tailscale could also be integrated in to Proxmox somehow. The main option seems to be to install Tailscale in each container and treat it as a separate host on the tailnet. (Which requires some config for unprivileged containers). That’s probably the right model but feels a little awkward. Also Tailscale’s binaries are 50MB, or 5x the size of the Alpine container ;-)

I still haven’t worked out how to share files across containers. Web searches suggest networked file systems: SMB or NFS or even 9P running as a server on the host and mounted on the guests. Yuck! I’m using a bindmount for a USB disk right now, that basically just shares the Unix directory from the host to the LXC guest. (You can also pass the USB device itself through and mount it only in the container, but that’s not really sharing.) I’d like some general solution for sharing disks, need to research. Maybe there’s an answer in Proxmox’ storage system which I’ve been ignoring so far.

Cloning a physical Linux system into a Proxmox VM

Working on replacing my failing server hardware with a new server running Proxmox. Finally realized I could just clone the whole OS off the old system rather than laboriously rebuild every service in a new way as containers on the new server. Clone first, then migrate later. Easy right?

Actually not too hard. The Proxmox wiki has several ways to do what they call “Physical-to-Virtual”, the primary one being “use Clonezilla to clone the entire disk into a KVM on Proxmox”. That’s what I ended up doing but it took about eight tries.

First, though, a minor complaint. It should totally be possible to move a Linux system solely by copying the files with rsync, not the physical disk block by block. I know this can work. But in practice the challenge is making it bootable. I think the modern way to do this is to install Grub in a second UEFI partition, then configure / use it to invoke the kernel on your main system. But the details of that are fiddly and opaque. So I cloned the disc.

The instructions on the wiki more or less worked. I wasted time on a few tries trying to migrate to a smaller virtual disk on the new server: the old server had 20 GB of data on a 256 GB partition. Proxmox has various options that look like this should work but I never could make it work, made doubly exciting by the way the clone tool doesn’t even check if you have space on the receiving disk for what you are cloning. (It worked for 15% and then failed on a seek error, lol.) Anyway, here’s my detailed notes during the process:

  1. Did a quick cleanup on the old server of disk usage, removing old log files etc to get the size down.
  2. Used Clonezilla to back up the whole disk to a USB drive as a safety measured.
  3. Booted Clonezilla remote source on the old server per these instructions.
  4. Booted Clonezilla remote destination on the new server
  5. Tried cloning to smaller partition. First time failed immediately (with no resizing options) without a clear error. Second time I told it to resize partitions proportionally; that failed a couple minutes in on a seek error, presumably trying to write past the end of the new smaller partition.
  6. Fortunately Clonezilla is fairly quick. It’s smart about not cloning unused space, also uses zstd. My copy operated at a nominal 12GB/minute (over gigabit ethernet from SSD to SSD).
  7. Finally gave up and allocated a destination partition bigger than the source. Clone succeeded but it didn’t boot; hung with 1 core at 100%.
  8. Searched the net for advice, found my way to this thread which suggests using an EFI BIOS in the VM instead of the default legacy Seasonic BIOS.
  9. First time cloning to EFI BIOS failed with a bit error on the copy. (Did I mention the old hardware is failing?) Filezilla detected the error, then ignored and made a valiant effort to recover from it. The resulting image was incomplete and did not boot.
  10. Cloned a second time and it worked! The new VM successfully booted to my Linux partition.
  11. systemd hung because fstab was trying to mount a hard drive on the old server that didn’t exist in the VM. Used rescue shell to remove those entries from fstab.
  12. Reboot did better, but got stuck getting network configuration up.
  13. Used a rescue shell to edit /etc/netplan/10-nelson.yaml to rename the ethernet device. (Use “ens18” instead of old “eno1”.)
  14. Reboot, comes up, but now no networking. Realize I’d left the old system running on the same IP. Ooops.
  15. Turn off old system, reboot VM and it works! I have successfully cloned the old server.
  16. apt install qemu-guest-agent. Not strictly necessary but helpful. Despite what the wiki says you can’t start this with systemctl in Ubuntu 23.04. It seems to start automatically somehow if you’ve enabled it in the Proxmox host options and reboot.

Clonezilla does work, and it is free. But oof is it old fashioned and clunky. I could see it totally being worth paying money for a nicer system cloning tool if you did this more than once every few years.

Boy does the BIOS make things complicated. I sort of understood the old legacy boot process but UEFI and GRUB are complex enough they make me nervous. I have zero motivation to sit down and really learn them.

BOSGAME B100 thoughts

I bought a cheap new mini-PC for Linux, a BOSGAME B100. I don’t have a lot to say about it except it has made a very good impression, particularly for the price.

Update August 2024: the cheap SSD in this thing failed after 9 months. Gave errors on reads sometimes. I still like this product category and it’s easy enough to replace the SSD, but ugh.

There’s a bunch of these generic inexpensive mini PCs on the market now based on Intel N100 CPUs (or before, N95). Beelink is a popular brand; I picked the BOSGAME because it would ship same day. I bought it from Amazon for $160 (with a coupon).

It’s wild how cheap these are for the capability. The CPU has 4 cores that can run up to 3.4GHz. 16 GB of RAM, 512 GB SSD that reads an honest 500 MByte/sec, a 2.5GB ethernet controller from Intel, 10 Gbps USB 3.2 ports. Supposedly 802.11ac and Bluetooth but I haven’t checked if they work in Linux. None of these parts are top of the line. For instance, the RAM is DDR4-3200 but it’s a single module (not a dual channel pair) and it’s CL 22. You can get SSDs that are 50% faster. But still, it’s pretty capable hardware. And that price!

It’s actively cooled with fans. I can’t hear the fan when it’s idle, I can hear it but it’s not very loud running at full load. One drawback of its design is it has the exhaust fan in the top, which means you can’t put anything on top of it. You could stack the Intel NUCs. (For an alternative see these fanless designs on sale here. But that’s got a big ol’ heat sink on top, still can’t stack it.)

Stress-ng gets it to 61C, the CPUs stays at 10.6W and 2900MHz. Plex actually works it harder when it scanned my video library for the first time. I saw the CPU peak around 76C, 14W, and 3300Mhz or more on all 4 cores. It’s using the GPU too, at least sometimes. The fan is a little noisy but the system is stable. Can’t find fan speed with lm-sensors.

The server seems to draw about 7W when running but mostly idle; the CPU package is using 2W of that. stress-ng on all CPUs gets the system to 19W, CPU package at 11W. Mind you that includes a spinning laptop drive which is 3W all in itself. It’s just remarkable how low power it is.

Signal Foundation financials

I keep seeing chatter about the Signal Foundation and their financials, so I dug deeper into their IRS 990 filings. No big story here, just my notes on what I learned. I love the secure messaging product and the non-profit mission. But their financial status sure seems headed for trouble. I am not an expert on non-profit financials, it’s possible I missed something and if so I’ll try to update this post.

Update: somehow I missed this post two weeks ago from Signal discussing their finances and asking for donations from individuals. More or less agrees with what I describe below. I’m looking at older financial reports, new donations won’t have shown up in the data I looked at yet.

Bottom line: the company is spending $20M–$30M a year. They’re making maybe $2M a year in real revenue. The only meaningful inflow was in 2018, the $105M loan (now mostly gift) from Brian Acton. They aren’t getting significant income from the product nor major contributions from other donors. They’re down to $37M in assets in 2022. Without some major change or new donation it looks like they’ll be out of money in a year or two. I think Wikipedia’s summary is mostly accurate:

On February 21, 2018, Moxie Marlinspike and WhatsApp co-founder Brian Acton announced the formation of the Signal Foundation, a 501(c)(3) nonprofit organization.[4][8] The foundation was started with an initial $50 million loan from Acton, who had left WhatsApp’s parent company, Facebook, in September 2017.[8] ... By the end of 2018, the loan had increased to $105,000,400, which is due to be repaid on February 28, 2068. The loan is unsecured and at 0% interest.

If you look at ProPublica’s summary of the 990 filings there’s some graphs of financial trends but they give a slightly misleading picture.

That revenue graph is dominated by details of the $105M loan in 2018. Most of the revenue in the graph above is Acton forgiving that loan, knocking $10M–$30M off a year. (The loan is down to $32M in 2022). If you look at Part VIII of the 2022 990, for instance, $23.5M of $26M is contributions. There’s no list of contributors but eyeballing the numbers, the big contributions every year match the debt forgiveness. It looks like their primary contributor is Acton writing off the loan.

Other than the gift, the most meaningful revenue Signal books is about $2M in 2021 and 2022 for royalties. There’s also ~$400K a year from investment income. Overall Signal seems to be taking in a couple of million a year from the product. And not receiving any major contributions other than Acton’s 2018 gift.

Meanwhile Signal’s expenses were $30.5M in 2022. Part IX of the 990s has the details. Roughly $12.5M is paying employees and executives, another $12.5M is computer hosting costs (Twilio, Microsoft, Amazon, Google). The 2021 picture is similar.

So that’s the picture; spending $30M a year, taking in $2M, and living off the $105M gift in 2018. That’s going to run out soon.

Nothing in this picture is weird or nefarious, it makes perfect sense for a non-profit. Signal is running a valuable service for people to use for free. But they aren’t getting major donations, relying entirely on that gift from their CEO in 2018. That’s cool too, I love seeing rich people use their money and time to build something of benefit to the world! But either he’s going to have to stump up again or something’s got to change.

(BTW, the Signal Foundation is the non-profit I’m looking at here. They own an ordinary company subsidiary, Signal Messenger LLC. That LLC seems mostly small and passive, not raising investment of its own. I don’t think this is like OpenAI and Microsoft.)

Amateur security hour at Carta

Just got this email from Carta. Or a financial phishing attempt. Or both?

At least they provided a copy and paste URL you can verify, although it going to a resource named “redirect” is not inspiring. The real treat here though is the big black button is not a link to carta at all; it’s a link to mandrillapp.com, some Mailchimp surveillance thing.

Linux and bad memory

This post has more than the usual flailing around. Don’t follow this advice.

My Intel NUC server is failing, twice now it’s corrupted database files with single bit errors. I confirmed with memtest86+ that the problem is bad RAM. I’ve got new hardware on order but meanwhile I want to make things work again.

First I used memtest86+ in summary mode (pressing F1 and F4) to get the above display. It’s telling me that RAM is bad between 868MB and 996MB, also with the hex addresses. Probably not all 130+ MB there is bad but who knows. (In detail I can see that the 5th bit is bad, mostly in a single 4k page. Happily this coincides exactly with the data corruption I was seeing in my database files.)

Then I convinced Linux not to use this RAM by adding the memmap=140M!860M to the Linux command line (by editing /etc/default/grub.) That avoids the whole region memtest86+ identified as bad. This Stack Exchange discussion was very helpful in figuring it out, and this web page has a great detailed explanation of how memmap works. The real purpose of this option is to tell Linux not to touch the memory because some other fancy performance system is using those addresses specially. I rebooted and confirmed the reservation was happening thanks to this line in dmesg:

[ 0.000000] reserve setup_data: [mem 0x0000000035c00000-0x000000003e7fffff] persistent (type 12)

Some fuckups I encountered along the way:

  • Linux has a CONFIG_MEMTEST where it can run a simple RAM check and automatically avoid RAM that tests bad. Apparently memtest=17 is a good setting, according to the cargo cult. I never got the system to boot with this; it’d just go to a blank screen and nothing would happen. I waited 20+ minutes, longer than the 4 minutes one guy who had 128GB of RAM said it took. Perhaps the system overheated and froze up.
  • The old way to do deal with flaky memory was using the BADRAM setting with a confusing mask. This apparently was never in a standard Linux kernel but the patch is in Ubuntu’s kernel. But it doesn’t work in UEFI Secure Boot so forget it.
  • A bug in ubuntu installer from 2016 left /etc/default/grub.d/50-curtin-settings.cfg lying around with a variable that clobbers my setting in /etc/default/grub with the empty string. Here it is eight years later and I just now got hit by the legacy of this bug. (They sorta fixed it, but didn’t do anything to repair systems that had the bug). So I was making changes to the GRUB config, always a scary and confusing thing, and they weren’t taking.
  • Sometimes on booting my poor machine would display “alloc magic is broken at 0x.....” early in the GRUB boot process, I think loading the init ramdisk. Searching Google for this error gives even less than the usual semi-useless info. But one common explanation is.. bad RAM! I noticed the address in the error was close to where my error is, so I think flaky RAM caused it. No idea why it works sometimes and not others, but it seems to work better after I let the system cool down a bit.

Truthfully, every time I’ve tried to use software to cope with flaky hardware it’s ended badly like this. Better just to throw money at the problem and get new hardware. I have an embarassingly cheap N100 system on order, hoping it’s not total garbage.

Filtering MailChimp spam in Gmail

Trying a new thing: labelling all email from MailChimp in Gmail so I have a heads up it’s probably spam. I’m not quite ready to just stop seeing these mails but I’m getting there. Here’s the filter, thanks to JsKnox’ suggestion to filter on list:mcsv.net.

Matches: list:mcsv.net.
Do this: Apply label "mailchimp", Never mark it as important

I didn’t select the action “skip inbox”. That’d be the next step. (I find JsKnox’s suggestion to reply with email of your own amusing but way more than I’d do.)

I’m not convinced this filter is perfect. My old filtering on phrases in the mail like “view this email in your browser” catches more mailing lists. But they may not be Mailchimp mailing lists; some seem to be some other spam software. I may end up wanting to filter on those too but I’m going to focus on Mailchimp for now. That list:mcsv.net filter sure is easy.

Thoughts and Rant

I get a lot of spam from MailChimp, Intuit’s spam company. Four years have passed since I last looked at this; back then I concluded 93% of the mail MailChimp sent me was spam but the other 7% was useful enough I didn’t block them entirely.

It feels worse now. Nothing in the product has improved for me, they still have nothing for people who receive mail from MailChimp. We are the product, not the customer. Meanwhile Intuit has cemented their control over the spam market.

I didn’t bother categorizing all the recent Mailchimp mail I got. Some of it is stuff I want, local community organizations that use Mailchimp (because what else is there?). A lot of it isn’t. Holidays are worst, when every restaurant and hotel I ever foolishly gave my email address to eight years ago decides to sign me up for a new spam mailing list and suggests I pop in for Christmas dinner in Thailand or London or someplace else thousands of miles from me.

The key problem is how Mailchimp allows their customers to add people like me to new mailing lists without my consent. That should not be allowed. Every subscription to a list should require consent from the recipient. But that’s not how the business works.

Gmail is in an interesting position where they could make that how the business works. Just tune their spam filtering algorithm a tiny bit, maybe rank mail from new mailing lists where I didn’t opt-in via Gmail more like spam. That’d be absolutely crushing to Intuit’s business and would no doubt lead to lawsuits. Couldn’t happen to a nicer company.

EV Charging Curve

Electric cars charge more slowly the closer the battery is to full. This response is called the charging curve. I was confused about what I was seeing and was wondering where the power goes if it’s not charging the battery. Turns out it’s never consumed in the first place: the car requests less and less power as the battery gets full.

Level 3

Level 3 DC chargers dump a lot of power fast into the battery. This forum discussion from May 2022 has a graph of the charging curve for the C40 and the XC40.

This graph shows charging power going from 150kW down to 50kW as the car charges from 10% to 80% in more or less a straight line, then further down to 25kW or so at 90%.

Level 2

Level 2 AC charging at home is providing a lot less power, 10% or less the wattage of Level 3 (typically). Here’s the curve going from 80% to 90% as measured by my Emporia home charger.

This shows charging power going from 9.2kW to 4.4kW. The drop started when the car was about 95% full and is not instant but ramps down over the course of 5 minutes or so. (The graph looks identical for amps.)

What seemed weird to me is that the Level 2 power draw stays at 9.2kW (38 amps) pretty much all the way up to 95%. I was expecting it to ramp down like the Level 3 does. But I guess the Level 2 power is so much less than the Level 3 power that isn’t necessary.

What also seemed weird to me is I thought on Level 2 my car charged faster going from 40–50% than from 80%–90%. But it’s drawing the same 9.2kW, so where was that extra power going? But I realize now I don’t really have a good measurement of that. I’m just eyeballing the time. And those battery percentages the Volvo reports are not particularly accurate measurements of how much power is actually stored in the battery.

I still don’t understand the underlying physics and chemistry of what’s going on to make charging slower when it’s nearly full. My hand-wavy explanation is the resistance on the battery goes up, so if you try to force too much current through a nearly full battery it gets wasted as heat instead. (Or worse, starts a fire). So the charging circuitry only requests as much power as it can safely put into the battery without overheating it. I think this is all some fairly complicated digital control logic but maybe it’s as simple as a circuit that responds to resistance.

Anyway for Level 2 the charging curve effect is pretty negligible. And not visible at all if you only charge your car up to 90%, as recommended. It’s more important at a Level 3 charger but the systems take care of it automatically for you.

Android Automotive vs Android Auto

Quick notes about Android Automotive Operating System, AAOS. I like it quite a bit. It’s part of why I bought the Volvo C40 Recharge.

AAOS is an Android-based operating system for cars. As the owner of a car, what I see is that I now own another Android device in addition to my phone and tablet. It has a different UI but it works like Android. I can install custom apps on it. And the default apps are quite good. Google Maps, of course, but a special version with EV charging info built in. Even better it integrates with my car’s systems so Google Maps can, say, look at my battery charge and help me plan a route. It also has Android apps for controlling the air conditioning, etc. AAOS mostly is visible on the car’s central display but it also integrates deeper into the car systems and the dashboard display.

Car software generally sucks. AAOS doesn’t, it mostly seems good and modern and not some OEM nightmare.

AAOS is different from Android Auto. Android Auto lets you mirror your Android phone’s display onto a car screen. Apple’s CarPlay is the equivalent thing for iOS. My C40 supports CarPlay but not Android Auto. I think they decided that Bluetooth integration with an Android device, plus maybe a little OS support to bridge things from the phone, was enough. I’m happy that calls, text messages, and media playing still work fine from my phone. But mostly I just run Google Maps and Spotify on the car itself.

GM/Chevy recently made the news that they were dropping support for both CarPlay and Android Auto in new cars. They’re adopting AAOS instead. That’s weird; AAOS can support the display mirroring mode. Dropping CarPlay seems like a real mistake, folks in Apple’s ecosystem are going to miss it. Also the press release suggests they’re doing this because they want subscription revenue; they can’t charge you if you’re just using your mobile phone to control the car. That sucks.

There are fewer AAOS apps that Android Auto apps. And both systems require extra work to support by app developers, a separate UI and affordances to not distract the driver. Here’s some developer info about AAOS apps from Google.

In practice I find the apps I want for my car are on AAOS. PocketCasts, Spotify, PlugShare. It even has YouTube and a web browser (only usable when the car is parked). Strangely A Better Route Planner is not on my C40. They do have an AAOS version for Polestar, not sure what’s going on there.

Home EV chargers simplified

I was confused about what I’d need for a charger at home for my EV. It’s far simpler than I realized. Lots of notes here specific to North America. Simple summary: get an electrician to install a new 50 amp circuit with an NEMA 14-50 outlet on it. Then use your car’s provided charger or buy a high quality charger like a Chargepoint Flex or an Emporia for about $500. You’re done.

Here’s lots of detail I’ve learned in the last week or two. Shoutout to Reddit /r/evcharging and in particular this wiki page and this post. They have useful if opinionated info.

How AC charging a car works

I’m only talking about Level 1 & 2 charging you do with AC power from a wall outlet. I’m ignoring Level 3 charging: that’s high power DC stuff you’re not doing at home. With AC charging everything from the wall outlet to your car plug is just to supply AC power to your car. It’s mostly just a wire; all the fancy stuff is happening in the car itself. The thing we call “a charger” on the wall with the plug is doing so little that “charger” is not really the right word. The Reddit nerds prefer the term “Electric Vehicle Supply Equipment” (EVSE).

Most EVs today use a J1772 plug that is carrying +120V, -120V, and ground to your car. It’s mostly a fancy extension cord. There are also two signal wires: one is used to detect that the cable is plugged in, the other is a simple protocol that tells the car how many amps max it can draw from the charger. Providing those signals is the only extra necessary thing an EVSE is doing.

Tesla has a different plug, the NACS plug. And starting in 2025 all North American EVs will use this plug instead. I don’t know details but NACS is enough like a J1772 that adapters are simple and cheap. During the NACS transition we’re going to be using a lot of those adapters.

Note that EVs have a charging curve: batteries charge slower and less efficiently the more full they are. Details are complicated and vary by charging source and car type. But all EVs charge better up to 80% or 90%; that’s part of why they all recommend not charging to 100%.

Level 1 and 2 charging

Level 1 charging is powered via a plain old plug, 110V AC and an ordinary NEMA 5-15 outlet providing 15A maximum (12A in practice). That gets you about 1.3kW and will take about 3 days to fully charge a typical EV with an 80 kWh battery. Everyone scoffs at how slow this is but can actually be useful if you’re charging in your garage and don’t drive much. Don’t write it off entirely!

Level 2 charging is also powered by a plug or can be hardwired. It’s higher power: 240V AC and often a 50A circuit. These high power circuits use a special plug. A NEMA 14-50 is common and typically will get you about 9kW, that 80kWh battery can be charged overnight. If you already have a 240V circuit in your house you can still use it even if it’s lower power or a NEMA 6-50 outlet. Level 2 is what people install in their homes.

Installing a power circuit

Unless you are lucky you probably need to install a new circuit in your house and that will require an electrician and maybe a permit. Go ahead and install a 50 (or 60) amp circuit, it won’t cost much more. And install a NEMA 15-50 outlet for the extra neutral wire. All this takes a few hours. I had no problem adding a 50A circuit to my 100A house power supply but houses with funky wiring, who knows.

The folks on /r/evcharging prefer hardwiring instead of a socket. It eliminates one point of failure, the need for an outlet, and possibly a GFCI breaker. On the other hand it means you need an electrician if you ever replace your charger, or at least do some tricky wiring. I chose the plug. Also there’s a question whether the common Leviton 14-50 outlets are up to the task of continuous high power draw for EV charging. I decided it’d be OK.

One weird thing is that for continuous loads, you’re only supposed to go to 80% of maximum rated power. See here or here for details. A 50A circuit should only actually have a 40A charger plugged into it. That 14-50 plug is also max 50A, so plug-in chargers stop at 40A. Hardwired will go to 48A because the plug is not a point of failure, although you will need a 60A circuit and breaker for that.

Choosing a charger (EVSE)

The EVSE does so little it seems unnecessary to spend a lot of money on one. Your car probably came with an adequate one and it may be all you need. The main distinguishing factor of particular EVSEs is a bunch of fancy scheduling and tracking software which are really not necessary. Your car probably can schedule charging itself. The tracking is not terribly interesting.

However: that charger is in your house. With a lot of power passing through it. This is not the place to cheap out on dodgy goods. Amazon is full of generic $200-$250 level 2 chargers that are not UL certified. They probably work fine but what if they set fire to your house? In the end I decided to pay more like $400-$600 for a trusted brand with UL certification. Almost all of them come with fancy software which you might then just ignore.

The evcharging wiki has a good set of recommended charger brands. I narrowed it down to three that had a plug version and were available on Amazon: Autel, ChargePoint, and Emporia. All UL certified, $400-$500 (on sale), well reviewed on /r/evcharging. I also liked the look of the Flo dumb charger but it’s hardwired only.

In the end I chose Emporia, mostly because it was the cheapest. And while I think the smart options are superfluous Emporia has an interesting suite of smart home electricity products. Including an energy monitor and a way to schedule the car to charge when your solar system has surplus power. I’m not using any of that now but I liked what the company is doing.

Conclusion

In the end it’s pretty simple to set up an EV charger at home. Running the circuit is the only hard part. You know what’s great? Never waiting in line at a gas station again. Having your car fill itself up every night when parked at your house.

Genie Pro Screw Drive remote programming

Got a new car with HomeLink and paired it to my garage door’s rolling code. Worked great! But then Ken’s HomeLink he programmed last year stopped working. We reprogrammed his, then mine broke. Did mine again, his broke. All through this a simple battery clicker kept working.

A trip through the manual informed us that this particular model can only pair with 7 transmitters. They don’t say what happens when you try to program an 8th but it seems to be a LIFO system, the last one obliterates the previous one. (Me, I would have guessed FIFO and the ancient 1st code would stop working. But that’d probably be the battery clicker that came with the device.)

The manual also told us how to reset the thing so it had no codes programmed: hold the button for 10 seconds. So we did that, then reprogrammed all 3 remotes, and all 3 work now. Hooray! I am glad I had a Theory of Mind for my Genie.

See also this earlier post about various options for garage door opener communications.

Samsung vs Material You

I wrote about this awhile back: creating a new Android UI with Niagara Launcher, dynamic backgrounds, and colored icons. The neat trick is Tapet can set a background with a random palette, then Niagara can pick that up and make the icons match the colors of the background. It looks great on Pixel!

It does not work on Samsung devices, because of a bug / design flaw in their OneUI. Samsung’s Material You colors ignore the screen background and are by default some boring blue. You can statically change the blue to something else with Theme Park, but there’s no way to have it dynamically set based on the background something else sets.

I just documented this all in painful detail in this Tapet GitHub issue. The interesting thing is the author clarifies that Tapet is not actually a Live Wallpaper app, it’s doing something similar (or older?) with simple static backgrounds.

I think the Live Wallpaper app Muzei was briefly working the way I wanted on Samsung. Muzie set the background, then Niagara picked up the new colors and changed the icons. But I tried the same thing today and it didn’t work, so maybe I’m wrong.

Charging a non-Tesla at a Tesla charger

Tesla runs a great charging network. Actually two charging networks: the Superchargers are the crown jewel with fast Level 3 charging but there’s also Destination Charging which is a network of power Level 2 chargers that are prevalent. You can use some of these in EVs with J-1772 + CCS plugs but it’s awkward right now. It’s getting better since the agreement on NACS and the transition is going on. In a few years we’ll all be using Tesla-style plugs (now called NACS or J3400).

Here is a map of Tesla chargers that can work with non-Tesla cars. It includes both “Superchargers open to Non-Teslas” and “Destination Charging”.

Access to Tesla chargers is via the Tesla app. Destination Chargers are often free, paid for by the business and/or Tesla. (Free is customary for a lot of J-1772 Level 2 chargers, too.) But now destination chargers can take money, too. I think Superchargers have always cost money although Tesla sometimes offers free charging as an incentive to Tesla buyers. For non-Tesla cars they cost about $0.50/kWh in California, or about what Electrify America is charging. Cars typically get 2.5-4.5 miles per kWh so this costs about about $0.15 a mile, or roughly the same as gas costs.

Level 2 / Destination Charging

The first trick is plug compatibility. You have to bring your own adapter for a J-1772 car, you are unlikely to find one to borrow at a Destination Charger. Amazon is full of “Tesla to J1772” adapters for about $80 that physically connect the two types of plug. I think these are relatively simple devices but there’s a locking mechanism and maybe a little signaling. These adapters will only work with LTesla’s Destination Chargers, not Superchargers.

The second trick is electrical compatibility. I think this just works. Level 2 charging is basically just providing AC current for the car to deal with, the car itself chooses the amperage and charging schedule. So it’s relatively easy. Most of the Tesla adapters I see promise 40 or 48 amps which is about the max level 2 you’re likely to see. A few specify 60 amps. In my car at least, I have to manually select how many amps to draw (Update: that may not be necessary).

The map shows several hundred Tesla Destination Chargers in California. Only one in Grass Valley.

I used one of these Tesla chargers for free in March 2023 in Florida. Worked fine and Hertz had provided an adapter with my rental Polestar 2.

(Interesting thing: J-1772 to Tesla adapters are half the price of Tesla to J-1772 and are much smaller. I think this reflects that in general the J-1772 connector is bulkier and more complicated. I wonder if that’s part of why the auto makers were willing to adapt the Tesla plug. Amazon has a few cheaper adapters but they look like scams with fake reviews.)

Level 3 / Supercharging

Plug compatibility for Level 3 charging is via Tesla’s new Magic Dock. If you tell the supercharger you’re not in a Tesla, it will unlock an adapter to J-1772+CCS that will work with your car. (The “magic” is that the adapter stays locked to the cable so you can’t take it away.) The Magic Dock is something of a temporary solution as NACS rolls out. Tesla is incentivized because it will get billions of dollars in federal subsidies for providing CCS compatible chargers. Good, that’s the subsidy working, assuming the Tesla Superchargers do function as promised. Musk sure is good at capturing government subsidies, it’s a feature of all his businesses.

I don’t know anything about electrical compatibility. I believe Level 3 requires significant negotiation of charging power. Presumably the Tesla charger speaks whatever software protocol CCS uses. I wonder what the endgame is after NACS is fully rolled out; will there be one protocol standard or two?

The map shows exactly two Superchargers for non-Teslas in California: one in Placerville and one in Scotts Valley. Both are charging about $0.50/kWh.

Commentary

Tesla has done a fantastic job building out a fast charging network. There are Superchargers in lots of places, they work well, and often they are pleasant places. They have a mature product with memberships, incentives, and mechanisms for third party billing (like a car rental). And their plug and cables are lighter and easier to use than J-1772 + CCS. I’m glad they won the standards war.

I hope we get a robust market of competing Level 3 NACS chargers. It will make a huge difference in Americans’ willingness to switch to an EV. I keep hoping someone figures out a business model where the charger is a destination. It might take 30 minutes to fill up but if you know you can get a good coffee or some decent tacos and the WiFi works, that’s not so bad.

Volkswagen sure shit the bed with Electrify America. That could have been a real competitor to Tesla’s Supercharger, making lemonade from their emissions fraud lemons. But instead of embracing the opportunity they did a bad job building a charging network. There’s lots of chargers, sure, but they are always broken. Also the Walmart parking lots they tend to be in are not exactly lovely. And their website and app are badly implemented. In general it’s just a poorly executed product. Opportunity missed.

The web is full of spam when you look for info on Tesla and charging. Zillions of websites with wordy low quality content farm articles, presumably partly AI written.

Influx corruption / hardware failure

My Influx time series database corrupted itself. Hard to even see what was going on. Grafana couldn’t load data. The process was using 100% CPU. I finally figured out the logs are in journalctl -u influxdb.service -n 1000 but are super spammy. And don’t use useful error levels, so filtering with -p isn’t helpful. But I got lucky and saw a real message in the sea of log spam. And figured out Influx was restarting itself and then panicking every few minutes. Here’s the real error.

Nov 23 06:54:10 gvl influxd-systemd-start.sh[1801566]: panic: keys must be added in sorted order: dsm1_cache,database=telegraf,engine=tsm1<hostnamu=gvl,id=794,induxType=inmem,patx=/var/lyb/influhdb/data?telegraf/autoge~/794,retentionPolicy=autogen,walPath=/var/lib/influxdb/wal/telegraf/autogen/794#!~#writeDropped < tsm1_cache,database=telegraf,engine=tsm1,hostname=gvl,id=794,indexType=inmem,path=/var/lib/influxdb/data/telegraf/autogen/794,retentionPolicy=autogen,walPath=/var/lib/influxdb/wal/telegraf/autogen/794#!~#snapshotCount

Note the bogus path there that starts /var/lyb/influhdb. Looks like corrupted data in Influx’s internals and the code isn’t smart enough to recover from the file not existing. It’s helpful to see the ID 794, presumably that’s the particular table / series / whatever that is corrupted.

So wutdo? Naturally I don’t have any backup. Here’s what I did to brute force remove the corruption.

  1. Stop influx with systemctl stop influxdb. Also stopped all processes like telegraf that were writing to it.
  2. Make a backup of all the files in /var/lib/influxdb. It’s about 4.5GB and gzipping it is a mistake.
  3. Look at influxdb/data/telegraf/autogen/794/fields.idx. Happily this is readable text that gives a clue as to which series is corrupted. It’s some old data related to PVS6 monitoring that I’d like but can live without.
  4. fgrep -r 'var/lyb' . in the data files to see if I can spot the corruption. Yes, it’s in data/_internal/_series/02/0000. Also in data/_internal/monitor/2090/000000064-000000001.tsm.
  5. At this point use Google and search for info on rebuilding a corrupt InfluxDB. I found this page about “Rebuild the TSI index” that looks promising. In particular it involves removing all the _series files; one of those is what’s corrupt for me.
  6. Double check the backup is good, then follow those instructions. I remove all the _series directories.
  7. Joke is on me! influxd inspect returns unknown command "inspect"
  8. Try to start Influx anyway, maybe it’ll rebuild what it needs on its own?
  9. Get same error, now it’s tripping over that monitor file I didn’t remove.
  10. Look in the data directory, see a bunch of new _series directories. I guess it did rebuild them?
  11. Delete the monitor file that matches var/lyb. Also delete all the _series directories again since one seems to have picked up the corruption. Brute force but we’re desperate here.
  12. Restart influxdb.
  13. Success! It started without any freakouts. Presumably I lost that one data series but the others seem to work. I hope.
  14. Reboot as the easiest way to restart all the processes that want to write to InfluxDB.
  15. Launch Grafana and verify most of my stuff is still there. Also verify the PVS6 project whose data I clobbered is not there. RIP.

This is not the right way to fix a valuable database! But this database is only sort of valuable and it’s 6am on Thanksgiving and I haven’t had coffee yet. This will do fine.

What I should do next is set up Influx backups. Or maybe this is the time to try switching to timescaledb, a Postgres extension for time series databases.

Really what I should be worried about is how random data got corrupted on my machine like that. Cosmic rays do happen and if so well, eh, that’s the hidden cost of cheap hardware. But the machine is five years old and not 100% stable (this is the NUC that overheats) so maybe the hardware is failing.

I took a look at system metrics and what I found is disturbing. Telegraf stopped logging at around 17:30 (local time), an unexplained failure I’ll chalk up to InfluxDB failing. There’s gaps of data until about 01:00 when it finally gets stable again. CPU load spiked around 21:00, that may be when the Influx process started failing so badly. Although a lot of data got written after that.

I don’t see any evidence this happened before, at least not in the last week. I guess I’ll keep an eye on it and the second there’s second evidence of random data corruption I replace the hardware.

Update

Ugh, it happened again. This time it’s related to autogen 893 (not 794) and a small snippet of corrupt data: datarase=telugraf,enwine=tsm!,hostna}e=gvl. Very glad I wrote up notes last week, I’m just doing the same thing again to blow away the corrupted data and recover the rest.

Oddly this corruption is also in my PVS6 data, something I haven’t read from or written to in months. Maybe that’s just a coincidence, I think the specific corrupt data is different this time. Also I think it got triggered by my reading data for some other measurements in Grafana. Huh.

Given the pattern of substitutions, something’s flipping the fifth bit in random bits of storage or, more likely, memory. Presumably hardware failure, unless for some unlikely reason I’m the target of a state-sponsored rowhammer hack. Looking for new hardware now, probably a Beelink system.

Securing your Roku data

Roku is an excellent media streaming device. But it’s ridiculously cheap because their real business is selling data on what you watch to advertisers.

I haven’t found a good general Roku setting in the app for opting out of that surveillance. It’s not really in the app’s settings, other than you can turn off personalized ads. I presume they’re still selling my data.

I did find some hard-to-find web pages though.

California gives me special powers. Roku has a don’t-sell page for us hidden here. The UI is (deliberately?) confusing but I believe “Enabled” is the more private option.

Roku’s cookie settings gives you tools to opt out of not only their own cookies, but their ad partners too. The main thing it does is take you to this industry opt out tool which is a general purpose web thing. Only works with ad blocker disabled. I think this is just setting things on the specific web browser you visited it on and is not a broader account opt-out.

Roku is also embedding more and more ads in the app. There’s a secret menu to turn those off that works, at least for now. Hat tip to Andy for finding this page. The code is Home (5 times), then up right down left up.

Update: My Roku is actually a TCL television. I can’t find anything online about TCL privacy choices but when I emailed me they sent me to this web form to submit a request. An automated process got me to the point of them wanting my TV’s serial number that also says “Roku TV: This data is solely controlled by Roku TV. Please email the request to privacy@roku.com” so I guess that’s the end of that. The process was not friendly: 2 different CAPTCHAs and 3 separate verifications of email and phone number.

Securing your Plex data

The Plex video player launched a new social media feature where it shows you things like “your friend Nelson watched Totally Licensed Movie last night”. You can see your feed of friends’ activity at this link. This seems to be part of a broad new product effort called Discover Together.

I didn’t opt into this sharing. I don’t want my friends to see a list of the TV shows I watch. Plex unilaterally decided to start collecting and publishing that data without my explicit consent. Which video files I watch is private data and potentially a legal problem. I can see how it’d be useful for Plex to become more of a social media app. But the abusive way they launched it makes me want to go scorched earth and block every aspect of data sharing I can from Plex.

Update: in a discussion on Mastodon a Plex engineer responded with a personal (not official) comment and said

You should have been shown two screens at some point; one to opt-in or out of view state syncing, and another more recently to opt in or out of the social sharing stuff, and would have needed to opt-in to both for any of this to be shared with friends.

So it’s possible I clicked something at some point to allow this.

Update 2: over on Reddit someone posted what the UI looks like for the opt-in I might have clicked. There’s four screens that pop up interrupting whatever you turned your TV on to watch. The first three are marketing copy, the fourth is the consent request. It’s very unlikely I paid enough attention to this to make an informed choice. It also looks like the default was to opt people in to friends sharing.

Update 3: PC Gamer has an article about Plex’ explanation of how people got this turned on without their consent. Turns out the “You’re in control” UI has a flow which turns off the privacy without the user intending it. Terrible design although not clear if it’s malice or incompetence.

Here’s what I did to preserve my privacy. I found two major things to block in Plex: watch history and ad preferences. There’s also some other minor account settings. Details below.

Profile settings: activity sharing

You can opt out of sharing what you are watching with friends by going to this link to edit your profile and selecting “Privacy Settings” at the bottom. “My Watch History” is the one I found most invasive.

Account setting: ads and more

Plex has a bunch of other privacy settings in your account. You can edit them by going to this link to edit your account and looking at the bottom for Privacy. There are several links there.

The most useful one is the Ad Vendors page, where you can opt out of them selling your data to 100+ marketing companies. This only works in some US states (thank you, California!) You have to disable your ad blocker to see the UI that lets you change things.

Here’s the list of opt-out states. The obvious typos are perhaps an indicator of how seriously Plex takes this part of their product.
California Colorado Connecticut Virginia Utah Indiana Iowa Montana Oregon Tennessee Texas Massachusettes New Jersey Pennsylvania Deleware

There’s also a “Privacy Preferences” link that takes you to this part of the webapp. It looks mostly like legalese text but if you look closely there is a checkbox you can turn off for “Send playback data to Plex”.

Further up the account settings page there’s also “Sync Your Watch State and Ratings”. That’s also keeping a record of what you watch. I think this particular feature is private to you and it provides a useful function, so I’ve left this one on for now.

Dark patterns

Plex’s scattered privacy settings seem designed to make it hard for users to find and configure them. It’s so hard to even find these things that I had to write a whole blog post. And after spending 30+ minutes on this I’m still not sure I got it all configured the way I want.

The playback preferences are buried deep in thousands of words of legalese text. The ad vendor preferences are only available to users from certain jurisdictions. And then the UI doesn’t even work if you are running an ad blocker (as likely 98% of people who get to this page are).

Maybe that’s all just bad design, Plex is not the most professional product. But it sure feels intentional, to keep users trapped in choices that benefit the company.

Ubiquiti routers: garbage bandwidth stats

My Ubiquiti routers continue to vex me, Unifi OS has lots of problems. My latest complaint is it’s not even able to give me a basic accounting of how much bandwidth each device (IP address) on my LAN is using.

For instance, here’s what I think is a graph of the last month’s traffic for my Playstation. I downloaded a 60GB game on Nov 17. I also probably downloaded at least one other > 30GB game that month but I’m not positive.

In upper right it says 66.7GB download for the month. That is a plausible number but I think is low But then in the graph it shows an average of 0.8Mbps for the day of November 17. Also plausible? 0.8*86400 = 69GB. In the graph tooltip it says “Total Traffic” (for the day) is 9GB. That doesn’t agree with the graph data! And then in the chart below it says “All Traffic: 6GB” for the whole month. On a different screen for the device it says “Traffic Activity: 1.66GB”. It’s like they’re picking random numbers.

The displays are utter nonsense. This problem has been going on for years. (Before, they didn’t even have any traffic stats.) I’m not the only one complaining: see here or here or here or any of these.

Unifi also has a more ambitious “Traffic Identification” display where they try to show you bandwidth by application: Youtube, etc. Doing that reliably is hard, I would expect some inaccuracy. But counting by device IP should be really simple. Failing that makes me wonder what else is wrong in the router that is less visible. (BTW, that screenshot above may actually be what it thinks for my whole network, although in context it doesn’t seem to be. If I explicitly choose PS5 I get another graph that shows that same 1.66GB total and otherwise obviously wrong small numbers.)

Every time I see a product fail this badly I always wonder, do the engineers who work there give a shit? Do they use their own software?

PG&E rates and EV charging

I’m about to get an electric car so I’m looking again at what I pay for electricity. Up to 54¢ a kWh! We have some of the highest electricity prices in the world. Also some of the most unreliable power for a supposedly advanced nation. And occasionally PG&E’s negligence kills some people or a whole town.

I have two houses and a full panoply of rates I’m paying. It’s remarkably hard to find the actual rates on the website or in your bill but this PDF has an overview of the common residential plans. Also the rates are hard to understand. There’s two tiers: a “baseline” and then overage. I’m only looking at overage prices. Also prices may vary based on time of day or season of the year. In total I use about 7000 kWh a year in San Francisco and 17,000 kWh a year in Grass Valley. There’s solar in GV that gets me to about net zero for that house on a yearly basis.

I’m mostly interested now in what it will cost extra to charge my car. I’ll only charge at night. I’ll be paying fully the higher tier pricing for the incremental extra electricity. I’m guessing I’ll use about 3000 kWh a year (or 13% more) for the car. Because of how the NEM 2.0 rate plan works there’s no advantage to me charging directly from my solar: PG&E credits me fully for everything I give them.

In San Francisco I’m on the old E-1 plan. There’s no time of day or seasonal adjustment. I’m paying 45¢ for past-baseline power. My car will be charging at 45¢/kWh.

In Grass Valley I’m on the E-TOU-C plan. (I also have solar under NEM 2.0, but that can be ignored here.) Power is more expensive from 4pm to 9pm, and for the four months of summer. Past baseline, prices are 46¢ to 54¢ in summer and 41¢ to 44¢ in winter. My car will be charging at an average of 43¢/kWh.

PG&E has a second time of use plan, E-TOU-D. It discards the baseline discount, has a shorter time window for peak pricing, and has lower average rates. My car there would charge at about 39¢/kWh. I think my overall bill would be higher though.

PG&E also has a EV2-A rate plan for electric vehicle owners. It’s significantly cheaper from midnight to 3pm (26¢) but then 43-57¢/kWh during late afternoon and evening. The car would charge at 26¢/kWh but the rest of my bill will go up. Too early to tell if it’s a net improvement for me.

Bottom line, if I charge the car 3000 kWh a year I’ll be paying about $1350 a year just to charge the car at my current rates. Which is just about what I pay in gas right now for the old car. If I switch to the EV2-A plan I might save $600 charging the car, but then the rest of the bill will go up and I’m not sure how much.

Update: in Jan 2024 the CPUC gave PG&E another eye-watering rate rise. Here’s an estimate of new rates (I think)

  • E-1: 53¢/kWh
  • E-TOU-C plan: 46¢/kWh
  • E-TOU-D: 35¢/kWh
  • EV2-A: ???

PG&E (or rather Opower) has a “find your best rate plan” that re-runs your old bills through each pricing plan and tells you what you would have paid in each plan. It’s not useful to me right now, but might be useful after owning the EV for a few months.

Windows fan speed controls in 2023

Computer fan noise was annoying me in my office, this high pitched whine. So I went looking for Windows software to understand what my desktop was doing.

LibreHardwareMonitor is a good open source program for monitoring fan speeds. It’s a fork of OpenHardwareMonitor, which stopped getting updates in 2020. You just run it and it quickly gives you a list of fan speeds, CPU temperatures, and a bunch of other hardware sensors. It has support for a whole lot of hardware and requires precious little effort to get going.

Usually a PC’s BIOS controls fan speeds. My ASUS X570 has a fancy thing called Q-Fan which has little control graph settins of fan speed vs temperatures. This works pretty well. My vague memory is if you run the “Optimize” thing in the BIOS once everything works better, but you still want to tweak it manually afterwards. (Bonus memory: the Apple keyboard I usually use is not capable of opening the BIOS with F2/Del. Something weird about how it initializes, or rather doesn’t. I have to plug in a standard PC keyboard to open the BIOS.)

Fan Control is an open source program to override the BIOS’ fan settings. If you ever used the ancient SpeedFan program, this is a better version of the same idea. It has a very slick setup system where it enumerates all the fan controllers, then tries changing input power and then sees what the fan RPM sensors tell it happened. Once it’s set up you can then manually alter fan speeds (overriding the BIOS) or enable one of several “Curves” which automatically change fan speed in response to temperature or other sensors. I decided not to use this but if I wanted to do more than the BIOS’ settings, I would.

CPUStres is a Microsoft Sysinternals program to generate CPU load to test your cooling. I found this really confusing to use.

HeavyLoad is a third party program for generating load. It’s no cost but is not open source. it’s easy to use to peg your CPU and GPU to 100%. It has a weird bug where it launches but the GUI doesn’t get events; if you switch to another window and back it seems to work right.

I spent half an hour figuring out what the fans were in my computer.

  • Fan 1: the fan at the back of my computer chassis. Very quiet even at full speed, software controlled. Usually runs at 550RPM, max is about 830.
  • Fan 2: the fan in the middle of the Noctua NH-D15S CPU cooler. This gets a little noisy at full speed (1500 RPM) but usually runs more like 550 RPM. It’s the fan I hear when my computer gets busy and is a little annoying, but sounds like moving air and not a whine. Software controlled.
  • Fan 5: no idea what this is, it shows as 840 RPM almost always no matter how busy the system is. It is software controllable and I can hear it, but I never did quite find where it was. The ASUS BIOS shows an “AIO Pump” running at 840 RPM but I certainly don’t have any pumps or liquid cooling. Maybe someone reused the motherboard header for a fan for the motherboard chipset or something?
  • Mystery 2866 RPM Fan. The BIOS shows me a PCH fan running at 2866 RPM. I have no idea what that would be and there’s nothing running loud enough to be that fast. The speed slightly varies so I suspect the sensor is hooked to something.
  • Power supply fan. My Corsair RM750X has a fan. It has no software interface at all but does turn up or down based on temperature. It seems very quiet.
  • NVidia 1080 GPU fan. Almost always entirely off, gets up to 650 RPM or more when the GPU is busy. It’s pretty noisy when it turns on.

The ironic conclusion to all this: the noise wasn’t coming from my Windows machine at all. But rather the NUC Linux server in the closet. Noise goes away when I close the closet door, d’oh. This is the same NUC that is overheating and is unstable at full CPU speed. The fan does work, I haven’t looked at controlling it.

SEO spam, Google, Bing, LLMs, and facts

Writing up a short thread I posted on Mastodon.

I want to know what the half-life of benadryl is. So I asked Google, then ChatGPT, then Bing. A common theme with all of these is that they have AI-enhanced systems that swiftly and confidently give a specific answer. But the actual answer is different in every case. There’s a general consensus of 3-9 hoursish, but some sites are saying 6-12.

Worse, the AIs are not great offering sources. The underlying problem here is the web is full of SEO spam from sleazy addiction clinics who are putting all sorts of garbage online to get clicks. And Google, etc are incorporating that garbage. So I really need the actual source so I can then evaluate it for myself. But results on that are mixed.

Google

Search query: [what is the half life of benadryl]. The top summary snippet is from an SEO spam site and says 6.7 to 11.7 hours. Below the fold are a bunch of ordinary search results with snippets highlighting numbers: 2.4-9.3, 7-12, 3.4-9.2, 2-8, ... The good thing here is the results are all links to sites so I can quickly click and evaluate them. The bad thing is most of the links are garbage. Results 4 and 5 are NIH studies, presumably peer reviewed, and give 7-12 or 3.4-9.2 as answers.

ChatGPT 3.5 (OpenAI)

ChatGPT 3.5 tells me 2.4 to 9.3 hours with no sources. When asked specifically for sources it doesn’t provide any but says “you should consult sources”. This result is basically 100% garbage, particularly given ChatGPT 3.5’s penchant for making up fake facts.

ChatGPT 4.0 (OpenAI)

Does a bit better than ChatGPT. Says 2.8-9.3 hours. Gives sources when I ask it, although it’s just by name and fairly generic. A friend and I both tried checking these sources and neither of us could find any specific reference to 2.8 hours. Either ChatGPT made that number up or, at the least, it’s awfully hard to verify its sources. The number is plausible though.

Bing (with ChatGPT 4.0)

The most interesting and promising result, sort of, in response to my query.

What I like about this is it has a mix of an AI summary of web results, a ChatGPT chat answer (offered sometimes, not always), and a list of ordinary web results. The chat results come with citations. Although sadly they are SEO garbage. Also like Google there’s a series of conflicting sets of numbers on the page, all presented with confidence. The first solid result (from NIH) is below the fold but fairly high up, not seen in this screenshot.

Thoughts

There’s a lot of things going wrong here. It’s a hard question without a clear answer. The sources the web search engines are relying on have been comprimised by SEO spam and they aren’t good at finding an authoritative source.

But I’m most mad about the UI choices being made. The system should be smart enough to know it doesn’t have a clear answer; the display of its guesses should be tempered with some indication of low confidence. And no one is doing as good a job as I want with citing sources so I can research and evaluate them myself.

Update: Phind

A friend suggested I try Phind, an AI startup. It’s interesting. It gives me a 5 paragraph answer and a sidebar that’s more like a traditional search engine. The main answert gives me a confident first number (2.4 to 9.3) and then gives me nuance in later paragraphs like how it caries with your age, dosage, general healt etc. And it does cite sources.

Unfortunately it cites addictionresource.com, which I think of as one of the SEO spam things. Although looking more closely at that page it’s fairly good. The synthesis that impressed me in Phind’s answer actually all comes from this page; Phind’s answer is basically a summary rewrite. Also the page does have a bunch of citations at the bottom. It may be SEO content but it’s not spam.

Kiwix Android mess

Update: this is now resolved. As of December 2023 the Play Store has version 3.8.1. The F-Droid version is still ancient though. See these notes on why you might still want to sideload an APK if you want to easily download ZIM files to your phone.

I’m a big fan of Kiwix, the offline Wikipedia reader. It’s great having Wikipedia cached locally on your phone, particularly when travelling. However as near as I can tell there’s no easy way to get a recent version for Android. iOS is a little better. I may be confused but this is what I’ve found.

The Kiwix Android GitHub repo and Apple repo look official and included dated source releases but not binary builds. Android had a 3.7.0 source release in May 2023. iOS had a 3.1 source release at the same time, with a 3.2 just yesterday. Presumably these version numbers are not directly comparable.

The Kiwix Applications page has what I assume are links to official binary downloads.

For iOS, the Mac App Store link gets you version 3.1, from May 2023. 3.2 came out literally just yesterday so a little delay is understandable. That all looks fine.

For Android, the Google Play link gets you version 3.4.5. That’s from November 2021. It won’t install on Android 14 although I happen to have it installed and it still seems to work. The F-Droid link is just the APK for F-Droid itself. The version hosted at F-Droid seems to be 2.4, from 2018. There’s also a direct APK download link. That gets you 3.7.1, the latest Android release (from June 2023), but you have to sideload it manually and it won’t get autoupdates. Bottom line: install from Google Play if you can, or else sideload.

Why aren’t there more recent Android binaries? This Reddit comment has the story. Kiwix is not open source enough for F-Droid’s policies. And Kiwix did some file scanning which fell afoul of Google’s review process. It looks like that was supposed to be fixed with release 3.7 but somehow that still isn’t out. This issue suggests they’ve fixed the issue very recently? There’s also this issue which tracks Android 14 support.

Update: got a response on Mastodon from Kiwix saying “3.8 should be on the playstore anytime soon”.

(The underlying technical problem is Kiwix needs to access the ZIM library for Wikipedia, which can be 100 GB or more! Treating it as a special file makes sense. But Android has over time made it harder and harder to access the local filesystem and they seem to be running into restrictions when they try to make Google Play releases.)

While I’m complaining, Kiwix also has always had usability issues for figuring out which ZIM library for Wikipedia to install. Right now when you look for Wikipedia in their web library you get 66 results. Anywhere from a 878kB file for “Wikipedia articles about Ray Charles” to a 102GB file for “The free encyclopedia”. It’s really unclear which of all the options you want. The mobile download interface in 3.4.5 is a little better than the website and if you sort through the Simplified English version and the “top 100 articles” version you can eventually find 60GB and 100GB files for the whole Wikipedia (with and without images), also a 6GB download for the top 50,000 articles. The library you want is there, but it’s really hard to find it.

I always feel bad complaining about free open source software. I really appreciate the work these folks do. But Kiwix is important and it’s a shame it doesn’t have easily installed releases for the mobile OS with 70% market share.

Hot water recirc energy cost

I have recirculating hot water and a gas hot water heater. It’s very nice having instantly available hot water! I always wondered how much propane I’m wasting pumping warm water around the house.

0.9 gallons a day, or about $60/month. Or 4x the propane I’d otherwise use in summer. (In winter I average around 6 gal/day for heating.)

In detail: I went out of town for a couple of weeks and unplugged the recirc pump. The average usage then (from Sep 23 to Oct 12) was 0.2 gallons. A month earlier it was 1.1 gallons. The low period had the hot water heater turned on, but no recirculation wasting heat. Also no gas cooking or actual hot water usage so not all of that 0.9 is attributable to the recirc loss. (And no furnace heat at all for any of this.)

I used to use a timer to turn the recirc off at night but it stopped working and I wasn’t sure the savings was worth the bother. I guess it was! My long term solution for this is to get a heat pump hot water heater which should be more energy efficient and avoid burning CO2. Some folks use instant hot water heaters at the point of use but I don’t think that’d work for me.

Every Mastodon client is broken

I have a simple goal with Mastodon. When I wake up in the morning I want to see every single post in my Following timeline. In reverse time order, oldest first. I do not want to see boosts ever but I want to see every original post. In Twitter I could do this easily, just by scrolling down (with algorithmic timeline disabled).

Not a single Mastodon client I’ve tried can do it.

Fedilab, tooot, and Megaladon all will just miss posts. I’ll see a post that’s 7 hours old, then a post that’s 1 hour old, and everything from 7–1 in between is missing.

Moshidon looks like it might be able to show all the posts inbetween. I like the UI above: it shows the 11 hour gap and has buttons to fill it on either side. A little more manual than I’d like, but workable. Only it has a fatal bug; when I tap “load newer posts” it does load them but for some stupid reason ignores my client-wide setting to ignore Boosts. So I see a stream of lots of boosts, not just the actual posts I want. It doesn’t have this bug when loading posts in other contexts, only pressing this button. Also if I quit Moshidon and relaunch it now that UI is missing; any posts I didn’t tap to load last time are now forever inaccessible.

Writing this now I realize I haven’t tried the official Mastodon Android client. In the past I didn’t like that one much, but I suppose I should try it now. Nevermind: it doesn’t have the ability to hide boosts.

The problem is so commonplace I wonder if it’s a problem with my server, or with the Mastodon API. But it’s not exactly consistent: each Android client seems to have a slightly different gap it refuses to show, it’s not like the same set of 23 posts are missing. And the Mastodon web client (or rather the Glitch soc fork) I use on tech.lgbt also shows this bug in the web view. But only sometimes. It doesn’t today, whereas all 4 Android clients I tried do.

One thing I’ve noticed trying all these clients is they all suck in various ways. 3 of the 4 lack the “tap at top of screen to scroll to beginning” UI that every Android app should have. Tooot doesn’t even have a humane inertial scrolling, so I have to swipe up one screen at a time over and over again to get to the most recent posts.

Another big probem is these apps all love giving user preferences. Fedilab must have 200+ settings. Some I understand; a single button to show or hide boosts, for instance. Others are baffling. Why are there buttons for “show indicator for image alt text” and also “show indicator for missing alt text”? Just pick an alt text presentation style (the right one) and do it, don’t make the user create their own custom client experience. Lots of choices for configuring correct behavior too, like “load missing content from servers”. Um? Yes? Why is this a toggle? It’s classic open source product design: the folks building the product just love all those choices so they figure their users must want choices too. Too many choices.

Sorry, feeling a bit ranty today. The inability to simply load old posts is pretty maddening.

Update: an iOS using friend says Ivory has no trouble with showing all old posts. Unfortunately I don’t have any iOS devices to try it on.

Update 2: I like this speculation it could be related to paginating incorrectly while filtering boosts. That the client loses count because it’s skipping some posts. Plausible? Hard for me to test short of spamming myself with boosts and seeing if it works.

Update 3: another line of inquiry is that I am informed that the Mastodon server keeps a queue of 800 posts for you in the timeline. That’s it and that includes all things, including stuff I’m filtering out in the client like boosts. That number is hardcoded in feed_manager.rb. I don’t really understand the code but it’s more complicated than that, with some calculations happening with just 200 or 400 items. I don’t think the posts I’m missing are 800 down a time ordered queue, I’d guess more like 100-300. But it’s worth a closer look.

Typographical quotes in 2023

Working on my new blog engine. I want to have “typographical quotes”, ie: “smart quotes”. Nice curly things that look like typesetting, not straight ’ or ” from some old typewriter. I am most interested in American English’s use of double quotes (open and close) and the apostrophe character we use in the middle of a word for contractions and plurals.

Annoyed I have to do this in my HTML; browsers could do a better job here, applying English curly quote rules to text input that looks like straight quotes.

Side note: testing all this was hard because something in Windows, PowerToys, or Windows Terminal is converting stuff I copy and paste. I can have a U+2019 in my terminal window from cat or from a web page and then when I paste it it turns into a U+0022. It was doing this with HTML entities I copied too. So I’m doing cut -c x..y | od -t x1 and dealing with cut not supporting UTF-8.

Side note 2: blogging about all this is impossible. The Wordpress editor is rewriting stuff I type, replacing various crafted markup examples with literal quote glyphs.

Unicode

Unicode double quotes are easy. U+201C and U+201D. Right name, right character category, done. Single quotes used for quoting are also easy: U+2018 and U+2019.

Unicode apostrophe is a mess. The ASCII U+0027 APOSTROPHE is what I type, and has the right name and categorization (“Other Punctuation”). But it looks wrong in most renderings, straight up and down and not curly. It’s kept that way for historical reasons.

U+2019 RIGHT SINGLE QUOTATION MARK is what most people use to get a curly apostrophe-looking thing. It works most places and is labelled in Unicode as “FINAL PUNCTUATION”. Which is half correct; it is punctuation. But also half wrong: apostrophe is not final. Also the Unicode character is actually a quote mark, not an apostrophe at all.

Some folks argue U+02BC MODIFIER LETTER APOSTROPHE is the right thing. But that’s the obscure choice. Also it has category “Modifier Letter” because it’s usually used as a letter, not punctuation.

I think U+2019 is the practical choice, ’, because that’s what most people do already. I assume it’s too late for Unicode to fix this by adding a proper apostrophe. The pedants probably think U+0027 is sufficient.

HTML

The most straightforward thing is just to embed the Unicode in UTF-8. That should be fine in 2023.

The older thing most people do is use Unicode entities so the output is ASCII with HTML encoding. For some reason those tend to be decimal, so you get ’ for apostrophe and “ and ” for double quotes. (Hilarious; I’d typed the entities for 8220, 8221, and 8217 in my Wordpress editor. When I came back what I typed was replaced by the actual glyphs.)

The W3C has a page from 2015 with different advice. It suggests named entities, using &ldquo; and &rdquo; for double quotes, and &rsquo; for apostrophe. There are also &apos; and &quot; entities which presumably are to be avoided.

Automatic conversion and Markdown

I’m lazy and want to type ASCII straight ’ or ” and have software convert them to proper quotes. “Smart Quotes”. It’s important to do this in a way that’s aware of HTML markup; you don’t want to be replacing ” in URLs, code fragments, etc.

The CommonMark spec doesn’t seem to say anything about typographer’s quotes. All their test cases replace ASCII ” with HTML entity &quot; but I’m not clear why, or if the spec demands it. Some sort of escaping safety thing I guess? It’s awkward IMHO. This discussion says the reference implementation does some smart quotes but it’s not part of the spec.

In the ancient days we used “SmartyPants” to do a typographic conversion for us. There’s a modernish Python implementation that seems to work. It uses 8217, 8220, and 8221. Good enough for me! But it’s awkward to plug in to other markdown frameworks, in particular smartypants is re-parsing the input and it’d be nice to skip that.

Despite that mistletoe + smartypants works fine.

mistune and marko do not work with smartypants. Both seem to be converting ” into &quot; like CommonMark’s demo tool does and smartypants won’t pick that up and replace them with 8220/8221.

The old pre-CommonMark Python markdown library has an extension called “SmartyPants”. It seems to be emitting named entities like &ldquo;. It doesn’t do apostrophes?

The Markdown-it-py extension has typographic components for quotes and apostrophes. This seems to work well and as a bonus emits actual UTF-8 for the Unicode themselves, not ASCII escapes. I’m not afraid of UTF-8. That may be enough to get me to use Markdown-it-py!

GNU cut breaks on UTF-8

cut is a very simple shell util; it will take a few characters or fields out of its input. cut -c 10-20 for instance should output characters 10-20 on every line.

Except hahahaha joke’s on you, despite being called --characters and there being a separate --bytes flag, they both actually operate on bytes. No matter what your locale is. This completely breaks UTF-8 input; it does not treat them as characters.

This behavior is not disclosed in the cut --help docs, nor in man cut on my Ubuntu system. It is documented in info cut, the obsolete doc tool rms failed to foist on the world 25+ years ago. There it says:

Select for printing only the characters in positions listed in CHARACTER-LIST. The same as ‘-b’ for now, but internationalization will change that.

There’s a good Stack answer from 2014 explaining all this. I even understand why the GNU tool does this, it’s as much POSIX’ fault as GNU’s. But you’d think in the intervening 9 years they could at least improve the docs.

Here’s a 2006 bug report documenting the same problem. I would not be surprised if the bug goes back to the 90s, predating the adoption of UTF-8 everywhere.

Live reloading HTTP servers

Pressing reload in a browser while developing a web page is for chumps! A very popular trick is to serve the site under development with a special server and put a little Javascript in the page to get a reload signal when it should reload. Saves a lot of time, I love live previews.

five-server is the most mature tool for this I could find. It’s written in Node but you can run it as a standalone server unconnected to the code you’re developing. This is a fork of an older live-server that was abandoned. There’s a VS.Code version too that has some integration that looks useful if you’re editing HTML files.

LiveReload is a Python server to do the same thing. It has a Python API so you can integrate it with your own Python code to help while developing a webapp. I hit a confusing problem because of less-than-robust error handling related to my malformed HTML input (the script injection failed) but it seems to work well.

There must be a zillion other tools that do the same thing.

Markdown processing in Python

I’m mad enough about Hugo I spent an hour writing a very minimal blog engine. Lots to go to make it usable, but as a piece of it I had to look for a Markdown processor for Python. Here’s what I’ve found, there are probably more. I want something that supports CommonMark and has a decent extension story. (A lot of folks support GitHub flavored markdown, perhaps that’s coherent enough to also be reasonable.)

mistletoe. 652 GitHub stars. I’ve used this already and it works but haven’t gotten in deep. Docs and PyPI niceties are not great. Says it’s the fastest implementation but all of these are pretty close (except Mistune which is way faster). Supports rendering to other targets like LaTeX, not just HTML.

markdown-it-py. 517 GitHub stars. Looks comprehensive, has a bunch of plugins. It’s a port from NodeJS code. Plugin code looks pretty complicated.

mdformat. 263 stars. Has plugins and code is connected somehow to markdown-it.

marko. 249 stars. Says it has very easy plugins and is not very fast but correct.

Mistune. 2300 stars. Not CommonMark but maybe reasonably so. Very fast. Plugins look awkward.

Not CommonMark: Markdown, Markdown2,

No real conclusion here. I’ll stick with mistletoe since I already have it working, then look to jump when I get to the part where I need my own plugins. marko or Mistune look most promising to me if mistletoe won’t work.

Update: some very simple evaluation

I did some quick tests comparing mistletoe, marko, markdown_it, and Mistune.

The output of all three were substantially similar. mistletoe emits actual ” ASCII quotes whereas the other two are outputing &quot;. Which reminds me I need to enable typographic quotes.

Some very simple benchmarks show mistletoe and markdown_it takes 2-3x as long as mistune, marko is about 4x.
timeit 9000 byte input: mistune (1.13ms), markdown_it (2.78ms), mistletoe (3.60ms), marko (4.84ms)
1800 HTML posts: mistune (490ms), mistletoe (860ms), markdown_it (925ms), marko (2000ms)

Update 2: markdown_it

After reading docs and setting up typographical quotes I think I’ll go with markdown_it. I was turned off at first because it was a NodeJS port and its code seems quite complicated, they really want to explore details of parsers, ASTs, renderers to you. But it does typographical quotes right! And it’s fast and popular. Now that I’m over the learning hump it seems a good choice. I haven’t tried writing a plugin for it yet though.

Some new Hugo learnings

I’m once again trying to port my ancient Blosxom blog to a static engine. Focusing on Hugo this time. I no longer care which engine I use, just want to use one, and the most popular one is probably a good choice. I am adamant that I have to write my own theme, collection of templates and layouts and stuff. I want complete control over site layout and page contents.

Most tutorials are toys that never talk about pagination. Many have a default home page of “all your posts”. This seems to be for crummy marketing sites with 3 pieces of content and are not useful for a real blog with 1000+ posts. Pagination is a whole complex topic I don’t understand yet.

A lightbulb went off when I looked at this classless-blog Hugo theme. It has no Javascript. It produces really simple semantic HTML with no CSS classes, just clean tags like <header> or <main>. You can then change how the page looks with pure CSS, perhaps starting with one of these classless CSS resets. That is the One True Way to web development, IMHO, at least for simple static textual content. I’m glad to see a clear path to doing it in Hugo. (Seriously, people are stuffing React into Hugo blogs? Ugh.) Unfortunately the classless-blog theme isn’t really suitable for me to just use (it doesn’t have the right structure for me) but I can steal a lot of ideas from it.

As for writing my own theme, I’m finding this tutorial really helpful. It’s from 2020, so a little out of date, but mostly good.

The tutorial neglects to mention at the start that you have to set the theme= in your configuration TOML. That file recently got renamed from config.toml to hugo.toml. Fun fact; if you don’t set that variable, Hugo throws an opaque error message.

WARN found no layout file for “html” for kind “home”: You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

What that error really means is “theme not found so you have no layouts at all for your blog”. It’d sure be nice if the tool caught this simple beginner’s error.

Hugo themes are programmed in Go template languages. Last time I encountered this I got mad but I read the excellent Go docs and now understand it’s pretty simple with just a few control flow items. The weird thing is some syntax like {{if}} are genuine control flow things, others like {{printf}} are more like function calls. Also there’s a {{define}} which creates new functions. The confusing part about Hugo templates is the implicit context hidden in . the cursor and how {{range}} is a looping construct. Also it’s still not clear how often templates are invoked. But...

Hugo has a concept of “Kinds”. These are the various sorts of pages that Hugo will create as it runs and it’s a little confusing and poorly documented. The docs here for .Kind are the most explicit I could find.

The page’s kind. Possible return values are page, home, section, taxonomy, or term. Note that there are also RSS, sitemap, robotsTXT, and 404 kinds, but these are only available during the rendering of each of these respective page’s kind and therefore not available in any of the Pages collections.

Each of these kinds is in turn instantiated by a template file. Hugo will look in many places for the template for a kind, with up to 46(!) different paths. The template lookup order docs are essential for understanding this.

It’d be nice if Hugo had a debug mode which printed every HTML page it created, why (what kind maybe?), and every template that was used to create that. That’d really help understanding what the generator is actually doing. I did find hugo --printUnusedTemplates useful for at least finding when template files weren’t being used.

Global Starlink outage for hours

There was a major outage yesterday across all of the Starlink ISP. Mine went down at 4:38pm California time. I don’t know when it came back (I swapped to my backup Internet.) This article says Starlink acknowledged the problem via a tweet at 5:33pm and that it was fixed at 6:33pm. So that’s two hours, with an hour to acknowledge the problem. Comcastic!

Starlink has no public monitoring page, no online status. There’s nowhere to go to find out what’s happening. Hour late tweets are not sufficient. DownDetector was surprisingly useful but all that does is count how many people are clicking a button that says “something is wrong”. Better than nothing but it’d be nice if Starlink did something real.

I continue to be mostly happy with Starlink service, particularly since the improvement early this year. I respect the complexity of what they’re doing with a satellite network. But some aspects of the product are not very good, particularly customer contact. I’m just grateful I’ve never needed to do a real support request; the experiences reported on Reddit vary wildly.

Python venv brittleness (with fix?)

I just upgraded from Ubuntu 22.10 to 23.04. Which means I upgraded from Python 3.10 to 3.11. Which means all my old Python programs don’t work anymore. Because each has a virtual environment and the venv is hardcoded to Python 3.10.

Am I doing it wrong? Yes, I was doing it wrong.

In the old days I’d create a venv with a command like python3.10 -m venv venv. This results in a venv/bin directory where python3 is a symlink to python3.10 in the same directory, which in turn is a symlink to /usr/bin/python3.10 (which no longer exists).

Awhile back I changed to running python3 -m venv venv. This results in all the binaries in venv/bin being symlinks to python3, which in turn is a symlink to /usr/bin/python3. That should be robust to upgrades. And Python is good about backward compatibility so using 3.11 to run a venv built for 3.10 should mostly be fine.

FWIW the docs just have you invoking python on the command line, so I guess that’s what the intended usage was. More generally it looks like venv is doing its best to set up an environment with the exact same Python pathname you used to create the environment, which seems reasonable enough.

Cronometer tech details: data accuracy

I switched from MyFitnessPal to Cronometer for tracking the calories in the food I eat. It’s a good food diary. Need more time using it but I plan to write a happy review on my main blog. A key advantage in Cronometer is its data is accurate. Some technical notes on details of that:

They use carefully vetted data sources. Most food trackers advertise “14 million foods!” but 13.9M of those are wrong or incomplete data. Cronometer has a core database of 30,000 foods from reliable sources. Most of my entries are coming from the NCCDB, a commercial database with an academic connection. Cronometer also has a broader set of data from commercial sources and the user community but these are clearly labelled as less accurate.

A related advantage is Cronometer has pretty good search ranking. When I type “milk” the top 2 results are “whole milk” and “2% milk”, both from the NCCDB. Good authoritative data. I’m finding mostly generics there too, not brand names which are just unnecessary extra choices for staple items.

Cronometer also shows data confidence scores on its summary statistics like how many calories or how much Vitamin C you ate for the day. Most of my scores are 100% or 90%. It’s a pretty broad accuracy number, mostly they’re just accounting for incomplete entries in the database. But it’s a thoughtful touch.

OTOH they also show calories to a ridiculous level of precision. It tells me the 1 tablespoon of butter I put on my toast had 101.72 calories in it, as if I measured that tablespoon to 5 significant digits and butter never varied. It’s weird they don’t just round to the nearest integer. Most of the UI is very good, this is a rare mistake.

MyFitnessPal data exfiltration

I’m mad about the food tracking app MyFitnessPal for various reasons, it’s a badly designed product. But I’ve been a user of it for a long time and I’d like to get a copy of all the data I laboriously entered. They won’t give it to me.

MFP has a data export feature. But it requires you pay an eye-watering $20/mo to get access to it and it seems limited to exporting 90 days of data.

They have a basic report feature that will show you a graph of calories consumed by day for the last 90 days. That’s the main thing I care about although it’s nowhere near complete. Anyway that’s backed by an XHR for the URL https://www.myfitnesspal.com/api/services/reports/results/nutrition/Calories/90?report_name=Calories which gives you a simple JSON time series. Unfortunately changing that “90” to “365” or “180” results in a server error (after a long delay) so I don’t think you can trick it into giving you more data.

They also have a printable diary report type which gives you line items for every food item you’ve entered. There’s no limit in the UI on how long that report goes for, but the webapp seems to error out (after a long delay) if you get more than about a month of data. Perhaps scanning more than 500 rows in a database is too much Big Data for their system architecture. That data is coming from a POST XHR to https://www.myfitnesspal.com/api/services/diary/report and you can capture a detailed JSON response in browser developer tools. I was able to use this to tediously get my data a month at a time.

I couldn’t find an easy way to get the recipes, meals, etc I’d custom created for myself. I don’t really use those features much so I didn’t try very hard. There’s a lot of other data they collect too, it’d sure be nice to have a comprehensive “download all data” option for what is, essentially, a data recording app.

Eufy RTSP stream

I have a Eufy IP camera, a cheap $35 Security Solo IndoorCam C24. It does support RTSP but it’s not easy.

To get it working, I had to use the mobile app and get to the settings for the camera. Then open General / Storage / NAS (RTSP). The setup flow talks all about a Synology NAS which is confusing, the docs say that’s all that’s supported. But really what they mean is the Synology RTSP client is the only one they want to answer questions about; it seems to work with any RTSP client, including VLC.

Anyway, you go through the flow and the end result is you are given a stream link. It’s of the form rtsp://username:password@192.168.###.###/live0. It generates a random username and password and claims it’s doing digest security.

RTSP support seems hit or miss with Eufy. Not clear which all devices have. Also they’ve disabled or broken it in the recent past, judging by Reddit discussions. Maybe in response to one of their many security disasters. Anywat this particular “Indoor Cam 2K” works, with firmware version 2.1.8.7.

Eufy apparently does not support Onvif.

Also Eufy is a bad product and should probably be avoided. They were recently caught sending images to the cloud even when the camera was explicitly configured not to do that. That’s not just an honest security mistake, that’s some product manager making a decision to harm their users. It speaks badly of the company. Too bad, it’s an Anker product and works pretty well. I generally like Anker!

YouTube TV vs geolocation

YouTube TV needs to know your home location to decide whether you have the right to watch local TV channels, also sports broadcasts. It’s an awkward impedance mismatch between the global Internet and 1920s business models born from the radio era. Anyway, the tech is a PITA for me.

Summary: sometimes you might have to log in and manually press an “update my home area” button. I do this from my phone when I’m really physically in that area, because the phone geolocation works.

Update (July 2024): just had to do this again and it was more complicated than I remember.

  • Try to watch YT TV in my desktop browser, get the error about location
  • Open YT TV app on phone
  • Tap little portrait of me in upper right
  • Click “Location” in my Account
  • Click “Update” for “Current playback area”, even though it shows the right area already
  • It says “updating...” and then “you have successfully updated...”
  • Desktop browser can watch the show again

In detail.. My home metro is the Sacramento area, where Grass Valley is. That is the main place I watch TV, where I live. But I do travel and also spend a fair amount of time in San Francisco. I always want YouTube TV to treat me as a Sacramento metro resident. This all should be in line with YouTube TV’s policies, in particular you are allowed to travel and watch shows from home as long as you log in from home every 3 months.

The problem is the main device I watch YouTube TV on in Grass Valley (a Roku TCL TV) is using Starlink. And Starlink’s IP addresses make me look like I’m in Los Angeles. So YouTube TV never sees me logging in from what it thinks is Sacramento. It’s really stupid and a great example of why IP based geolocation is a bad idea.

The easy work around has been to watch YouTube TV from my cell phone from time to time. The phone app seems to use the phone’s actual location, not the IP address, and all is well.

Apparently I forgot to do that and the app on a Roku in San Francisco refused to show anything until I logged in again from my home area. Same thing happening here in my web browser. Everything locked.

Finally on the phone I found a way to set my home area. It was almost like I had to set it up again, manually pressing a button saying “yes I really am home now” (in Grass Valley). Once I did that my account was unlocked and all the other devices worked again with Sacramento as my home area.

What a stupid farce.

(Coincidentally, just yesterday I set up my desktop computer to spoof my location so I look like I am where I really am in Grass Valley, despite the Starlink IP being in LA. Somehow that didn’t seem to work with Youtube TV. Maybe just a cache problem, or maybe they get upset if the IP location doesn’t match the browser geolocation? My impression is YouTube TV is doing the minimum to comply with licensing requirements and is not too worried about catching dastardly people who spoof their locations, but who knows.)

You know what videos I have that don’t have georestrictions? The pirated ones. Once again the illegal option is a better user experience.

What my phone was talking to

After setting up some monitoring I’ve got some data on a little over 2 days of Android phone activity. But I don’t really know what’s going on with my phone other than it’s a lot.

The phone is a Pixel Phone, nothing extraordinary, not used often. I do have a couple of background things running (Syncthing and GPSLogger). Mostly I’m curious why so many apps are sending network traffic every few hours. So I set up NextDNS and Netguard to learn more. Honestly, I didn’t learn much from this exercise. But here’s what I got.

NextDNS Analytics shows 18,000 queries, 35% of which were blocked for being trackers / ad related.

Top domains blocked were for Braze, Urban Airship, Optimizely, Crashlytics, Twilio Segment, and Google Analytics. Ie: all basic user surveillance, ordinary marketing bullshit.

Top unexplained domains allowed were Google SUPL (a location thing), federatedml-pa.googleapis.com, youtubei.googleapis.com, play.googleapis.com, and firebaseremoteconfig.googleapis.com. Guessing these are all related to Google services that are part of Android OS. (A whole lot of network connections go to 1e100.net addresses but all that tells me is they’re hosted by Google.)

Netguard is showing me a lot of my apps wake up and do a little network stuff every few hours, despite me not actively using them. For instance Amazon Music (which I haven’t used in weeks) wakes up once an hour and makes several network connections totalling 1-2MB. Once an hour! What the hell? I deleted that app.

Other apps seem to connect only once a day and some (like HSBC’s banking apps) don’t connect at all. Despite being apps I do use regularly. Presumably some are suppressed because Android identified them as unused and deprioritized them. I’ll note that many open source apps seem better behaved. And shout out to the apps that have “no Internet permission”, typically apps that don’t need them.

I have a theory that a lot of this sparse traffic is basic app telemetry. For instance it looks like Grindr is firing off requests to Crashlytics, Google Analytics, and Scorecard Research. (And also its own DNS-over-TLS queries once it figures out I’ve blocked those on the system level.) Remarkably the other gay dating app I have installed, Growlr, seems to make no queries at all when not used.

There’s an interesting splodge of queries at 2023-08-29T20:45. It’s plausible that’s when I unlocked my phone, I could imagine a bunch of apps taking advantage of the device waking up to phone home.

One last tool I tried is Google’s “Non-carrier data usage” report; that shows you app data usage for a month. But most of that is stuff I did on purpose, like reading a newspaper. Just about 20GB for a month. The first surprise on the list is Tapet, an app that makes random background images; that comes in at 172MB. I do use that app (and love it!) but none of its features are networked, so where’s the data going? I couldn’t figure it out, although their privacy policy suggests usage surveillance. Amazon Music is up there at 42MB. A blood pressure monitor app I barely use is at 39MB. Etc.

Bottom line, I didn’t learn much. Honestly trying to figure out what’s going on with these limited tools is difficult. Netguard has the ability to capture full traffic in PCAP files but trying to comb through those sounds like a nightmare, especially since it’s almost all SSL.

There’s definitely a cost to keeping old apps installed on your phone. Even if you never use them they still wake up and do stuff on the network.

Update: Android has some guidance on excessive mobile network usage in background. “Android vitals considers background network usage excessive when an app is sending and receiving a combined total of 50 MB per day while running in the background.” This page seems mostly concerned about battery consumption, not bandwidth.

Google APIs

One interesting bit of data from the DNS logs are various Google API queries. It’d be interesting to know what all of these services are; like what’s geller-pa?

228 crashlyticsreports-pa.googleapis.com
218 youtubei.googleapis.com
218 federatedml-pa.googleapis.com
180 play.googleapis.com
157 firebaseremoteconfig.googleapis.com
141 android.googleapis.com
130 firebaseinstallations.googleapis.com
114 play-fe.googleapis.com
107 androidattestationvalidation-pa.googleapis.com
100 googlehomefoyer-pa.googleapis.com
90 http://www.googleapis.com
79 notifications-pa.googleapis.com
76 android-context-data.googleapis.com
70 userlocation.googleapis.com
60 geller-pa.googleapis.com
39 telephonyspamprotect-pa.googleapis.com
37 translate-pa.googleapis.com
36 update.googleapis.com
36 paperwork-pa.googleapis.com
36 firestore.googleapis.com

Top Domains

And here’s the top domains overall by DNS queries (count is number of queries, not overall traffic).

588 sdk.iad-06.braze.com
548 device-api.urbanairship.com
400 logx.optimizely.com
386 firebase-settings.crashlytics.com
384 api.segment.io
377 ssl.google-analytics.com
265 supl.google.com
228 crashlyticsreports-pa.googleapis.com
218 youtubei.googleapis.com
218 federatedml-pa.googleapis.com
188 discovery-v6.syncthing.net
180 play.googleapis.com
172 googleads.g.doubleclick.net
157 firebaseremoteconfig.googleapis.com
154 app.rain-alarm.com
151 device-metrics-us.amazon.com
143 static.withings.com
141 discovery.syncthing.net
141 android.googleapis.com
140 g.whatsapp.net
136 meta.wikimedia.org
132 rest.locuslabs.com
131 prod.rudderstack.withings.net
130 firebaseinstallations.googleapis.com
129 clients4.google.com
128 remote-data.urbanairship.com
126 graph.facebook.com
122 slack.com
120 http://www.googletagmanager.com
120 api.pocketcasts.com
119 clients3.google.com
118 http://www.googleadservices.com
118 ad.doubleclick.net
117 msh.amazon.com
114 sb.scorecardresearch.com
114 play-fe.googleapis.com
114 discovery-v4.syncthing.net
111 i.ytimg.com
111 assets.adobedtm.com
111 api.amazon.com

Faking geolocation in Chrome

I finally found a good extension for controlling browser geolocation: location-guard. It’s open source, works in multiple browsers, and has some smart features. This replaces my old config hack for Firefox on my desktop computer and I’m mostly using it to work around Starlink’s geolocation limitations.

Update July 2025: no one ported Location Guard to MV3 so Google has now broken it. I’m using Cloaq instead. It’s not quite as fancy but seems to do the job. However read the notes about their use of the debugger API and having to launch Chrome with a shortcut. Nuisance!

Update April 2026: I’m using this Location Guard (V3) now. It’s on GitHub here but I didn’t verify that the version from the Chrome web store matches that code.

I used this site to test it (although it bugged out on me once...) Probably this test site is better, it has more diagnostic detail. The Chrome permissions at chrome://settings/content/location are also worth examining.

It’s important to me this type of extension be open source. The extension has to have permission to access all websites and all data, so it takes a lot of trust to run it. And this kind of extension has a bad history of being bought and subverted (see also: the sad Hover Zoom story.)

Location Guard works by overriding the geolocation API in the browser Javascript. It’s pretty clever about it. By default Location Guard adds 500 meters of random noise to your current location. It keeps a cache of the location it gives to the site for 30 minutes so you don’t appear to be jumping around randomly. It also updates the accuracy data on the reply to indicate the location is not precise.

I worry that this kind of randomization is not really great, that if a site collects enough samples they can average away the noise. I’ve always thought it was better to just truncate coordinates. But in practice it’s probably good enough for most sites. Also I could be entirely wrong about this, the FAQ references some academic research about why this particular kind of Laplacian noise works.

But I won’t want to fuzz my location, I want to appear 400 miles away. For that I use Fixed Location. There’s a confusing option to that: “Fixed location disables geolocation. warning: this also disables the permission dialog”. I’m running with that turned off, because I definitely want to get a notification if a site is trying to geolocate me. The relevant code is here. It seems to work to let you still deny location permission if you want.

Note if you’re testing this be sure to use the extension option to delete local cache as needed.

What is my phone talking to?

Trying to figure out what all on the network my Android phone is doing. Two avenues.

One is using NextDNS as a private DNS server. I’ve been doing this for a year+ as an ad blocking measure. It provides logs and some high level analytics for DNS traffic. I don’t love messing with DNS but they did a great job on this service. NextDNS shows me info about where my phone is connecting to, but not specifically which app. Also it’s skewed a bit by caching since it’s only DNS queries, not network connections. Anyway it already got me to remove TikTok (I hadn’t used it in a month and it was making 3 queries a minute). I’ve also learned about braze.com, some surveillance system that is happily being blocked.

NextDNS analytics

The other is using NetGuard, an open source app firewall. It works by being a locally hosted VPN. It’s main use is to block network to individual apps (like, say, TikTok). But it has some auditing capabilities, albeit with awkward UI. I currently have it allowing all connections but displaying notifications for new ones. Which is pretty noisy but is giving me a view of what’s happening on my phone. Syncthing is sure chatty! And I’m wondering WTF Uber and WhatsApp are doing consuming data when I’m not using them (it should not be polling for notifications.) There’s also a detailed log view and it will even export PCAP if you really want to get into the data.

Product desire

What I really want is a per-app audit of network activity with drill-down to see details. But the main view is just a scoreboard. One row per app, sortable by bandwidth and # of connections and the like. Just a passive monitor, no filtering needed. I’ve wanted something like this for 20+ years on every computer and router I’ve owned and am always disappointed.

Starlink publishes performance maps

This is really great; Starlink is publishing performance metrics on a map. Download, upload, and latency. Per-state in the US, per-country in smaller places. “Metrics range from 20th to 80th percentile for the “Standard” service plan only, during local peak hours, and are refreshed monthly. Map coloring is based on the median for each metric”. That’s pretty useful and way better than I’ve seen any other ISP do.

Download speeds, darker is slower

In California they report 44–139 Mbps down, 8–17 up, and 39–52ms latency. That’s pretty well in line with what I measure (over the whole day, not just peak hours). My latency at 51ms is on the worse edge of that.

Not sure I can draw many conclusions from the map coloring. Some broad regional patterns, but nothing specific. The per-state binning is pretty coarse.

Some random home-scale LLM facts

I’ve been learning a lot about small-scale LLM models running on your desktop by reading /r/localllama. None of this is novel, just absorbing common wisdom. I’m linking to some sources but these are by no means authoritative, just useful for feels.

  • They tend to talk about models in terms of number of parameters.
  • LLaMa 2, which many models are derived from, comes in 7B, 13B, and 70B sizes. 70B means 70 billion 16 bit weights. They were trained on 2 trillion tokens as input.
  • Number of parameters dictates memory needed. LLaMa 2’s 70B is 140GB. But folks often downsample to 4 bits when running them so it’s just 35GB. (Or less?)
  • Desktop CPU RAM is fairly cheap (up to 128GB), but VRAM is expensive if you’re running on a GPU. The most expensive gamer GPU (an NVidia 4090 at ~$2000) has 24GB of VRAM.
  • You can also chain multiple cheaper GPUs to get more total VRAM. Beware a single 3090 takes three motherboard slots, so you need a special motherboard and case to have room for two.
  • Specialty AI chips like the A100 or H100 support 40-100ish GB per GPU.
  • 70B is said to be enough to approach ChatGPT 4.0 levels of quality but I have my doubts.
  • The GPT4All models I’m running just on my CPU with GPT4All are 6-13B.
  • GPT4All uses GGML / llama.cpp to run things. it has various quantizing algorithms, it’s not just “truncate the lower bits”. That driver targets 4, 5, and 8 bit integer quantization.
  • GGML can offload part of the model to run on the GPU and use CPU for the rest. This lets you run bigger models than can fit just on the GPU.
  • This discussion about folks running LLMs on an NVidia 4090 with an Intel i9 is interesting. That’s the highest end reasonable home hardware, maybe $4000ish for a full system? They talk about running 70B models at speeds of 1-2 tokens / second. Which is not fast but maybe acceptable for an interactive session.

Update

Some new facts:

  • Running a 70B model (at 4 bit quant?) at home takes 48GB of VRAM. Folks are using two high end GPUs like 3090s or 4090s. Talk of generating ~15 tokens / second. At the low end, two Tesla P40s will work and are cheap.
  • Running on your own leased cloud computer is totally reasonable. See this discussion and this one. It may cost about $1500 a year to lease, compared to $4000+ to buy hardware.
  • Inference can use up to 700W of GPU, Call it 100W for the computer and you get to about 35¢ an hour just for PG&E electricity. OTOH in casual use you’re not running inference full-out, so actual power will be much less.
  • RunPod keeps coming up in discussions about cloud providers.
  • Folks say it costs about 60¢ an hour to run a 70B model on a cloud server. Apparently this can be done for a single user without too much drama. Scaling that up to 100+ is going to run into availability problems.

task-spooler

This Hacker News discussion taught me about a great new-to-me tool: Duc Nguyen’s task-spooler. It lets you queue up a set of jobs on a Linux box and have them run in parallel in the background. It’s available in Ubuntu and has the shell command tsp.

I’ve used GNU Parallel before for this and it’s great but the model there is you run one big command and the jobs run in parallel all together. The queueing interface in task-spooler means you can keep throwing work at the system and it gets done eventually. Task queues are one of the great computing paradigms IMHO, along with event publish/subscribe.

The interface is very easy. You run tsp command to enqueue a new command, it returns immediately. It sets up a background process to run the command if there isn’t already one and puts the job on the queue. The default parallelism is only 1; you can run tsp -S 4 if you want to run 4 jobs in parallel. Output is written to files in /tmp by default.

There’s more complex commands for querying job status, etc. There’s minimal support for more complex queue management. including options for “wait for a job” and “the job will be run only if the job of given id ends well”. I wouldn’t use this to replace a complex task queue system but it’s nice to have those basics available.

$ tsp -K
$ ps xu | grep tsp
nelson    3983  0.0  0.0   6304   652 pts/0    S+   11:45   0:00 grep tsp

$ tsp sh -c "sleep 1; date"
0
$ tsp
ID   State      Output               E-Level  Times(r/u/s)   Command [run=0/1]
0    finished   /tmp/ts-out.H7AJLG   0        1.00/0.00/0.00 sh -c sleep 1; date
$ cat /tmp/ts-out.H7AJLG
Mon 21 Aug 2023 11:45:47 AM PDT

$ !ps
ps xu | grep tsp
nelson    3985  0.0  0.0   2548    84 ?        Ss   11:45   0:00 tsp sh -c sleep 1; date
nelson    3999  0.0  0.0   6304   648 pts/0    S+   11:46   0:00 grep tsp

$ tsp -K
$ tsp -S 3
$ date; for i in {1..6}; do tsp sh -c "sleep 5; date"; done
Mon 21 Aug 2023 11:54:10 AM PDT
0
1
2
3
4
5

$ tsp
ID   State      Output               E-Level  Times(r/u/s)   Command [run=3/3]
0    running    /tmp/ts-out.Ifxnc9                           sh -c sleep 5; date
1    running    /tmp/ts-out.estpmo                           sh -c sleep 5; date
2    running    /tmp/ts-out.vDtaPG                           sh -c sleep 5; date
3    queued     (file)                                       sh -c sleep 5; date
4    queued     (file)                                       sh -c sleep 5; date
5    queued     (file)                                       sh -c sleep 5; date

$ tsp
ID   State      Output               E-Level  Times(r/u/s)   Command [run=3/3]
3    running    /tmp/ts-out.IgWMfx                           sh -c sleep 5; date
4    running    /tmp/ts-out.tSSCYL                           sh -c sleep 5; date
5    running    /tmp/ts-out.j003cY                           sh -c sleep 5; date
0    finished   /tmp/ts-out.Ifxnc9   0        5.00/0.00/0.00 sh -c sleep 5; date
1    finished   /tmp/ts-out.estpmo   0        5.00/0.00/0.00 sh -c sleep 5; date
2    finished   /tmp/ts-out.vDtaPG   0        5.00/0.00/0.00 sh -c sleep 5; date
$ tsp -t

Mon 21 Aug 2023 11:54:20 AM PDT

Starlink vs Hurricane Hilary

I’m wondering if Starlink service was affected by the hurricane? I’m in Grass Valley where we got some clouds but no significant rain. But my packets are routed through Los Angeles. I don’t know if that’s entirely in space or if they go to earth in some invisible relay closer to me, but LA is definitely where the packets first appear in traceroutes.

Anyway, coincidentally I noticed an unusual service degradation yesterday around 9am to 6pm, about when the storm was passing through. Sort of? It’s not exactly time-correlated but The effect was worst around 4pm. Hurricane Hilary passed closest to Los Angeles at just about that same time.

Honestly I thought it was congestion-related but the effect is much larger than usual. Packet loss went up to 4% (typically 1%), round trip time up to 100ms (typically 50ms). Speed tests don’t show anything obvious, maybe throughput is a little worse.

It’s plausible there’d be an effect. The satellites are well above any weather but I’ve seen rain fade impact signal quality in the past when I’ve had strong local storms. (By far the biggest risk of hurricanes is the wind and your local antenna mount.)

There’s a discussion of a related observation on Reddit.

Here’s a graph of the last two days.

Starlink detailed timings

Over on Reddit user panuvic is posting a series of interesting timing graphs from Starlink packets. Most recent post here. I have no idea who this is or what they’re doing but it’s very interesting. Some of their posts make it sound like they’re measuring with independent radio gear listening in on the transmissions.

Some things I noticed, using his graphs.

Above is a graph of round trip times over a few minutes. Handoffs to a new satellite are typically multiples of 15 seconds. What’s interesting is the highly variable latency between satellites, like 20-70ms. That’s way more time than can be accounted for by radio propagation delay and physical distance. Maybe it’s queueing, some satellites are busier than others?

This is handoffs for two different locations. The two graphs are synced in time. If you look closely, so are the handoffs. They both occur at the same second, despite being two completely different installs at different locations 2400 miles apart. Isn’t that strange? I’ve heard other people speculate that every Starlink dish in the world schedules handoffs at 12, 27, 42, and 57 seconds after the minute. That seems wild to me!

Graphs of latency measured asymmetrically; bottom graph is one way delay from the Internet to the customer, middle is one way from the customer to the Internet, and top is two way. What’s interesting here is the banding in the receive timings, it looks like 4 or 5ms jumps in latency. I’m wondering if that’s some sort of time division multiplexing in action. Miss your transmit window on the satellite and have to wait for the next one?

Game streaming with GeForce Now

A couple of weeks ago I tried streaming a game to my Chromebook via GeForce Now. It worked surprisingly well in some ways but the video quality was bad enough it wasn’t much fun.

The main goal was playing Satisfactory (a first person game but slow, not twitchy) on my Chromebook. I paid for the Priority service, which gives you 1080p @60fps and a powerful enough server. It all worked OK and the experience was nearly seamless. But the video quality was awful. It’d constantly drop down to really blurry graphics. If I sat still and didn’t move the camera it’d look OK but the moment I moved it was awful.

I think it may have been the WiFi I was using. It was good WiFi and speed tests showed 50Mbps or more with low latency. But even good WiFi has some packet loss and that’s the enemy of quality. FWIW performance was better on my Windows machine wired to a fast gigabit fiber. Also pretty good for ethernet + Starlink. But good heavens if a streaming game service can’t work on good WiFi what’s the point?

I was able to improve things on the WiFi a bit by disabling “adjust for poor network conditions”. Before I did that the stream would regularly drop from 1080p as far down as 480p for a couple of seconds. It seemed to run much better locked to 1080p.

I don’t think it was the Chromebook; it looks bad on my gaming PC too. It’s possible paying $20 for the Ultimate service would help things. I’m fine with just 1080p@60 but maybe paying for a better server results in a better quality video stream?

Even on the fast ethernet networks the video compression quality is really weird. Here’s some screenshots comparing the same scene in three scenarios. (Click to enlarge, they are all lossless PNGs). 1080p on the native game (ie, perfect). Then the best picture I could get out of GeForce Now streaming. And finally the worst picture from GeForce Now. Captured by spinning the camera and snapping a photo. The game is not doing motion blurring, it should look sharp. These were all generated on my Windows gaming PC, GeForce Now running in Chrome.

That right image from GeForce Now is just unacceptable to me. And that’s what you see most of the time, when the camera is in motion. The middle one where GeForce Now is doing its best is also not great. I can only think that compressing a video stream at 60 fps with very low latency is hard and their streaming platform isn’t up to it.

FWIW the streaming client seems to use up to 30Mbps for the 1080p stream which suggests it’s very fast compression. There’s options for limiting the bitrate and I tinkered with those but mostly have left them unlimited.

Good things.. The latency is great, even with a 50ms+ lag from Starlink it feels very responsive. I didn’t try a twitchy shooter or anything but it felt like I was playing locally. The user experience is also very simple. It all runs in a browser and you can easily use your existing Steam library (including Steam Sync for save games). The free level is good enough you can see how it works but you definitely want to pay for the $10/mo premium for higher quality. (Not sure the $20/mo is worth the improvement, I didn’t try it.)

BTW there’s precious few docs. Press Ctrl-N for streaming performance stats and Ctrl-G for the GeForce Now settings.

I dunno, it’s remarkable this technology works at all. Game streaming has worked for over 12 years now! But somehow it’s never quite caught on. GeForce Now solves a lot of problems: easy to use, simple business model without some weird game subscription required. But the video quality was just not good enough, particularly on WiFi.

Running my own LLM

No original work here, just summarizing how astonishingly easy it is to install and run an LLM on your own computer using Simon Willison’s fantastic llm tool. Simon has been on an absolute tear with tooling for LLMs lately, amazing work. A bit hard to keep up but between his Mastodon feed and his blog I can sort of follow along. See his list of plugins for a sense of how broad the tool is.

I think this current moment in AI development is amazing and fascinating. And it’s great so many models can be downloaded for free experimentation. Simon’s tool makes this easily accessible.

Getting started

Here’s what I did to host my own LLM in just a few minutes:

  1. pip install llm
  2. llm install llm-gpt4all
  3. time llm -m orca-mini-3b ‘what is the capital of france’
    The capital city of France is Paris.
    real 0m2.337s user 0m7.701s sys 0m0.168s

That’s it, literally three commands. All automagic. The slowest part is downloading the 4GB of weights for Orca. Simon did a fantastic job with this tool. See the detailed docs or read on for my usage notes.

Technical details

llm was originally designed as a front-end for the OpenAI API but has a plugin architecture with lots of plugins. There are some other plugins for hosted models like Google Palm, Replicate, Claude. But I’m more interested in running the model locally. My example above uses llm-gpt4all, which downloads and runs GPT models downloadable in some standard format. (There’s some 13 models there, most are about 7GB big.) There’s also hosted plugins for Llama, MLC, and Mosaic.

I installed this on my year-old Linux server. It’s middle-of-the-road home system hardware, notably with no external GPU. So not a great match for AI but then I don’t have to sweat the details of making GPU access work on Linux. When running the GPT models they seem to be using 6 or 8 threads, which suggests they want real cores and not hyperthreads. Not sure how much RAM it uses; the docs say 4GB for the 1.8GB Orca model but I’m observing more like 1GB.

Performance of the smallest Orca model is fast enough on my CPU to be interactively usable; 2-3 seconds for short queries. Some others are significantly slower; I have to think a lot of these are designed to run on a GPU.

The main command is llm prompt for querying the LLM. It has a -c flag for an interactive session, similar to ChatGPT’s web interface. Otherwise each question starts from a blank slate.

Each model comes with a system prompt baked in that primes the LLM for your query. Ie “You are an AI assistant that follows instruction extremely well. Help as much as you can.” You can customize this; for instance Simon advises telling Llama “you are funny” if you want jokes.

Not sure where all LLM is storing its model files, they aren’t in the Python venv. Some of mine are in ~/.config/io.datasette.llm. Another place is ~/.cache/gpt4all. These model files are huge, often over 10GB each, so if your home directory is backed up over a network or something beware.

In summary, Simon’s LLM tool is a great frontend driver for various LLMs. It handles installing plugins to drive the models, downloading models themselves (for local hosting) and key management (for remotely hosted AIs). It also has some nice features for tracking your usage like llm logs for access to a database of your chat history.

Some model outputs

Some quick notes from me trying all the self-hosted models with the test query “what is the capital of france”. Note I tried several versions of LLaMA 2 using different llm plugins. All timings are based on using a simple Intel CPU; results should be much faster with a working GPU.

gpt4all results

These are all using the gpt4all plugin, which seems to run best on my system. All of these give a short output of “The capital city of France is Paris.” or something very similar.

  • orca-mini-3b. 2.4 seconds.
  • orca-mini-7b. 4.2s.
  • orca-mini-13b. 7.6s.
  • ggml-model-gpt4all-falcon-q4_0. 3.9 seconds.
  • wizardlm-13b-v1. 5s. (also uncensored).
  • nous-hermes-13b 5s.
  • GPT4All-13B-snoozy 5s.
  • llama-2-7b-chat. 10s

One reason these are so fast is the output is so short, presumably an artifact of how the LLM was set up by the plugin. (The prompt is “Human: {{{user input here}}}. Assistant:” If I ask orca-mini-3b “what is the capital of france and tell me a bit about it” it generates a full paragraph and takes 9 seconds instead of 2.6.

The capital city of France is Paris, also known as “The City of Lights”. It is located in the northern central part of France and is the country’s largest city with over 2.1 million people living there. Paris is famous for its iconic landmarks such as the Eiffel Tower, Notre-Dame Cathedral, the Louvre Museum, and the Arc de Triomphe. The city is also known for its fashion industry, art galleries, restaurants, cafes, and shopping centers. Paris is a popular tourist destination and attracts millions of visitors every year.

Other LLM plugins

The other plugins run slower, but that might be because they are giving larger outputs.

  • MLC llama-2-7b. 26 seconds. Something weird in htop, it doesn’t look like it’s using any CPU?!
    Thank you for asking! The capital of France is Paris. I’m glad you asked, as it’s a beautiful and vibrant city that offers a lot of interesting places to visit and things to do. If you have any other questions or need further assistance, feel free to ask!
  • llama-cpp llama-2-7b-chat.ggmlv3.q8_0. 22 seconds.
    The capital of France is Paris. It is located in the northern central part of the country and is known for its iconic landmarks such as the Eiffel Tower, Notre-Dame Cathedral, and the Louvre Museum.
  • mpt-30b. 75 seconds.
    The capital of France is Paris. It is located in the northern central part of the country and is known for its famous landmarks such as the Eiffel Tower, the Louvre Museum, and the Notre-Dame Cathedral. With a population of over 2 million people, Paris is one of the most populous cities in Europe. It is also known for its art, fashion, cuisine, and cultural heritage, making it one of the most popular tourist destinations in the world.

Specialist output

These models seem to be giving some unique output, not general chat.

  • gpt4all Bert (ggml-all-MiniLM-L6-v2-f16). 0.8s. I think it’s not intended for direct use.
    !!!!!!!!!!!!!!!!!!!...
  • gpt4all starcoderbase-7b-ggml. 34s. One of several models specifically for generating code.
    def get_capital(country): ...
  • gp5rall markov. 2.4s. This is a simple Markov chain as a demo of how to write a plugin, not a serious tool for use.
    is the capital of france france the capital of france what is the capital of france the capital of france...

Daily usage

Now when I want to ask an AI a question I’ll simply do llm 'my question here'. No more thought than that required, answers in about 10 seconds depending on the complexity.

I went ahead and ran llm models default wizardLM-13B-Uncensored to pick a specific default model. Why that one? Simon’s notes say Wizard is the best choice and it ran fast enough for me. Not sure what all the “uncensored” means but that seemed like a novelty I could try that’s not available at the online services. I suspect it isn’t adding anything of value though.

Mastodon Chrome extensions

I like Mastodon. But the mess which is cross-server following UI is really terrible. One bandaid for it is a browser extension. There’s a bunch of them. But the extensions have to have permission to modify data on all Internet sites, a potentially scary thing. Extension authors have definitely abused that power in the past. So my rule for this kind of thing now is it has to be open source.

There’s three open source Chrome extensions I found that make following cross-server easier.

  • Tootski (GitHub). This is the one I use. It works by adding a button to the awful “following users on Mastodon is a terrible experience” popup. It’s been a little flaky but does seem to work. Also ads a “share any page on Mastodon” button which I don’t need.
  • Mastodon Link. Obtrusive UI, so I skipped it.
  • Mastodon Profile Redirect. Two-step explicit process involving navigating to a web page at your instance.

Link to text fragment

I’ve noticed something since switching to Chrome: sometimes when I click on a search result some text is highlighted on the page. Turns out this is called text fragments. More docs here and a general interest article here or here. Th ey date to 2020 and work in all major browsers but Firefox.

For example searching Google for [coconut milk chicken marinade] leads an in-line “People also ask” result. Clicking that result leads to a special anchored URL that causes Chrome to navigate to and highlight the relevant result. It’s a way to make a deep link into a particular piece of a page, based on its text content, without the page having an explicit anchor to link to.

The text fragment link syntax is

https://example.com#:~:text=[prefix-,]textStart[,textEnd][,-suffix]

There’s a standards proposal here (and a W3C document) that talks about some subtleties. There’s escaping, of course. There’s an HTTP directive for a page to opt out of the behavior. The browser applies a :target CSS pseudo-class to let the site customize the highlight style. Also a little bit of Javascript API for the feature.

The syntax :~:text= made me wonder what other possibilities there were. MDN calls the :~: a “fragment directive” but so far text seems to be the only option. :~: was chosen because it wasn’t seen anywhere on the Web at the time the proposal was written.

Google released a browser extension to easily create text fragment links.

Update: see also fragmentations, an alternate proposal which just normalizes putting plaintext phrases in an anchor. The Mozilla folks seem to prefer that. I’m not sure any browsers really do anything for them; the implementations I’ve seen involve Javascript or an extension.

Towards a calmer Android home screen

I just completely changed how my Android devices look and couldn’t be happier. I switched from the usual “grid of random icons” to a clean monochrome look. I like the result, here’s screenshots from my phone and tablet. Edit after 6 weeks I like it even more. Read below for notes on how I did it.

Background: Tapet

The simplest part is the screen background, generated by Tapet. That’s an app that makes a new abstract image once an hour. It’s tweakable, I’ve set it to 60% Adaptive Dark and 10% Blur so the images are less distracting. (The pink screenshot is without the dark setting.) Tapet has been around a long time and is great. You can use it on its own without the other stuff. It’s free but it’s worth paying a few bucks for the premium unlock.

Launcher: Niagara

The big change; I switched from Pixel Launcher and Nova Launcher to Niagara Launcher. That’s a pretty major change to phone UI and I really like it. Niagara has you choose ~8 apps for the home screen (as seen above). Then the rest of the navigation is based on a really neat rolodex UI that lets you pick an app out of a list alphabetized by name. I’ve been launching apps by searching by name for years now; this picker is way better than typing the name!

Beyond that Niagara has a limited but thoughtful set of features to help you keep the home screen clean and minimal. Despite that it also packs in some great detail. See the text on Moshidon on the left screenshot? That’s an Android notification displayed inline in the launcher. There’s also a fancy “popup” feature that’s like folders but better, when I tap on News I get a nice popup of various news related apps.

Niagara is free or $10/year for the not-really-necessary Premium.

Icons: Pix Material You Light/Dark

Niagara can replace the app icons with an “icon pack”, something you download from the Google Play store. These packs contain thousands of icons, both specific ones like “Slack” and generic ones like “Video”. Niagara does a great job helping you use these icons. Google is encouraging all apps to provide a monochrome icon for Material Design but even after two years most of my apps don’t have them. The icon pack lets you override them.

The icon pack I’m using is Pix Material You Light/Dark. These are monochrome icons that adapt to the device theme (more on that below). It’s $2, well worth it. Another nice option is Whicons, all white icons (there’s a black version too), it’s free. I prefer the shapes of Pix but they’re both good.

Weather: Weawow

Niagara lets you have one widget visible on the home screen. I picked Weawow for weather. My first choice would be Windy but its widget is full of colors. Weawow has a nice simple monochrome widget that looks clean. (Does anyone make a weather widget that uses adaptive colors?)

Colors: Material You

Here’s the tricky part: the icons adapt to the colors on the background screen recently generated. See the pink cast to the app icons on the right that matches the pink background? That’s Material You design in action. The system picks a color based on your background screen and customizes all the UI to use that one color as a highlight. And it changes every hour. Subtle variety.

Niagara works well with Material You, most of its UI elements are themed to it. And it can re-color an icon pack to match the Material You color. Works great on my Pixel phone. Unfortunately Samsung chose to break Material You. As Niagara explains, “On Samsung devices the Material You palette consists by default only of shades of blue, no matter what wallpaper you have applied.” Samsung’s apparently really committed to their brand identity color. You can use the Samsung Theme Park app to edit it: it will still be stuck to one color, but at least that color can be white. That’s what I’ve done on the screenshot on the left.

Thoughts

I always feel guilty spending time customizing my environment, but I think it was worth it this time. I’ve got something that looks clean and fresh. And it shouldn’t require much updating or maintenance. I feel like Google is working its way to this kind of look in Android; the core concept I’m using is just an extension of their Material design. But the Niagara launcher is a pretty radical departure.

Update

I like this setup more and more as I use it. Niagara just launched a new version with “Anycons”, its own set of monochrome icons that can be recolored. They are very nicely drawn and it looks great, I’ve replaced the Pix icons. Unfortunately the Samsung bug is still there and still breaks the color detection, see more notes on that. Niagara now has a set of static options you can pick that look fine on most backgrounds, including a neutral white.

Linkblog architecture

I’ve seen some folks talking about setting up a new linkblog so I thought this would be a good time to document how my linkblog works. I’ve run this publication over nearly 20 years and am pretty happy with the current iteration. See also previous detailed posts.

Summary: I post links to pinboard. A cron job on my own server downloads the pinboard data to sqlite and renders static HTML, RSS/Atom, and Mastodon posts from it. There’s also some code for generating screenshots of the linked pages.

Simpler alternative

There’s no need for custom code or your own server. You can run a simple linkblog just using Pinboard or Raindrop. Those sites offer both an HTML view and a very functional RSS feed. There’s a bunch of services that will mirror RSS to social media like Mastodon; IFTTT, maybe Zapier. That’s how I ran my linkblog for many years.

My data model

My linkblog is a collection of posts. Each post has six elements:

  • URL of the page I’m linking
  • Short description
  • Extended description
  • Tags (including a +/- sentiment tag)
  • Date I made the post
  • Hash of the post

This is basically Pinboard’s schema, not an accident!

One thing I don’t have for each of my posts is a URL for my post itself. There’s no way to link to one linkblog post of mine. My RSS feed’s links don’t go to my own linkblog; they go directly to the page I’m linking. I think this is the defining feature of what a linkblog is but not everyone who linkblogs agrees. I have some detailed notes on what other linkblogs do.

The hash is a little strange; it’s something Pinboard generates, a 32 character string. I use it in places where I need something unique for each link I blogged like the ID for each Atom feed entry or the URL for an image preview.

Posting a new link

When I want to post a new link I use the Pinboard Plus extension in my browser. Really any way to create a Pinboard post would work, this one is just convenient for me. The posting UI looks like this:

Publishing new posts

I have a cron job on a personal server that polls Pinboard every 5 minutes checking for a new post. When it finds one it does a series of things:

  1. Add the post to a local sqlite mirror of Pinboard data
  2. Create image previews for the new link
  3. Render static HTML and Atom feeds for the whole linkblog
  4. Push those static files to a web host
  5. Post new links to Mastodon

Image previews

A side / optional feature, an image for each link I post. It boils down to using Metascraper to look for a suitable image unfurl or else shot-scraper for a screenshot. Here’s some detailed notes on page previews.

HTML and Atom rendering

Most of the code I wrote is for rending my linkblog to HTML and Atom feeds. It’s pretty straightforward though. It should be possible to use a static blog generator like Hugo instead but I wanted complete control so I rolled my own. I don’t worry too much about the HTML page functionality, I expect most people read my linkblog via a feed reader or else social media.

Social Media posting

New posts go to social media, these days that’s Mastodon (it used to be Twitter.) This process is driven entirely from the Atom feed, not from my rendering code or sqlite mirror. Currently I’m running feed2toot on my server to do the posts, it works fine. A service like Zapier or IFTTT would work too and be one less thing I have to manage myself.

Thoughts

I set up this new architecture last year and have been very happy with how robust it is. Cron jobs and static publication are a great way to build things like this. I do regret running my own server for the rendering piece but I wanted to experiment with something custom to me, so it was effort well spent. Fortunately it seems to be running by itself with little work for the last year.

I think an existing bookmarking service could run a whole linkblog. I haven’t tried it but Raindrop.io looks to have all the important components: image previews, feeds, and a nice public page for an HTML view. It’d come down to details and whether they center links to raindrop.io itself or the destination site that was linked.

AAA and AA batteries

I started using rechargeable batteries about 15 years ago, when Eneloop batteries were the new hotness. Some of those old batteries no longer hold a charge. Also I got more interested in how they work. Some details, mostly about AAA batteries. AA batteries are very similar but have about 2.5x the capacity.

Old fashioned disposable AAA batteries are typically Alkaline chemistry. They’re nominally 1.5V and store about 1000mAh of power, so 1.5Wh. This is what Duracell sells you.

Most rechargeable batteries these days are NiMH. (NiCd are obsolete.) These are nominally 1.2V and about 1000mAh, so 1.2Wh. Capacity varies 20% though; Amazon Basics sells 850mAh. I recently bought some Tenergy batteries which are supposedly 1100mAh but actually 1000 when measured. Wirecutter has recommendations for other brands.

There are also Li-ion AAA batteries. The cells are 3.7V, so these come with a small transformer built in to get the power down to 1.5V. These seem to be sold as 1200mAh, so 1.8Wh of power. A lot of stuff I’ve read suggest NiMH batteries are better for most AAA applications but I don’t understand why, something about load patterns and battery longevity.

A typical set of 4 AAA batteries is about 5Wh of energy, or under a penny worth of electricity. Compare 10-15Wh in a cell phone, or 65Wh in a laptop.

Note the difference between 1.2V and 1.5V depending on battery chemistry. This doesn’t matter for many applications, I guess the power circuit isn’t that sensitive or smooths it over. The voltage also drops as the battery discharges but NiMH has a pretty flat curve for most of its duration. Li-ion batteries put out a steady 1.5V, presumably because of the transformer built in.

Batteries wear out over time. NiMH AAA batteries are typically rated for 500-1000 cycles. But the reality of batteries is they seldom have such nice clean full-to-empty load placed on them so the actual lifespan is shorter. I think the batteries I’m throwing out probably were put in a charger about 100 times at most.

Fancy battery chargers like this old one have a couple of nice features. One is variable charging power; it’s better for the battery to charge more slowly. Another is a “Charge Test” mode; it charges the battery to full, runs it down to zero, then charges it to full again and measures how much charge it actually holds. That’s how I figured out which batteries to throw away, the ones that didn’t hold more than 600mAh anymore. The charger also has a “refresh” mode where it cycles the battery repeatedly hoping to make it work better. I’ve tried using that in the past and it seemed to help but not be worth the bother.

Astro static site generator

I took a quick look at Astro, a newish open source framework for building (mostly) static websites. It looks pretty nice but may not be what I want for my current project, (once again) trying to replace my ancient dynamic blog engine with a modern static site.

The big thing Astro seems to enable is Javascript-heavy static sites. If you want to use React, Vue, Svelte, etc to build a complex Javascript site, but you want everything statically pre-rendered, Astro looks to be your choice. There’s a lot of fancy support for dealing with Javascript, CSS, fonts, etc and getting them to assemble to a nice static page for the client. Also integration with GitHub (for code hosting) and Netlify (for site hosting). I think that’s an interesting spot to be in for a framework in 2023. (Also kind of the opposite of another paradigm I think is interesting, very lightweight Javascript and using HTMX to bridge to a dynamic server.)

One minor annoyance: even the very first empty template project loads about 5kb of client side Javascript. It doesn’t seem to be doing anything and I think can be removed. But it says something to me that even the null project already has client side Javascript; this is a tool intended for Javascript sites.

What Astro doesn’t have out of the box is a blog engine. They have a great tutorial that has you create a blog, very nicely written and easy to follow. But along the way you’re writing code like “enumerate all the markdown files for the posts then use that to build an index of my blog posts”. Ie, you’re coding your own blog layout. That’s fine as an example of building your own static site. But I’m just trying to set up a blog, I’d rather have that stuff built in already.

Maybe that stuff does exist. Astro has a bunch of blog themes, perhaps Astro + an off the shelf theme is what I’m looking for. So I gave Blogster minimal a try. It’s kinda nice and has zero Javascript in the built output, a goal I want. But this looks more like another demo of how to build a blog. In particular there’s no easy way to extend this code short of forking the github project and building your own. Which is fine, but more like programming Javascript and less like customizing some static HTML templates. That’s great if you want to really customize but is work I’m hoping to avoid.

I’m left with the impression Astro is a good choice if you are expecting to write a lot of code to build something unique and custom.

Blog update pinging

While migrating my poor old blog I looked at a 2003-era script I wrote to ping services to tell them when blog was updated. Yes, this used to be a thing. I pinged three services, one is still up.

Ancient history

blo.gs: still live! Pings still work! They even have an API to get the update stream. This was originally built by Jim Winstead, then went to Yahoo, then Automattic (ie, Wordpress) picked it up in 2009 and has been running it faithfully ever sense. Three cheers to Automattic, they run a lot of neat little things that would otherwise be abandoned.

weblogs.com: fails, website doesn’t even exist any more. This was an early service that had big drama in 2004 when Dave Winer threw a hissy fit. VeriSign bought it in 2005, then a few years later it was bought by a private investor group. The last copy of the page in the Wayback Machine is April 2019 and has LexisNexis as the owner. Not sure anyone noticed its passing in 2019.

Google blogsearch. The website is gone but my request to blogsearch.google.com/ping still looks like it works (it probably doesn’t). Apparently this shut down in mid-2018. The larger blog search project shut down in 2011.

Current status

I don’t know what the modern version of blog pinging is, if there even is such a thing. Sitemaps have replaced much of the web function and active push systems like Twitter or ActivityPub have replaced the RSS based pings. Fortunately RSS itself still works.

There’s a large number of ping services that claim to ping many indexers endpoints for you. Ping-o-matic is old and reputable (and owned by WordPress Foundation), it now supports Blo.gs, Feed Burner, Spinn3r, and Superfeedr. One of the biggest lists is from something called “Brain Bliss”, here’s the list of blog pings it says it does. Some of these are definitely offline now.

Daypop, Technorati, Bloogz, Blog Census, Blo.gs, IceRocket, Read A Blog, FeedBurner, Google, BlogRolling, focusLook, Weblogs, Alexa, GeoURL, Gnoos, Adoppt, Twingly, Infotiger, whatUseek, Cipinet, Burf, FyberSearch, Walhello, Acoon, HopHunt, Super.info, AskPeter, Myahint, Semager, Livedoor, Gnibo, Search-o-rama

Ubuntu: slow login / sudo after changing hostname

Amazing Stack Exchange answer that solved a mystery for me: sudo and ssh logins were taking a few seconds. Turns out if you change your hostname on an Ubuntu box with hostnamectl it doesn’t add an entry to 127.0.0.1 for the new hostname. So you have to add it manually.

The delay isn’t so bad you can’t live with it. Maybe 2 seconds? But it’s annoying! I felt like it was DNS related but was assuming it had to do with the DNS server my datacenter was setting. But there’s no reason sudo should involve network DNS at all.

While I’m here, trying to change the DNS servers on Ubuntu is still a total clusterfuck. Not sure if the problem is netplan or systemd-resolve. resolvectl status is helpful but the output is confusing. I’m not sure if I’m getting the “global” setting or the “link” setting. I wish there were some easy way to test it. nlsookup just tells me I’m using systemd’s goofy 127.0.0.53 as the resolver.

# resolvectl status
Global
           Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
    resolv.conf mode: stub
  Current DNS Server: 8.8.8.8
         DNS Servers: 8.8.8.8 8.8.4.4
Fallback DNS Servers: 1.1.1.1 1.0.0.1

Link 2 (enp2s0)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.187.107.16
       DNS Servers: 192.187.107.16
        DNS Domain: nocix.net

Link 3 (tailscale0)
Current Scopes: none
     Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

Password backups and succession planning

How do you back up your passwords in 2023? It’s a grim topic but if someone dies it’s an enormous help if their executor can access their online accounts. Passwords are a key part of that. Here’s some notes on a succession plan for account access. They’re 1Password specific, but any decent password database should work similarly.

1Password emergency access

1Password has a very well thought out emergency kit. It’s a single page you print out that contains most of the data you need to get access to a 1Password vault. Print that and put it somewhere safe. What’s missing is your vault’s password, the thing you type to unlock it. There’s a space for you to write it in. Diceware style passphrases (e.g. “correct horse battery staple”) are a good choice for your vault’s password; secure, relatively easy to remember and type, and quite easy to read when scribbled on a piece of paper.

1Password also has a family recovery system. If you’re paying for a family plan anyone who is a “Family Organizer” can unlock someone else’s vault in an emergency. Note you have to set this up ahead of time.

Printing passwords

1Password’s recovery system is great and what you want to use. But there’s something to be said for a simple paper backup in case something goes catastrophically wrong at 1Password. It’s very easy to export 1Password’s database, either to a special format 1P invented or to a plain old CSV file.

Printing 1500 passwords is harder; it’s a lot of pages and you want it to be legible. I ended up using good ol’ Keepass for print formatting. I exported my database to CSV, then imported it using the generic importer in Keepass. It has a decent print system, the formatting is fairly good. My ~1500 passwords ended up being 30 pages. Don’t forget to print double sided to save half the paper.

Passwords aren’t everything

Passwords aren’t all you need to get access to everything online. Two factor authenticaton, passkeys, etc all complicate that.

Phone access is increasingly useful, particularly for two factor logins. I imagine there could be a need to get one last thumbprint to unlock a phone...

Email access is also really valuable. Consider setting up Google Inactive Account Manager if you use Gmail. Note it’s a minimum of 3 months to trigger.

Yet another new datacenter server

My server for somebits.com broke (hardware failure). My notes from last time I set this up were helpful so I’m taking boring detailed notes again.

I really need to stop having a custom configured bespoke server like this. It’s almost entirely used for web traffic these days, and most of that is static. If I can ever successfully convert my blog over to a static generator I could be done with needing a custom server.

Fairly generic stuff

  1. Change password for user “customer”
  2. Add my ssh pubkey for user root
  3. Install Tailscale
  4. Set hostname with hostnamectl set-hostname
  5. Add DNS A records to somebits.com for both main IP and Tailscale IP
  6. Run apt upgrade
  7. Install a bunch of useful packages
    apt install joe stress-ng stress s-tui smartmontools zip unzip rsync openssl webp plocate ripgrep pigz python3 python-is-python3 python3-venv python3-dev pkg-config build-essential sqlite3 chrony rsnapshot
  8. adduser nelson
  9. usermod -aG adm,cdrom,sudo,dip,plugdev,lxd nelson
  10. reboot
  11. file a ticket for reverse DNS
  12. Copy all my old server files from backup to a subdirectory under /root
  13. Set up /home/nelson from the backup
  14. Set up rsnapshot backups. This is very fiddly; rsnapshot -t is useful for testing things. On the newly installed server to be backed up it requires a new user and an entry in /etc/sudoers.d.
  15. apt install mail and set up a local-only postfix
  16. Skipping this time: autossh, munin

Service specific stuff

  1. Change *.somebits.com and somebits.com DNS to new server. I did this early, before the new server was fully set up, because the old one was already broken.
  2. Change DNS entries for other services I run (check Hover DNS).
  3. apt install apache2
  4. Copy over /var/www from the backup
  5. apt install certbot python3-certbot-apache
  6. Restore /usr/local/etc from backup
  7. Restore /etc/apache2 from backup
  8. Make subdirectories in /var/log/apache2
    for d in logsoflag n177xy somebits weblog windhistory; do mkdir $d; done
  9. Restore /etc/logrotate.d entries that are relevant
  10. Set up Perl environment for Blosxom
    apt install libcgi-pm-perl libimage-size-perl
  11. Migrate old Let’s Encrypt install over to new server
    Restore /etc/letsencrypt from backup
    Test https works on new server (beware of DNS expiration times)
    Test certbot renewal with certbot renew --dry-run
    Remind yourself to check in three months
  12. Copy over and test secret stuff from /usr/lib/cgi-bin (no, really!) Also requires
    apt install python2
  13. Set up linkblog user and test it
    adduser linkblog
    restore ~linkblog from backup
    On home server: /home/nelson/somebits/linkblog/prod/update.sh -p -f
    Probably have to swizzle cached ssh keys with this.
  14. User crontabs in /var/spool/cron/crontabs.

Testing

  1. Look at dmesg and /var/log/syslog for anything troubling
  2. Try various websites
  3. Look at /var/log/apache2/*/error.log for anything troubling
  4. Add a new linkblog entry, verify it shows up

One hidden gotcha is all the other client hosts that might have the wrong entry in .ssh/known_hosts for the domain name for the new server. You have to run ssh-keygen -f "/home/nelson/.ssh/known_hosts" -R "somebits.com" to remove them, then manually accept the new ones once.

I managed to break my first attempt at setting up the new server by adding a disk to /etc/fstab forgetting an earlier lesson. Linux systems won’t boot if something in /etc/fstab isn’t working! Fortunately the datacenter has automated system reimaging so I could start over without wasting anyone else’s time.

Diagnosing a failing Linux disk

My datacenter server failed, bad power supply, and when it came back it’s sort of working but is very very slow. I poked around and got the impression the problem is a failing disk. How to be sure? These notes are for a spinning SATA disk, not an SSD.

iostat

The main thing I noticed is everything writing to disk was taking a long time (ie many seconds instead of 100ms). Also a lot of processes in device wait. Here’s how I quantified the problem

# iostat -d 1 --human -xs /dev/sda
Device             tps      kB/s    rqm/s   await  areq-sz  aqu-sz  %util
sda               7.94    415.3k     8.93  380.72    52.3k    3.01  90.8%

sda             111.00    444.0k     0.00    7.36     4.0k    0.80  83.2%
sda              31.00    660.0k   134.00   55.77    21.3k    1.70 127.6%
sda             240.00      1.1M    30.00    4.31     4.5k    0.99  87.6%
sda              13.00     96.0k    12.00  189.85     7.4k    2.45 102.8%
sda               9.00     44.0k    55.00  340.44     4.9k    3.04  97.6%

Note with iostat -d 1 the very first row is since system start, then it’s a continuous report for the last second. The alarming thing here is the “await” column. That’s milliseconds waiting for a single read or write; 380ms average since system boot! Something’s not right. The throughput numbers are also a clue, disks should be doing 30 MB/second, although that does depend on what the programs using the disks are doing. The 100% utilization is a very bad sign too. You can get more details from iostat if you remove the -s flag, but it gets a little confusing.

hdparm

hdparm can be used to test read rates on a disk. Here’s what I got

# hdparm -t /dev/sda
/dev/sda:
 Timing buffered disk reads:  30 MB in  4.27 seconds =   7.02 MB/sec

That’s 7 Mbytes/second. That’s awful. Even a slower spinning disk should be in the range of 100 MB/sec. Something is wrong.

smartctl

smartctl -x /dev/sda is also important, using SMART diagnostics on the disk itself. -x means “all, no really all”. Unfortunately its output is still really hard to understand, the confusing “VALUE WORST THRESH” stuff. I have previous notes on understanding smartctl output that are helpful. This weird Maxtor drive I have has confusing numbers and doesn’t report the Raw_Read_Error_Rate I’d most like to see.

I do have an error log with lots of entries like

Error 46140 [11] occurred at disk power-on lifetime: 36305 hours (1512 days + 17 hours)

There’s no easy way to tell how old those errors are or exactly what they meant. But their presence and the number “46140” sure gives me concern.

smartd displayed this helpful error in the syslog, also suggesting a problem.

Jul 4 17:05:56 wl smartd[3197]: Device: /dev/sda [SAT], 1 Currently unreadable (pending) sectors

Remapping bad blocks

Modern spinning hard drives have the ability to remap bad blocks and avoid them in the future. Linux has historically been bad at letting the disk do this, I think on the theory that destroying data is bad and it should be a manual process (or better, avoided). Here’s some recent notes on the topic. I think manually remapping a known bad block is still really awkward and difficult. Reading that makes me think the disk should itself eventually recover if the block is re-written. But if it’s a read only file that’s corrupted that won’t ever happen!

SSDs change how all this works.

Background work in Javascript

I’m writing a little browser toy where I calculate a model in the background and render it frequently. Think something like an animated cellular automaton.

Rendering is easy in modern browsers: you just use requestAnimationFrame and hopefully it’ll call your code once per screen refresh or at least as fast as it can manage.

But how do you do background compute work in Javascript in 2023? I want it to run as fast as possible (ie, 100% CPU for the browser tab) but still be smooth and responsive. I think the right answer is “web workers” but then that requires the overhead of passing the calculations back and forth via messages (and JSON serialization?!).

Here’s some other things I tried for background Javascript work. I tested using a calculate function which executes in well under 1ms.

  • Use setInterval to fire off the calculation: 4ms is the minimum allowed in modern browsers, limiting you to 250 calculations / second.
  • Use a spin loop. This works and I can do but now the main browser thread is blocking everything and it’s a UI disaster. Not feasible.
  • Use a spin loop with a Promise to yield via a short sleep. Still subject to 4ms on setTimeout, but overhead means it’s more like 5.2ms in practice.
  • Use requestIdleCallback. I had high hopes for this but in practice I’m getting called every 11.1ms or 90 updates / second. Turns out that’s my screen refresh rate and the idle callback rate changes if I update the display driver refresh. It’s like VBlank interrupts in 2023 only about nineteen layers removed from the hardware.

I think in practice setInterval will work for me; my calculations are likely to take a few milliseconds and anyway I don’t want it to run “too fast” because it won’t be visible. Still kinda wacky this is so hard in 2023. Web workers are probably the right way if I need faster than 4ms.

// Calculation loop using idle callbacks
function calculate_idle() {
        calculate();
        window.requestIdleCallback(calculate_idle);
}

// Calculation loop using ersatz sleeps. Note 4ms is minimum here.
async function calculate_sleep(interval) {
        // https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep
        while (1) {
                calculate();
                await new Promise(r => setTimeout(r, interval));
        }
}

switch (mode) {
        case "idle":
                // Seems to be every 11ms per quick testing in Chrome
                calculate_idle();
                break;
        case "interval":
                // Browsers seem to make 4ms the minimum interval
                setInterval(calculate, 1);
                break;
        case "spin":
                while (1) {
                        calculate();
                }
                break;
        case "sleep":
                calculate_sleep(0);
                break;
}

Starlink dropouts

Ever since I started using Starlink I noticed that sometimes it drops out for 100-1000ms, maybe a couple of times an hour? I used to think it was just my site (I have some very minor obstructions, well under 1%) but enough other folks complain online about it now that I think these microoutages are just a weakness of Starlink’s Internet service.

That’s a graph of 24 hours of outages data, as reported via Dishy’s gRPC. It’s the same thing Starlink shows textually in its “Outages” mobile app tab. From what I’ve read the “Obstructed” tag doesn’t necessarily mean obstructed; it’s a catch all for “unexplained outage”. This graph shows 59s of obstructed, 30s of no pings, 50s of no downlink, and 12s of “no schedule” which is Starlink’s semi-regular 4am outage.

All told it adds up to 151 seconds of outages, or 99.8% uptime. Over a month I measured 99.3% uptime.

Two nines isn’t very impressive for an ISP, in my opinion, although it’s within the parameters promised by Starlink. Maybe it is impressive for a wireless ISP though, or a satellite one. I hope it improves but it’s not awful now.

The main way I notice is if I’m playing an online game; I’ll get a lag spike until the game recovers. Fortunately the outages don’t break TCP connections, either the packet shows up eventually or else TCP retransmits fix it. It also causes problem with live video and audio streams, like a Zoom call. But it’s only a second or two every 30 minutes, not terrible. You won’t notice it at all with web browsing and it will hardly affect bulk download speeds.

I have no idea what’s going wrong but could imagine many explanations. One common theory that seems wrong is that Starlink drops out every time it hands off satellites. I don’t think that’s the case. It’s potentially doing a handoff every 15 seconds, and seems to be every 5-10 minutes in ordinary usage. It’d be intolerable if every time it did that the Internet went away for a quarter second. Actual performance is much better than that. (IIRC Dishy is able to track a primary satellite and a backup, which probably helps with a smooth handoff.)

Starlink 50 Mbit/s throttling

Not my own data, but a couple of Reddit threads (also) are users reporting being throttled to 50Mbps download after using a certain amount of bandwidth in a short time. I think I’ve seen this myself but haven’t tried to measure it. One user’s guess:

This is 100% a hard throttle that can be triggered at will and is repeatable. It slows entire starlink service down to 50mbit. Even if it’s middle of the night!!! It then resets after the hour and the cycle repeats as follows.
-Start download -download at 120 for 15 mins -drops to 50 for remaining 45 minutes -returns to full speed for 15 mins -drops to 50 for remaining 45 minutes.
Seems to be 1 hour cycles, 15 mins of full speed followed by the remaining 45 throttled.

A lot of folks are pointing out how clumsy this is, particularly at 2am when there’s spare capacity. I don’t think this explains the better performance I’ve been seeing since March. I think it was added newer and isn’t the most effective of measures they’re using. But I’m totally guessing here.

Update: I haven’t seen any evidence of this at my own site but I would have only noticed around June 12/13 when I did some big downloads. Diablo 4 downloaded 85GB at an average speed of 150Mbps, no evidence of throttling. (at 8am Tuesday the 13th, a quiet time). Some of the reports on Reddit have definitely looked like a 50Mbps cap, I believe them, but the reports aren’t consistent. Maybe it’s something they’re testing or only doing to some users.

Update 2: a Reddit thread of someone getting a response from Starlink Support (in Poland) saying they are throttled because they used too much data, over 1TB.

Obsidian Sync

I’m really liking Obsidian as my note taking app. I just paid $10/mo for Obsidian Sync, their syncing solution, and had some thoughts. This was originally an email to their support team.

Obsidian Sync mostly worked great. The docs are good. It feels like a solid product.

I previously was syncing with Syncthing. It worked mostly fine but was a little awkward. The thing that got me to buy the service was not having a great way to run Syncthing + Obsidian on a Chromebook.

I really balked at the $10/month or $98/year price. I’m sure they’ve heard a lot of complaints about the price and have their reasons. But if it were half the price or less I would never have set up SyncThing in the first place. FWIW I think 1Password is a good comparable at $3/mo for a single person.

Migrating to Obsidian Sync was a bit tricky; a lot of juggling of vaults, passwords, state. The extra steps to sync Obsidian settings and plugins were particularly confusing. This is the primary customer acquisition pathway, some streamlining here would help. None of the steps were technically wrong! Just awkward and given how easy it is to screw everything up with sync, a little nail-biting.

That reminds me they totally undersell one of the best features of Obsidian: the vaults are just simple text files and some JSON data! It’s so easy to make a backup of a vault or move a copy. So many systems (like 1Password) are opaque; Obsidian is refreshingly transparent. Ironic, given the product name ;-)

Starlink stays improved

A couple of months ago I noted that Starlink had recently improved during nightly congestion. Glad to say that trend has continued. It’s not gotten any better but it hasn’t gotten worse either. Even more important I’d say it’s “pretty good” now whereas before it was “really bad every evening”. I actually managed to watch a video stream over the Internet at 9pm last night, something I wasn’t able to do for the last year reliably.

Here’s a couple of graphs showing the change around April 1. I’m on residential service (ie, higher priority than best effort) Note there’s some bad data mid-march (I was on my backup ISP because of something unrelated).

This is my best measure; how many hours a day do I get under the advertised 20 Mbps download speed, based on an hourly Ookla speed test. Before the fix this was regularly 4+ hours a night, every night. Now it’s typically 1 or 2 hours. The nice thing about this measure is it highlights what I really care about, which is degraded service for part of the day.

And here’s a simple packet loss graph based on pings to 8.8.8.8. Before the fix I was averaging 1% packet loss for the whole day. Now it’s 0.5%. Still pretty high but not terrible. This doesn’t highlight the nightly congestion very well, I should do something showing “hours with over 1%” or something. Eyeballing a graph I have this steady 0.5% packet loss most of the day, it’s nothing like the bad old days of 5%+ packet loss in the evening.

This last graph is not useful, only including it for its obviousness. That’s average daily bandwidth (again, measured hourly at Ookla). The average may have gone up a tiny bit since the April improvement. But it’s not noticeable because the 3am periods of 250+Mbps swamp the hour or two of unacceptable 5Mbps service. Just an example where simplistic measures don’t capture what you care about.

I still don’t know what changed at Starlink. But my money is on them improving their traffic shaping and load balancing algorithms. It’s also possible this was a fix just for me, maybe I was incorrectly classified as a best effort customer and that got fixed? I have no reason to think that though. I think they improved their technology at the same time they dropped their soft data cap plan.

Nintendo Switch image downloads

The Switch has a screenshot function that saves images to an “album” in system storage. There’s a bunch of ways to download those images; plug the Switch in to a PC via USB, transfer with an SD Card, upload them to a social media service.. Or the slickest way, ad-hoc WiFi.

The process is described well in this article. Briefly the steps are:

  1. Select photos to download and say you want to share to your phone.
  2. Connect to a Switch ad hoc WiFi network. You do this by scanning the QR Code the Switch displays. It contains a WiFi Card string which has the SSID and password. The phone connects automatically to the network when you scan the image.
  3. Connect to a web server the Switch is hosting at 192.168.0.1. You do this by scanning a second QR Code that contains an URL. Your phone opens a web browser with the images in it.
  4. Save the images from the web page however your phone lets you.

It’s pretty slick. Also remarkably complex from a technology point of view, but using it is fairly simple.

Using Passkeys in Google’s ecosystem

I’m trying to understand passkeys. I did a test today trying to create and use a passkey on a demo site. I tested trying to log in on an Android phone (Pixel Pro 6), an Android tablet (Samsung Galaxy Tab S8+), a Windows 10 desktop, and a Chromebook. Here’s what I learned.

In summary: passkeys seem to work well for login and are shared across Android devices. Passkeys are stored alongside old fashioned passwords in a product Google calls “Google Password Manager”. If synced any Android device can be used as an authenticator for any passkey you’ve added. However Chrome cannot act as an authenticator on Windows or ChromeOS; they delegate to a nearby Android device. Important features for managing passkeys do not exist yet.

These notes are all for today, May 19. Most of my devices are pretty well updated: Chrome 113.0.5672.94, Android 13 on the phone and tablet, ChromeOS Beta 114.0.5735.31 on the Chromebook. The desktop is Windows 10 Pro 22H2. I have not set up Windows Hello on it.

(I didn’t test on any Apple systems. My understanding is Apple Keychain works pretty well and is synced across all devices via iCloud.)

Logging in

I created a new account and passkey at passkeys.io on my phone. That took a one-time setup of Google Password Manager on my phone to tell it to store passkeys there and let me unlock them with my phone biometrics. Then the new passkey was created and stored.

Chrome on Android Phone: I could log in and out of the demo site very easily in the Chrome browser. Chrome prompts me once to verify I want to log in with a passkey, then a second prompt for my thumbprint, then I’m logged in. I wouldn’t mind if they whittled that down to a single prompt.

Firefox on Android phone: worked identically to Chrome with no extra setup.

Chrome on Android Tablet: after initial setup it was the same login experience as phone. The tablet also lets me use a PIN instead of a thumbprint. The important thing here is I never did anything to get my passkey on to my Android tablet. That happened transparently, behind the scenes. Apparently Google is syncing passkeys between secure Android devices via the Internet (or possibly Bluetooth). The passkey is definitely coming from the tablet itself, my phone is not involved.

Chrome on Chromebook: different experience. Logging in pops up a “use your passkey” dialog with a list of devices that have my passkeys. I chose my phone and a notification popped up on my phone asking me to approve and use my thumbprint to log in. That all just worked in 4 clicks/taps in total. Behind the scenes I believe this uses Bluetooth. The passkey is not on my Chromebook, it requires a different device to be the authenticator.

Chrome on Windows: similar experience as Chromebook once Bluetooth was set up on Windows. I’m prompted with a list of authenticator options, delegating to my phone worked like the Chromebook. There’s also an option for “Windows Hello or external security key” as an authenticator which popups up a Windows dialog for what I imagine is Windows’ passkey authenticator. Before I added Bluetooth to the Windows box that popup appeared immediately, it was my only choice. I didn’t pursue the Windows stuff, but I imagine that’d be the way to get passkeys on the Windows device itself (or a Yubikey) and not rely on a phone. It’d be nice if Chrome didn’t ask me every time which Android device I wanted to use.

Firefox on Windows: goes straight to the Windows dialog, even with Bluetooth available. No choice of authenticators. It doesn’t seem aware it could delegate to my Android phone.

Edge on Windows: two options, “Windows Hello or external security key” or else “Use a different phone or tablet”. That second option popped up a FIDO: QR Code that introduced Edge to my phone as an authenticator. Then the phone did the passkey thing via Bluetooth. Second time around I had a third authenticator option, my phone, which worked just like Chrome and Firefox on Windows. I don’t know if some of this interaction was specific to passkeys.io and their Javascript libraries.

Summary: Android devices are storing passkeys and syncing them between themselves. Windows and Chromebook are not storing passkeys but can delegate via Bluetooth to a nearby Android device.

Managing passkeys

Logins work pretty well in the Google ecosystem, what about managing passkeys? The story isn’t as great although Android at least can give you a list of passkeys.

Google’s passkey authenticator product is called Google Password Manager (GPM). This is the same thing that stores plaintext passwords for websites you log in to. It manages passkeys too. I never set it up before because I use 1Password instead.

Android: GPM is part of Google Play Services, a sort of adjunct to the Android OS. Launching GPM on Android is not easy. It’s hidden in Settings and I could only find it via a search, and in a different place on the Samsung tablet than the Pixel phone. Once in the Password Manager there’s a button “Add shortcut” which will give you an icon you can tap to open it. Opening that I see a list of my passkeys and passwords.

Chrome on Windows: GPM is in Chrome settings at chrome://settings/passwords. However it only has a list of my passwords, there are no passkeys there. Not too surprising since the passkeys aren’t actually on my Windows machine.

Chrome on Chromebox: same as Windows; no way to list your passkeys that I can find.

Google Passwords webapp: GPM has a webapp version of its product. It only lists my passwords, not my passkeys. This seems like a fairly serious omission to me. I don’t know any way on the web to find the passkeys that Android is syncing for me.

Google Accounts: Google has a webapp for the passkeys I can use to log in to Google itself. It tells me that two were automatically created for me, one on each of my Android devices. That’s a relatively new thing but is an extension of a passkey-like authentication that Google/Android has been doing for awhile.

Summary: GPM on Android is the only working passkey management tool. It’s pretty limited. You can list your passkeys and delete them. There’s no option to export them, or back them up outside Google’s ecosystem, or share them with someone else. Some of that stuff is supposedly coming but I have a suspicion Google is in no hurry to implement something that’d let you migrate out of their product.

My new Acer Chromebook Spin 714 (2022)

I finally picked a Chromebook to be my travel laptop; an Acer Chromebook Spin 714. Specifically the 2022 model, CP714-1WN-53M9 SKU:6507836. I got this on sale for $529 from BestBuy, I probably wouldn’t have bought it at the usual $729 price but I’m glad I got it on discount. (Chromebooks often go on discount, it’s weird.)

It’s very good hardware! The screen is nice and bright and at 1920x1200 has enough pixels. The keyboard feels fine. The system feels quite fast, a combination of ChromeOS being responsive and the CPU in this thing being pretty high power for what it’s doing. Unusually it also comes with 3 USB ports (two USB-C) and a dedicated HDMI output.

Note there’s no SD card slot. The 256GB of SSD is more than enough for normal Chromebook stuff though. I have a complaint about the trackpad. It’s a little floaty, apparently a design flaw with inexpensive laptops that you might be able to fix yourself. I’m also not thrilled about the vents and fan; the fan comes on a little just sitting in my lap if my clothes are blocking the bottom vent at all. Ut doesn’t spin if sitting unobstructed on a flat table. And it’s very quiet when it’s running but there’s a difference between no fan at all vs. a very quiet one.

It’s a “Spin” which means the hinge rotates all the way around so you can use it fold it backwards and use it like a tablet. (Touch screen or stylus, the keyboard and trackpad get disabled). I was thinking that’d be a great feature but now I don’t; it’s just too bulky and awkward. Also the hinge doesn’t fully lie flat so it feels a little springy, like it might break if you press wrong on it.

One nice surprise is that Steam is available in beta on ChromeOS and a bunch of games seem to work well on it. The Chromebook isn’t going to win any gaming benchmarks but some games with light 3d were perfectly playable. I wouldn’t recommend buying a Chromebook for gaming, particularly not this one, but it’s nice to have the option.

The main thing I like about it is the screen. Bright, clear, and while not high DPI text looks pretty good on it.

Alternatives

Acer is now offering a slightly updated Spin 714, the CP714-2WN at $699. That one is mostly the same. Slight upgrade to the CPU (13th generation vs 12th) but the rest seems the same. They took out the stylus from the package, that’s kind weird.

I kind of wish I’d bought one of the Kompario 1380 systems. Either the $489 HP x360 13b-ca0047n or the $599 Acer Chromebook Spin 513 cp513-2h. That latter one is particularly interesting for its 2256 x 1504 screen. The ARM CPU means lower power so they have longer battery life and are truly fanless. OTOH ChromeOS on ARM is a mixed bag. It won’t matter for basic stuff but if you’re installing Linux you need arm64 packages that may not be available. And Steam is out of the question AFAIK.

I was pretty impressed with my $120 Chromebook, an old Acer 311 also based on an ARM processor. Still a great value.

Update

Worked great for my recent trip to Ireland! Didn’t miss having Windows or MacOS, not even once. Loved the light machine with a big bright screen. Really appreciated that it doesn’t need its own proprietary charger; I guess most laptops charge via USB-C now but this was my first one and it’s great to have a lighter bag.

Switching from Firefox to Chrome

I switched to Firefox over 5 years ago, when Quantum came out. Yesterday I switched back to Chrome, at least for awhile. OMG it’s so much faster.

Why

The primary reason to switch is the new Chromebook. Running Firefox on ChromeOS is not great. You’ve got two choices. Either install the Android app, which works too much like a mobile app. Or install the Linux app which mostly should work OK but it’s running in a container and is awkwardly integrated. Either way, it’s hard to overlook that it’s a Chromebook running ChromeOS which is largely a bunch of Chrome browser tabs as apps. And while I can run different browsers in different places it’s very nice only having a single browser everywhere for data syncing, etc.

The other reason is Firefox doesn’t feel as great to me as the early Quantum days. It’s slow to first launch, like 5+ seconds. Turns out I shut down and relaunch my browser a lot (I’m a tab zero kind of guy). Also I keep running into little weird site problems with Firefox where the most likely explanation is the site was never tested on it. (e.g., the Wordpress.com editor I’m typing this in looks better in Chrome.) I just got tired of dealing with that friction.

Migration

Moving from Firefox to Chrome is pretty easy. Chrome has an import tool to bring in bookmarks although I had to organize after the import to get them in the right place. It will also import browsing history, something I’ve found surprisingly useful to keep around.

Most of the important stuff is in authentication. I use 1Password already so my login passwords are already portable. There’s no way to bring over login cookies so I have to re-log-in to everything in Chrome but, eh, that seems inescapable.

The surprising hard part of moving over was browser extensions. I only use six, and some of them have identical versions in multiple browsers. But I had to find a different Pinboard extension. And sadly I’ve learned both Imagus and Bypass Paywalls Clean have gotten deprecated / not updated for a long time. So that’s awkward, albeit also a problem for Firefox.

Missing

The main thing I’m missing from Firefox is Multi-Account Containers. I use that to quarantine hostile surveillance sites like Facebook or Twitter. It doesn’t work perfectly but I think it helps. Anyway Chrome doesn’t have them. It is relatively easy to use separate profiles in Chrome now, so I’m doing that, but it’s not as good a solution as Firefox’s more automatic UI. SessionBox seems the most popular extension but it’s basically payware and the UI is a bit awkward. Does seem to get the job done though.

Also worried about ad blockers. Right now uBlock Origin works great on Chrome. But there’s the ongoing Manifest v3 thing coming and concerns it will make effective ad blocking harder. If Chrome breaks ad blocking I’ll switch back to Firefox, so got to keep an eye on that.

I’ve noticed that Chrome’s “restore closed tab” feature isn’t as robust as Firefox’s. Firefox can not only restore an old tab but a whole window of tabs. And it restores them with more state, like the text of a Reddit post that I closed the window before posting and then changed my mind and decided I wanted to post afterall. It’s not a big deal but I got used to the Firefox safety net.

Chrome allows third party cookies. You can turn that off but they haven’t done anything to mitigate all the stuff that breaks. Like Google’s own home.nest.com, which apparently uses a google.com cookie or something to authenticate. Firefox has a more complex system for blocking invasive third party cookies, so does Safari.

Feelings

So far Chrome is working fine for me. It definitely feels snappier; somehow Firefox has gotten less responsive over the past couple of years. But I haven’t measured that in any precise way. That first window open is definitely way faster on Windows in Chrome, and I checked and it’s not just because Chrome is hiding as a background app. (That trick makes it faster still.) Also a lot of web pages feel like they’re reacting faster to my inputs. But without careful measurement I can’t really be sure.

I think Firefox is important. I want Mozilla to succeed. But I feel a bit like I’ve just taken a hairshirt off. My main message is I should be trying different browsers more frequently.

Chromebook, Ubuntu, Crostini and other containers

ChromeOS has nice support for running your own Linux distro in an LXC container. By default it installs Debian in a container named “penguin” and there’s a Terminal app to connect to a shell in it. I’d rather use Ubuntu. There’s lots of instructions on how to do this online but most of what you’ll find are using the outdated Crouton container environment.

The 2023 way of setting up Ubuntu on a Chromebook is with Crostini. This Reddit Wiki has thorough instructions. This article is also fairly good as is this outdated gist. It boils down to launching a special Termina shell to control containers. Then to install Ubuntu in a new container, then to install some Chromebook specific stuff, then to set up your user login.

All that being said I could easily set up a container with a different Linux distro but I couldn’t get it to connect nicely to the Terminal GUI app. This is all pretty complicated tinkerhacking. One reason I’m excited about ChromeOS is you don’t really need to do this kind of thing for an ordinary experience. But I’m being a little extra about a Linux environment.

Alternate distro support is a work in progress and there’s lots of notes about current development online. I stopped about here, which was instructions on telling Terminal how to connect to a different container. This is related to the crostini-multi-container flag in about:flags. That’s a feature that gives you a GUI for accessing multiple containers but is not complete. See also discussion here.

A failed Ubuntu install

Unfortunately the online instructions didn’t work for me with Ubuntu 23.04 and ChromeOS Beta 114.0.5735.18.

One problem is the Chromebook-specific stuff (cros-ui-config and friends) failed to install, either using the fancy script or just running “apt install” and hoping for the best. The Reddit Wiki has complicated instructions and a script for installing cros-ui-config. I guess the packages are still not working quite right but different hacks are needed than what that script did. These didn’t work for me with Ubuntu 23.04 and ChromeOS Beta 114.0.5735.18. Simply running apt install cros-ui-config got fairly far but failed in the end.

Worse, even a vanilla Ubuntu 23.04 install (without cros-tools) didn’t work right for me. It seemed to be fine, I could get a working shell with lxc exec. But then I couldn’t connect to it via the Terminal app, the little spinning progress thing ran and stalled without giving me a shell. It’s like whatever connects the ChromeOS UI to the containers wasn’t working. I couldn’t even completely wipe the Linux development environment from the Settings app, it also hung, although the wipe did work after a reboot. At least I didn’t have to powerwash the whole system and start over.

For now I’m just going to settle for Debian. When I feel like tinkering again I’ll revisit Ubuntu, maybe update this blog post.

Other containers and VMs in ChromeOS

It’s not just a Linux environment that uses a container on a Chromebook.

Modern Chromebooks run android apps in a container called ARCVM. I don’t know much about how this works, it’s all pretty opaque. Folks complained it uses more resources than the old method but it seems fine to me.

ChromeOS 108 got the ability to run Steam games. It does this with a VM environment called Borealis. From what I’ve read this is Ubuntu 18.10 and using Valve’s Proton stuff to emulate enough Windows API to run a lot of games. Ie: similar to what a SteamDeck is doing.

This is all a lot like what Windows does, btw; WSL is the Windows equivalent of Crostini, and Windows can run Android apps in a VM too.

Influx: seeing table (measurement) size

I’ve been accumulating data in Influx DB for a long time. Here’s how to see how much (in bytes)

influx_inspect report-disk -detailed /var/lib/influxdb/data |
  jq '.Measurement | sort_by(.size)'

I’d like to set up a retention policy to auto-delete some old data but unfortunately policies seem to be per database. I’ve got a lot of stuff in a single database named telegraf and some of it I want to keep forever, others I want to discard after a month. I imagine there’s a way to configure the telegraf agent to start writing data in different databases and/or retention policies.

telegraf vs timestamp precision

Learned something the hard way: telegraf by default rounds (some?) timestamps to 1 second.

I’ve got some code that runs IRTT and emits influx format lines every 100ms with precise timings and timestamps. Output like this:

irtt_packets,remote_address=45.66.249.240:2112 delay_rtt=49890590,ipdv_rtt=-25723094 1683647662430925080
irtt_packets,remote_address=45.66.249.240:2112 delay_rtt=100696672,ipdv_rtt=50806082 1683647662530279079
irtt_packets,remote_address=45.66.249.240:2112 delay_rtt=66017146,ipdv_rtt=-34679526 1683647662630672054
irtt_packets,remote_address=45.66.249.240:2112 delay_rtt=56583224,ipdv_rtt=-9433922 1683647662731135862

Those are nanosecond timestamps and the interval is roughly 100,000,000 nanoseconds (ie: 0.1 seconds).

But in influx the data comes out looking like this:

1683646020000000000 43842340 gvl 12180311 45.66.249.240:2112
1683646021000000000 43708652 gvl -11768007 45.66.249.240:2112
1683646022000000000 36362863 gvl -4289225 45.66.249.240:2112
1683646023000000000 40232640 gvl -47825 45.66.249.240:2112

It’s filed all the numbers off my timestamps! Worse, it’s combined ten 100ms measurements into a single 1s measurement. I think new entries just clobber old ones although I’m seeing some signs of it actually combining data from several measurements (‽)

The culprit is precision in telegraf.conf. This can be set both for the whole agent and on a per-input plugin. Maybe also per-output.

My Ubuntu had this set to the empty string. What that means is not well documented on the website but the .conf file had this helpful comment

## By default or when set to "0s", precision will be set to the same
## timestamp order as the collection interval, with the maximum being 1s.
## ie, when interval = "10s", precision will be "1s"
## when interval = "250ms", precision will be "1ms"

So that’s super confusing. But I had my interval at 15s and was seeing timestamps with precision of 1s. I added a precision = "1ns" to the input of interest and now it’s logging timestamps properly.

I can see how truncating timestamps like this could be useful; it hides slight jitter in data and everything lines up neatly. But in my case I really need precise timings. Also the way this causes multiple entries to be lost (because of timestamp combining in influx) is bad. Particularly surprised that it’d throw away precise timestamp info from influx wire format data. If someone went through the trouble to output nanoseconds they probably meant to.

Starlink residential improvements

Starlink has changed their service plans, at least in the US. For once it’s a small improvement for me, specifically the drop of a 1TB soft data cap on residential plans. They also raised documented download speeds to 25-100Mbps (from 20-100) although upload speeds are now listed as 5-10Mbps (from 5-15). See the new service specification that I assume replaces the old one for details.

I wonder what changed that caused them to drop the soft data cap? I posted a month ago about a performance improvement during evening congestion; maybe they’ve improved their resource sharing enough they didn’t need a formal cap? Service is definitely improved for me, the change I documented a month ago has held steady.

Update: the “fair use policy” indicates they might still throttle only on terms less clear than the planned 1TB soft cap. So this seems a step backwards, not forwards.

If bandwidth patterns consistently exceed what is allocated to a typical residential user, Starlink may take network management measures, such as temporarily reducing a customer’s speeds, to prevent or mitigate congestion of the Services

Awakened PoE trade, AI complexity

I am playing the game Path of Exile again and continue to be amazed at the complexity of the third party tools gamers have created for it. The game doesn’t really support addons or anything, it’s all hacked on. A few years ago I looked at how PoB Item Tester worked; this time around it’s Awakened PoE Trade (APoET).

There’s a feature where APoET will take a screenshot of the screen, OCR the text on the caption of an item, then tell you whether it is valuable. It’s a little flaky but when it works it’s a huge convenience over alt-tabbing out and doing a web lookup.

The tech it uses is remarkably complex. APoET itself is an Electron app written in 8500 lines of TypeScript and 6800 lines of Vue. It’s a strange UI, built to run as popups on hotkeys while playing the game; not at all like a typical Electron windowed app.

The OCR code is just 326 lines of TypeScript. To use it you install a binary blob. In that is Tesseract, a nearly 40 year old OCR library that has gotten a bunch of updates over time. The modern version is based on OpenCV (itself 20 years old) and some machine learning model boiled down into 4MB of weights. The code for these libraries are a further 5.5MB of WASM binaries. It’s called “tesseract-core-simd”; news to me that WASM could take advantage of SIMD instructions, I guess that’s a few years old.

Anyway it’s a tower of complex software building what is ultimately a pretty simple and kludgey product. I love that this is all possible and accessible even to folks hacking a tool for a game they play.

(while I’m here, the real standout tool for PoE is Path of Building, a complete theorycrafting game simulator. With 50,000 lines of hand-written Lua and another 2M lines of game data as Lua code.)

Chromebook shopping

I’m on the hunt for a good Chromebook, a real laptop for travel. The cheap Acer 311 C722-K4CN I bought is fine but underpowered and not a great screen (low res, TFT not IPS). I want something with a touchscreen and sturdy hinge but that folds back 360° so it’s like a bulky tablet. Would like a fingerprint reader and decent speakers. And I want an ARM processor, not Intel, on an unsubstantiated theory you get more life on the same battery.

Lenovo is about to come out with a $270 Lenovo IdeaPad Slim 3 Chromebook. It looks good except that the hinge doesn’t do 360°. Also it’s marketed as “budget” but it seems plenty powerful enough to me.

HP has a $370 HP Chromebook x360 13b that also looks promising. This review and this one note “bottom firing speakers” which is not great. Also no fingerprint reader. Still it looks good, particularly at $100 off the original price. If I had to buy one today it might well be this one.

Shopping for Chromebooks is so frustrating. HP makes 17 machines named Chromebook x360 that all look pretty different. The “13b” is the only ARM one. Apple does so much better at marketing their laptops.

Insisting on ARM is really limiting my options. Maybe I should give up on that.

What I really want is an OLED screen. The only option I could find is the Lenovo Chromebook Duet 5. But it’s a detachable keyboard which doesn’t meet my “sturdy” requirement. In particular I need to be able to hold it by the keyboard and have the screen stay put. Could be an interesting alternative to my Samsung Android tablet though.

Update: needed this sooner than I expected so I ordered theHP Chromebook x360 13b-ca0047nrr for $409. Note this is slightly updated from the 13b-ca000 that until recently was the offering. The newer one has a faster MediaTek Kompanio 1380 and 8GB of RAM. Reviews for this machine are mostly positive with the main complaint being the screen is nothing special (1920x1080, 250 nits). I was sorely tempted by the Samsung Galaxy Chromebook 2 360 because it has an amazing screen: 2560 x 1600 and 350 nits. But the $450 model has only 4GB of RAM and a Celeron N4500 and reviews said it felt underpowered, even for a Chromebook. I’m going to keep using my Android tablet for high end video stuff so I’m OK with the better computer with the less exciting screen.

Update 2: ha, cancelled the HP order and am getting a Acer Chromebook Spin 714 instead. They’re on sale right now for $529. Compared to the HP laptop it’s a brighter screen (350 nits vs 250 nits), better speakers, and significantly faster (80,000 octane vs 30,000, according to videos). Downside is it’s not the ARM processor I was hoping for but, eh, that was a bit of a silly thing to stand on. The Acer apparently gets an honest 10 hours of battery life which is plenty (compare “up to 16” with HP).

I’ll add that hp.com is a miserable place to try to buy something direct. The ordering experience is OK but then it takes 2+ weeks to ship? Maybe it’s backordered. But then cancelling is a nightmare. There’s no automated order cancellation, you have to talk to support. Which takes 10+ minutes and involved three separate attempts to retain my order and/or sell me something new. And at the end of that I’m just told “we’ll try to cancel your order let you know in 48 hours”. So dumb.

Shelly heat/temperature + Grafana

I bought a little Wi-Fi thermometer, a Shelly H+T. Neat product; eInk display, wifi, runs on 4 AA batteries for a year. I don’t know much about Shelly but it seems fairly hacker friendly. In particular you can run the thing in local network mode and not use their cloud service at all.

Setting up Shelly

First challenge was getting the device up and running. The docs are good and there’s several routes. I went the WiFi only route (no Bluetooth); you plug the device in, get it into AP config mode by holding the reset button in the battery compartment. It creates a WiFi network for itself and runs a web server on 10.33.1.1 which you can then use to configure it. You have to work fast; even plugged in to a USB power source it seems to only want to run for 30 seconds before going in to sleep mode. The main configuration required is to tell it your wifi network details to connect to your LAN.

First step after that was to flash the firmware. Glad I did, they completely changed everything. Next step was to configure it to do something useful. Because it’s low power you can’t really poll the device, most of the time the WiFi is off. So instead it wants to push data.

Shelly is remarkably sophisticated and has a lot of thoroughly documented connection options. I chose MQTT with their default settings because it seemed the simplest path.

Setting up MQTT

I’m not a fan of MQTT, it’s too complicated. But it is a standard and there are tools. I found this guide helpful in getting started. It has you installing mosquitto for a MQTT server (“broker”), mosquitto-clients for testing, then setting up telegraf to be an MQTT listener for data logging to influx and thus Grafana.

mosquitto takes some config; by default it will only listen on localhost. You have to configure authentication. I used a simple username/password, probably “no auth” would be fine on my LAN too. Note this configuration has to occur before a line like listener 1883, defining which mqtt instance you’re setting up. (See what I mean about complicated?)

Then I pointed Shelly at the MQTT broker (no SSL, port 1883, username and password) and.. nothing. There’s a log file in /var/log/mosquitto but it didn’t have much useful in it. So I added connection_messages true to the configuration and then I could at least see that Shelly was connecting. No data logged to a file though.

To get the data you have to use mosquitto_sub to subscribe and listen to the data. There’s a concept of “topics”, which kind of events you listen to; # is a wildcard. You can also use mosquitto_pub to send test messages. Honestly to figure all this out I asked ChatGPT how to use it and it told me. Way easier than reading docs and it happened to work this time. (ChatGPT failed later producing telegraf configs.)

With all that set up I got Shelly logging overnight. It seems to log to two topics: shellyplusht-b8d61a8b17cc/events/rpc and shellyplusht-b8d61a8b17cc/online. The useful data is in the RPC.

The important RPC payload is a JSON blob method named NotifyFullStatus and a wakeup_reason of status_update. The data itself is in params and the key thing is data blocks for temperature and humidity.

Not clear on update frequency. When it was plugged in I was getting updates every 305 seconds or so. There was some status indication that suggests it wants to update every 600 seconds; I guess 300 is when it starts trying and the extra 5 is getting wifi online? On battery it updates less often, I think only when a measurement changes significantly. There’s a setting in the firmware where you can make it wake up for every change of 0.5°C or 1% humidity.

Anyway, Shelly is working and publishing to MQTT. Now to get the data somewhere useful.

Logging to Influx

Telegraph can take input from MQTT. It took some levering to get this working but I finally got telegraf to just store all the fields that are in the JSON data blog from Shelly. Here’s the config:

[[inputs.mqtt_consumer]]
  servers = ["tcp://127.0.0.1:1883"]
  topics = ["shellyplusht-b8d61a8b17cc/events/rpc"]
  username = "shelly"
  password = "hunter2"
  data_format = "json"
  # json_time_key = "params.ts"
  # json_time_format = "unix"
  tag_keys = ["method"]
  json_query = "params"

This logs all RPC messages from shelly; the useful ones with data but also other RPCs. It also logs all the measurements, many of which are not so useful, but it’s just easier this way and it’s only logging every 5 minutes at most.

Note the commented out date parsing. I’m sure I got that JSON key name right but telegraf couldn’t find it, at least in some of its inputs. I gave up. Instead telegraf will log with its own timestamp rather than the one Shelly reported. That’s OK most of the time but if Shelly buffers any data and uploads it in bulk it will be a problem.

Also the “tag_keys” seems to be useless. I was hoping to use influx tags to filter just on the NotifyFullStatus responses and not the other junk. No idea why but it’s not ending up in the database.

I probably should have tried json_v2 as the telegraf parser.

(An aside on testing telegraf with systemd. systemctl reload telegraf does work but sometimes delays, I think telegraf waits until the agent finished its last run. journalctl -f -u telegraf is a useful way to watch the telegraf log file. Shelly only logs every 5 minutes so it’s a slow process of testing.)

Calibration

A man with two clocks never knows what time it is. None of these devices are precisely calibrated so I don’t know for sure what’s right. Shelly has an option in the firmware to add a static offset for calibration so I can at least get it to line up with the Laseregg.

When I first was using it, my LaserEgg said 70.5°F, Shelly said 72.7°F. A Taylor thermoprobe (for cooking) says 71.5°F (both air and a glass of water). In general the Shelly is reading 2-3°F more than the LaserEgg and 2% less humidity.

But then I put Shelly in the fridge for 10 minutes, and it dutifully read colder. Then I took it out. Now 12 hours later Shelly and the LaserEgg are basically reading the same without me putting in a calibration offset at all.

Graph

Here’s 24 hours of my far-too-complex set of graphs of Shelly data. Top two are calibrating temperatures between Shelly and the Laseregg, bottom two are status just from Shelly. The weird dip in temperature is when I locked Shelly in the fridge

LED bulbs, Waveform Lighting

After last week’s article about LED lighting quality I noticed a lot of posts in the Hacker News discussion were praising bulbs from Waveform Lighting. So I ordered some to try. But they look too blue and I will be returning them. I’m flummoxed by LED lights now and am thinking I need some fancy color-tunable bulb.

Waveform Lighting sells high end LED bulbs: $18 for the typical A19, compare $3 for a basic Feit bulb from Home Depot. Waveform bulbs are supposedly better. A higher CRI (95 vs 90), a better spectrum beyond what CRI measures, and no flicker. Their website has a blog with a bunch of excellent semi-technical posts on it explaining what they do and why. I’ve been wanting high quality bulbs for awhile and they have a generous return policy, so I ordered some 3000K BR30 floods for my office / TV room.

They’re too blue.

When I turn them on low at night the room looks very blue. Way bluer than the old incandescents, which I expected. But also bluer than the 3000K Feit PAR30s I use. Nominally the Waveforms and the Feits have the same color temperature design; weird! The Waveforms also look too blue on a cloudy day. On a sunny day I don’t notice as much, presumably because the sunlight washes everything else out.

What’s weird is the measured color temperature of the Feit bulbs and the Waveform bulbs is the same. I measured this with an Android app. I didn’t calibrate the app so I don’t trust the absolute numbers, but the relative comparisons should be meaningful. The Waveform LED bulbs measured 4000K at all dimness levels; so did the Feit LED bulbs. The incandescents measured 3400K-4100K depending on dimmer setting. Those numbers are all about 1000 too high (calibration?) but otherwise plausible.

So why does the Waveform light look bluer to me? My only thought is it’s in some detail of color accuracy, that the Waveforms fill in more bluer spectrum than the Feits. I don’t have a way to measure that. But I know how it looks to me. The good news is I like the cheaper bulbs more! So that’s money saved.

Update: after a day or two with both the Waveforms and Feits in the same room I no longer think one looks bluer than the other. They seem a similar color temperature to me now. However there’s definitely a difference of some kind in color between the two. I can’t describe it and one doesn’t look better to me than the other. The room with both lights feels a bit cold / late night convenience store for me. It’s not objectively true but my subjective vibe is more “fluorescent lighting” than “candles”.

Desired color temperature

I think I’d prefer the Waveform bulbs in an application where they were turned on during the day to, say, light an office. I believe their claims the colors are more accurate.

But this is a room where I either stare at a computer screen during the day (don’t much care about the ceiling lights) or watch TV at night (want cozy dim lights). I think what I really want is a light that turns redder towards 2700K at low dim settings, them up to 3000K or maybe higher at full brightness. Philips sells “warm glow” bulbs that are exactly like that. But it’s not clear that’s a viable product. Now I’m contemplating programmable smart bulbs of some sort.

It’s funny, when I first learned about LED bulbs I was sure I wanted true sunlight 6000K bulbs. It’s natural! Turns out, at least in the west, we’ve all learned that cozy indoor lighting looks red like a fire glow. I put some 4500K bulbs in my shower and they look just terrible to me on cloudy days, like cheap fluorescents.

Other Waveform thoughts

I really wanted to like these Waveform bulbs. I’m happy to pay for higher quality!

They are good heavy bulbs. I take that as a sign they have a serious heat spreader.

I didn’t get any sense for flicker. I’ve never noticed flicker in any LED bulb.

I like the lens on the BR30s. The surface of the bulb is a smooth glow, not like the visible points of light in the cheaper Feits.

The Waveforms take about half a second to turn on after flipping the switch. Not a huge deal but it seems weird.

I’m testing with a 20 year old Leviton incandescent dimmer, which is not correct. The Waveform mostly works with it, but the minimum dimness is too bright. Also there’s a quiet buzz coming from the bulb at low dim levels. Both of those problems would probably be fixed with a proper modern LED dimmer. I’ll note the cheap Feits work fine with the old dimmer; another cost savings.

Starlink improvements during evening congestion

After collecting a week+ of data I think Starlink’s service has genuinely improved for me in Grass Valley, CA (residential service). The ISP had gotten very congested in the evenings; 5% packet loss, speeds under 10Mbps, games and streaming video not working well. Really frustrating. I first noticed this in February 2022. But sometime in the past few weeks it got better.

Measuring the improvement

Some basic stats comparing the last week (Mar 31 - Apr 7) to a typical week in February (Feb 7 - 14):

  • Average packet loss around 9pm: 1% vs 4%
  • Average packet loss for a week: 0.5% vs 1%
  • Latency around 9pm: 53ms vs 65ms
  • Average latency for a week: 50ms vs 50ms
  • Hours of download under 20Mbps: 3 vs 16
  • Average download: 115Mbps vs 105Mbps
  • Min download: 7.5Mbps vs 0.9Mbps

They key pattern here is that worst-case performance during the evenings is much, much better. Packet loss is the biggest change: Starlink has gone from 4% (with peaks of 10%) to 1%. But that shows up also as improved latencies. And maybe improved download speeds although that’s harder to measure accurately; the “bad hours” statistic I list first seems real though.

It’s interesting that average performance over a whole week didn’t improve much, just the worst-case performance in the busy evenings.

Thoughts on what it means

I’m thrilled with the improvement; things had gotten so bad in the evenings I couldn’t reliably use the Internet. Great job, Starlink! And well timed; they just opened up the area to more customers, i was afraid it was going to get even worse. It might still get worse again, and I don’t love Starlink’s pattern of degrading service and increasing prices. But this change here is a real improvement.

So what changed? I don’t know. But my guess is they deployed a better traffic shaping system. So that individual users are getting fairer sharing than they used to. That would be nicely in-line with their announced plans to add soft data caps. They’ve supposedly been throttling best effort customers all along but I wonder if the initial implementation wasn’t as good as what I’m seeing this last week.

The other possible explanation is more capacity. But I think that’s unlikely. They’ve launched more satellites in the past two months but not enough to explain this change. I don’t think they increased their satellite link capacity (or did they?). It’s possible they improved the infrastructure on the ground between the station and the rest of the Internet, but I don’t see much evidence of that.

I don’t really know what changed, but as a customer of Starlink I’m very happy to see the improvement.

Some graphs

Here’s a graph of packet loss and latency over the week in February, from before the change. The peaks every evening are evidence of a congestion problem.

And here’s a graph of the same data for the last week. See how much smoother it is? What an improvement!

Notes on measurement

All data comes from my automated test setup. Download speeds come from an hourly Ookla speed test. Latency and packet loss come from IRTT, a ping-like tool. I think they’re both reasonably accurate measures but I’m just doing some simple testing with basic tools. These are all scripts and graphs I’ve set up myself, using Telegraf and Grafana for data collection and a cheap VPN server in LA for the other end of the IRTT testing. I also have a second measure of latency and packet loss from pings to Google DNS; it confirms this pattern.

Starlink; improved latency and packet loss during congestion?

Not positive about this, but I’m seeing evidence that Starlink has improved performance in the evening congestion. Back in February packet loss would go up to about 5% and latency would jump from 50ms to 70ms during the evening hours, particularly 7pm-9pm. Now it’s only going to 1.5% and latency is staying steady around 50ms. There’s maybe a small increase in packet loss and latency in the evening but nothing nearly as bad as before.

I might also be seeing an improvement in my hourly Ookla speed tests. Feb 17 I got 9.3Mbps and 1.5Mbps at the worst hours (9pm and 10pm). April 3 it was 30Mbps and 27Mbps. Speed tests are so random I’m not confident about this.

I’m in Grass Valley, CA with residential service. It’s a congested area. Testing with IRTT, a ping-like tool. if I had to guess I’d say this improvement is recent, like in the last week or two. I don’t have good data because we’ve had a lot of snow-related outages here.

Here’s snapshots of before and after, from 2pm to 2am on Feb 17 and Apr 3.

February 17
April 3

That’s latencies and packet loss. For download speed, here is a 90 day graph of number of hours a day under 20Mbps. (Ignore the big red block of 24 hours; that was my backup ISP). These past few days have been really good; 0! This data is noisy enough I don’t want to read too much trend into it.

A simple Datasette experiment

Thought I’d give Datasette a quick try. I was curious about which countries were the most and least diverse. Seemed like a good simple use case for the data exploration tool. This is my first time really using it. I am trying to use higher level tools rather than write low level code that works exactly like I want. Here’s what I did. An hour or two of tinkering and learning here, maybe a little more.

Preparing data

Gathered data from Wikipedia: diversity and population. I used this tool to extract CSVs from the tables.

Manually edited the CSVs to change the column headings to simpler things without whitespace.

Installed datasette, sqlite-utils, and csvs-to-sqlite via pip.

Ran csvs-to-sqlite *.csv diversity.db to make a database.

Merged the two tables into one by using sqlite to run create table combined as select * from diversity left join population on diversity.Country = population.Country;

Removed an extra copy of the country name with sqlite-utils transform *db combined --drop 'Country:1';

Converted the population column from string to text with this code:

$ sqlite-utils convert *db combined "Population2023" '
try: return int(value.replace(",", ""))
except: return None'

$ sqlite-utils transform *db combined --type Population2023 integer

Querying data

And with that now I have a nice little web GUI. I used it to make a report of the diversity of large European countries. Which immediately yields a lot of questions about exactly how we’re defining diversity, but that’s not Datasette’s fault.

Thoughts

Datasette is cool, a nice generic HTML front end to tabular data.

Preparing data was more fiddly than I liked. I felt like Datasette and related tools wasn’t doing a lot of work for me I couldn’t just do in sqlite. For instance, I was hoping for a GUI in datasette for doing the join between the two sources tables. It will let you do the Datasette slice-and-dice on top of any sql, so you can have an ephemeral table where you write the join yourself, but I wanted a persistent table for convenience.

The management of the population column types seemed awfully awkward. My input CSV had quoted text-looking columns for the numbers like "233,319". The code uses pandas to import CSV files, which I thought was smart enough to parse those as numbers. Maybe there’s a way to get csvs-to-sqlite to import them that way. It’d be nice if sqlite-utils convert inspected the Python type and changed the column automatically. (There’s a -transform option but I think it only works if you create a new column.)

I was hoping for some way to do a chloropleth of the diversity measures, but no one’s written that plugin. Would be easy enough to export a CSV and use some other service to visualize. There are some map visualization plugins for Datasette but they seem oriented to working with lat/lon pairs, not country names.

It’s really cool how easy it’d be to publish this little set of data to some cloud service.

I’m surprised the integer columns don’t have separators in their display! “144713314” is hard to read. This would be an easy plugin I imagine.

Starlink as missile guidance

Interesting bit from a recent Economist article about Ukranian attack drones.

At an early stage the Ukrainians appeared to pin hopes for controlling drones behind Russian lines on Elon Musk’s Starlink satellites, which work at frequencies and in numbers that Russian systems struggle to jam. A naval-drone attack on Russia’s Black Sea fleet in October reportedly made good use of this gap. But Mr Musk, apparently worried about the escalatory effect of such moves, has stepped in where Russian technology proved unable to. Starlink now uses geofencing to block the use of its terminals—not only above Russian-occupied territory inside Ukraine, but also, according to a Ukrainian military intelligence source, over water and when the receiver is moving at speeds above 100km per hour. “You put it on a boat at sea and it will simply stop working,” he says. So Ukraine’s drone developers now use a range of other, more expensive communication systems, with multiple systems often on the same vehicle.

Migrating Joplin to Obsidian, metadata

I’m migrating from Joplin to Obsidian for my little personal notebook. Some notes on doing that with metadata for each note.

Migrating note text is easy. Joplin has an export-to-Markdown option that creates simple .md files that can just be dropped into the Obsidian vault directory. Done. However, that doesn’t preserve any metadata the note may have.

You can get Joplin to export the metadata as well by choosing “Markdown with Front Matter” as the format. That will add tags for each note, here’s an example:

---
title: My Note
updated: 2023-03-21 17:32:36Z
created: 2021-11-08 16:12:48Z
latitude: 37.30000000
longitude: -121.80000000
altitude: 0.0000
---

It’s the dates I care about most; Obsidian’s default UI shows these when you hover over a note as “Last Modified” and “Created”.

Last Modified is pretty easy; Obsidian seems to be using the file mtime timestamp. I wrote a little Python program that parses that date and sets the mtime on each file accordingly.

Created is harder or impossible. Unix and Posix have no way to store the creation time of a file. (There’s ctime, but that’s actually the creation time of the inode and can be demolished in various ways. Also there’s no clean way to set that on a file.) I’m not sure what Obsidian is showing; NTFS on Windows does store creation time so maybe that’s what it’s using? There’s reports of people saying it gets broken when you use Obsidian Sync, so it’s apparently not reliable. I just gave up on it. I’m honestly not sure why Obsidian even shows this in the UI if it’s not correct.

The other metadata folks often care about are tags. I never set tags in Joplin so I didn’t look at it. But I think it’s as simple as reading the tags from the Joplin export and then sticking them in the note as #hashtag style tags in the body of the note. Or alternately...

Obsidian does have a way to put arbitrary metadata in a note; frontmatter, just like the Joplin export. You can use that for tags as well. For now I’m not using those. Note as near as I can tell there are no standard metadata keys for note creation time, that’d be a solution to that problem. I think some parts of the plugin ecosystem have a standard set of metadata keys they use, maybe including creation.

Thoughts on Obsidian

Obsidian’s nice! Every single time the Joplin UI bugged me I realized I should try this obviously better thing.

Obsidian also has a very active user community. I’m leery of getting deep into a complex note taking tool; I’d prefer mostly just simple text files. But it’s kinda neat to see what complex things folks are doing with it, also all the plugins.

For syncing.. this is still an experiment, but my plan for now with Obsidian syncing is to use SyncThing. Now that I understand how SyncThing deals with conflicts I’m not worried it’s going to fail in some inscrutable manner. If that doesn’t work well I’ll buy Obsidian Sync. I confess I’m balking at the price; $100/year seems like an awful lot. Maybe I should think of it as paying for Obsidian itself plus the extra network feature.

I’ve installed it on Android too and synced following these notes. Seems to work so far.

I need a good HTML export option, I like to write blog posts in Markdown and then post them to my blog, which needs HTML fragments. There’s several plugins that do it, need to pick one. I’ve tried 3-4; the two “copy as HTML” result in nothing useful in my clipboard. One of the “save to file” ones does sorta work but sure generates a lot of extra CSS, etc to make the HTML look fancy. I just want a simple HTML fragment conversion.

Update

After a couple of weeks I really like Obsidian. I’ve switched entirely over to it. Mostly I just liked the UI; say what you will about Electron bloat but the web UI + command palette paradigm makes for some nice apps. (See also: VS.Code). I still feel a bit strange about how powerful and complex Obsidian can be. Folks on Reddit are sharing their 10,000 document knowledge bases full of interlinking. But it works fine also for just a few simple text notes.

SyncThing on the folder is working fine for me to sync between two desktops, a laptop, and two Android devices. I’d rather be using Obsidian Sync but can’t quite get myself to pay the price for it.

For HTML export I’m using Obsidian Enhancing Export, the consensus choice. It uses pandoc. Honestly it’s overkill but the HTML it produces is nice. In particular it does “smart quotes” in the output, something most of the other HTML exports don’t do.

Starlink v1 vs. an inch of snow

Snowing in Grass Valley (again). Last two times it’s done this Ken had to switch us to our backup fixed wireless Internet. I wasn’t home to look at it. This time around I am home. I was able to confirm Dishy says it’s heating (in the mobile app, also alert_is_heating: True in the gRPC). But flaky connection that became progressively useless. Starlink’s not supposed to have this hard a time with snow but it sure seems to. I’m glad I have a backup.

Here’s some network diagnostic graphs, both from Starlink’s gRPC status and from my own IRTT ping tests. Starlink shows definite problems with a sort of random assortment of statuses that all boil down to “no signal”. My pings show much higher latencies and periods of very high packet loss. All consistent with “shit’s broke, yo.”

I can’t easily access the dish (it’s on the roof) so wasn’t able to try to brush snow off. Or get a good photo, but what I could do suggests there’s a layer of snow + ice maybe half the thickness of what’s on the roof. I’m guessing we’ve gotten an honest inch of snow here, two at the most. Note I have an O.G. round dish v1; no idea if the newer v2 ones handle snow better.

Update: an hour or two later and we’ve gotten a proper.. 4 inches? Not sure. I happened outside to see the dish pointing straight up (recovery mode) and then watch it tilt to its new normal position. And a bunch of water run off. So the melting is working. OTOH there was still a bit of snow there, so it’s not working very well. Or maybe the signal is being blocked by snow in the atmosphere?

Either way I recall this working better in last year’s snow.

Update 2: Starlink was working again when I tried it about 3 hours after I posted this. The snow had slowed down and the face of the dish was completely free of snow, so the melting did end up working. The obstruction log did show 1.48 hours of “No Schedule” though so it was truly out for quite awhile.

Economist Android app: two bugs when changing font size

Finally figured out what causes a couple of bugs that have been driving me crazy in the Android app for several months now. Both are caused by changing the font size of articles (with the Tt button displayed at the top of every article screen).

The simpler bug is that if you increase the font size from the default, the last paragraph’s line spacing is incorrect. It looks like every other paragraph has the line spacing adjusted to match the font size but this last paragraph does not. This is 100% consistent and reproducible on both my phone and tablet. Screenshot below.

The more pernicious bug is that sometimes the navigation at the end of the article doesn’t work. It’s a bunch of links to other articles in the same section. But tapping them sometimes takes you to some other story, generally one or two above the one you tapped on. I think this is also triggered by changing font sizes. (Could it be the page is calculating tap zones based on the original font size layout, not the visible one?) I can’t reproduce it 100% reliably.

Broken line spacing
This navigation menu doesn’t work

Syncthing and conflicts (also Joplin)

I’ve been using Syncthing for several years now to sync several gigabytes of files, mostly various kinds of user-generated documents. Like my entire personal source code repository. Also my Joplin notes. Across 3-5 systems: Windows, Linux, and an Android device. It works great. I’ve never had to think about it much. But something went wrong with Joplin recently and I learned something...

Syncthing has no conflict resolution tool.

Seriously. Syncthing detects conflicts and does something sensible with conflicted files but does not offer any sort of merge tool or UI to help you know about conflicts and deal with them. I got confused because SyncTrazor, the Windows UI for SyncThing I use, does have a simple GUI Conflict Resolver. But there’s nothing like that in the main SyncThing web-based GUI.

All the core SyncThing does if it detects a conflict is try to guess which version of the file should be canonical. It has some heuristics based on modification dates and will prefer a modified file to a deleted one. It then renames the discarded version as <filename>.sync-conflict-<date>-<time>-<modifiedBy>.<ext>. That gets kept forever as a regular file also in your syncthing store and gets synced just like any other file. It’s up to you to notice these conflicts and do something about them; syncthing will not tell you about them. (Hilariously, you can have conflicts on conflicts and end up with files named ...sync-conflict-…sync-conflict -…-sync-conflict...)

I’m not complaining about Syncthing; what it does is very simple and understandable. Conflict resolution is hard and subtle, better not to do anything than do a bad job. Automated merge strategies are possible but fraught with dangers, and manually requiring users to merge is not in keeping with SyncThing’s background nature. OTOH I’m a little spooked that these potential errors have crept in without any visibility. It’d be nice if the Web GUI at least showed a count of conflicts, but maybe that’d just cause anxiety?

I’ve got about 50,000 files in my Windows Documents folder (synced between two PCs) and just today learned I have 27 conflicts. Mostly saved game files; it’s possible Steam Sync was also involved which no doubt causes all sorts of confusion. FWIW none of these conflicts have caused any problems, so maybe I don’t really need to care about them. I just deleted them; nothing was going to be reading those conflict files anyway. The 3 conflicts in my source tree worry me a bit more, they’re all in git repo metadata. But those git repos are working fine and git fsck isn’t complaining, so going to just delete those too.

How do conflicts happen? When two separate syncthing instances update the same file before they sync them to each other. This happens surprisingly seldom for me, I think because I have an always-on hub that everything syncs to and Syncthing seems to be watching the file system for changes and uploading them quickly. Conflicts seem more likely to happen on my Android phone where running in the background is a challenge and it may not sync at all when I’m not on WiFi.

Which brings me to Joplin. I’m looking at all this because I’d had a lot of problems with Joplin/Android and file sync. I recently encrypted my Joplin notes and something weird happened on the phone when it synced to it. Not sure what was really wrong but I just deleted all the conflicts my phone generated and I seem to still have all my notes. Joplin itself only syncs to local files every few minutes, then Syncthing itself only syncs those files to the hub every few minutes. Seems a little delicate.

Overheating Intel NUC

My 2018 home media server (an Intel NUC7i5BNH) is failing. It crashes under load; seems to fail when I use it for something intensive (like watching video via the Plex server there). Long story short, the hardware is flaking out; limiting the CPU speed to about 90% of maximum seems to make it stable again. Detailed notes on diagnosing and fixing it below.

When it crashes it locks solid; doesn’t respond to network, doesn’t send pings out (from an in-memory process), syslog doesn’t get updated, hard drive light doesn’t blink. Nothing in the syslog, it just stops writing, nothing in the dmesg file either.

Thanks to this blog post I realized telegraf was logging temperatures even though they weren’t on the dashboard graph. So I added them. Temperatures were going up to 84°C as the CPU load went up. That seems hot, but the CPU is rated to 100°C and looking online I see folks running NUCs at CPU temperatures of 95°C or more. (All temperatures I’m talking about here are from the CPU Package sensor.)

I installed the system stress tools s-tui and stress-ng and was able to crash the system again after stressing (with s-tui defaults) for 2-3 minutes, at around 83°C. Definitely crashing under load, but am not positive it’s temperature.

Thinking it was overheating, I figured the root cause is I added a USB drive to the system and stacked it on top of the NUC. It’s not blocking any vents or anything but will impede passive cooling. So I moved the USB drive. I also took the case off the machine and blew some dust out. When that didn’t work I took the thing apart and give it a proper cleaning, although I did stop short of removing the heat sink since that’d require new thermal paste. I also updated the BIOS and set the fan settings, raising it from “quiet” to “balanced” and eventually “cool”. The fan is definitely spinning and speeding up under load.

But I was still able to crash it with s-tui after just a couple of minutes. Even after all the cleaning, and running with the case off, it still gets to 83°Cish and crashes under load. 83° isn’t that hot! So maybe it’s not actually overheating but failing under some other stress? I wish I had a second power supply to test with.

A full run of memtest86+ passes.

I tried turning off turbo boost in the BIOS; that limits the CPU to 2.2GHz and never lets it run at 3.4GHz. This seems to help; under stress temperatures max out about 57°C. System still works under load after 45 minutes. Of course I’m losing a lot of performance. I don’t think this particular NUC lets you tune overclock parameters in detail, the options are not available in the BIOS.

I got most of my speed back by using Linux’s fancy drivers for controlling CPU scaling and power usage. intel_pstate is the name of the driver, this Arch doc page is a good start as are these RedHat docs. cpupower is the recommended userspace tool but the systemd service definition isn’t available on Ubuntu.

Turns out intel_pstate has a file interface at /sys/devices/system/cpu/cpufreq/. A simple thing is just to write a max frequency to the /sys interface files.

if grep -q i5-7260U /proc/cpuinfo; then
        echo -n "(nelson) throttling CPU in /etc/rc.local for flaky Intel NUC. Max speed: "
        echo 3000000 | tee /sys/devices/system/cpu/cpufreq/policy*/scaling_max_freq
fi

The system seems to be stable at 3.2GHz, just a bit under the 3.4GHz max. At 3.1GHz I was able to stress for a full hour and the system got up to 78°C but never crashed. I set the max to 3.0GHz just to be safe.

Still wish I knew what specifically was failing. I suspect it’s only going to get worse and I should be looking for replacement hardware now. Also curious what changed. December 14 the average temperature climbed from 37°C to 48°C; that’s when I upgraded from Ubuntu 20.04 to 22.10. All sorts of stuff changed then but the only obvious thing is that there’s a new behavior where average load creeps up from 0.15 to 0.2 over the course of a month (before, 0.15 steady was typical.)

Some graphs:

Temperature and CPU during a recent crash
Temperature for the last six months
s-tui after the system crashed

ChromeOS, Flatpak, and Obsidian

Bad experience with ChromeOS trying to install Obsidian following these instructions. I did eventually get it working but only with a bunch of ugly hacks as root.

Note the install instructions have you making bwrap setuid root. Ugh! I did not do that, because other things online say it isn’t necessary. I did try enabling setuid a few times and it didn’t fix anything.

First problem: flatpak just won’t work other than root. Even flatpak list gives me a “Permission denied” error (unhelpfully not telling me what permission is denied.) This happens even with bwrap setuid. I don’t know if that’s a general flatpak thing or is a problem specific to ChromeOS. Docs I’ve read online suggest that at least parts of flatpak shouldn’t require root but that installing software probably will. Whatever, I’ll just do everything as root. (At least part of the problem is /home/nelson/.local/share/flatpak ended up being owned by root and permissions 0700; this happened on Ubuntu too, so a Flatpak bug? But even fixing that, still couldn’t flatpak list on the Chromebox.)

Installing with Flatpak went smoothly. There’s now an Obsidian app icon in the ChromeOS GUI. But when I launch it either nothing happens, or the logo for Obsidian shows up but with an infinite spinning circle on top of it. No feedback on what’s wrong. The online advice for access to ChromeOS system logs is all out of date. I finally found my way to a log viewer at chrome://device-log/ but there’s nothing there about the app not working. The log dump generated from chrome://network/ does seem to have useful info but I could not understand what was failing.

OK, so let’s launch from a command line instead. An hour later, here’s a short transcript of all the breakage I encountered.

~ ⬢ [Systemd] ❯ flatpak run md.obsidian.Obsidian
error: Permission denied

~ ⬢ [Systemd] ❯ sudo !!
sudo flatpak run md.obsidian.Obsidian
error: "flatpak run" is not intended to be ran with sudo

~ ⬢ [Systemd] ❯ sudo bash
root ~ ⬢ [Systemd] ❯ flatpak run md.obsidian.Obsidian
Debug: Will run Obsidian with the following arguments: 
Debug: Additionally, user gave: 
[13 zypak-helper] Failed to connect to session bus: [org.freedesktop.DBus.Error.NoReply] Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
[13 zypak-helper] src/helper/main.cc:40(DetermineZygoteStrategy): Assertion failed: bus
/app/bin/obsidian.sh: line 40:    13 Aborted                 (core dumped) zypak-wrapper /app/obsidian $@ ${EXTRA_ARGS[@nelsonminar

root ~ ⬢ [Systemd] ❯ dbus-run-session flatpak run md.obsidian.Obsidian
... 
[0319/141600.942543:FATAL:electron_main_delegate.cc(299)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

root ~ ⬢ [Systemd] ❯ dbus-run-session flatpak run md.obsidian.Obsidian --no-sandbox
it worked!

So.. it has to run as root. Then it turns out it doesn’t want to run as root, at least via sudo. And then it needs access to the system’s DBus, which for some reason the Flatpak hasn’t set up. Then Electrno complains about root needing --no-sandbox so if I provide that option it works! Lololo.

Just a total mess of complex systems stuff that’s standing between me and my application. DBus, the Crostini container, the Flatpak container, the Chrome/Electron sandbox. Layers and layers of stuff and some of it is broken.

So a failed experiment, even if in the end I did get the thing running. To be fair to ChromeOS: this is really not what that product is designed for. A Linux program, Flatpak, a separate Chrome/Electron instance. Yeah, don’t do that. I suspect if I need to do this for real I’ll just end up using the Android app running on the Chromebook and put up with the less-than-optimal mobile UI.

Joplin works again on Android

I’ve been using Joplin for a few years now as my note taking app. It’s mostly good but has some rough edges. But there was one ugly thing; Android file system sync was broken for most of a year, without acknowledgement. I used this to sync my machines (via SyncThing for the files). This got fixed a few months ago with Joplin 2.9 but then that release was never pushed to the Google Play Store, making it much less accessible to users.

Happy to report that my phone currently has Joplin 2.10 from Google Play and filesystem sync is now working. The UI is still a little awkward but it seems to be functioning. (With some delay; Joplin is not super swift in re-syncing.)

The whole experience has left me with a sour feeling about Joplin. Maybe that’s not fair; it’s a free open source project. And it’s remarkably complex, supporting a bunch of platforms and sync methods. The underlying technical issue (Android file system permissions) was genuinely complicated. OTOH the developer didn’t handle the bug very well and between that and the Google Play release problem I get the impression he doesn’t much care about the Android platform. Also the UI really is clumsy in a lot of ways.

Another bug / UI problem: I just enabled encryption on my Windows desktop. It re-encrypted the notes and synced them. Then I went to my phone and tried to synchronize and got some generic error (“TypeError”) that suggested data was bad. So I manually turned encryption on in the phone app (it should have turned itself on) and now my phone is very slowly encrypting and re-uploading all its notes again. This is bad! In general the encryption implementation seems wonky.

Alternatives

So maybe I need an alternate notetaking product again. It seems like a simple product but then it needs to be really well designed and reliable, so that it becomes a piece of your memory and not some hated complex app. The main things I need are syncing between Windows and Android (and/or ChromeOS) and good Markdown support. And a good UI for displaying and editing markup.

There’s a lot of note apps out there; here’s a recent roundup of 7. Simplenote was the first I used and loved. I stopped using it because notes aren’t encrypted. Although ironically I never turned encryption on with Joplin because of my sync problems. I switched to Standard Notes for awhile but the price went to $50/year and it had so many UI problems I didn’t want to pay that. So I switched to Joplin.

I’d try Google Keep but the UI is like a clown circus. Evernote is way, way, way too complicated. So I’m sticking with Joplin or now. Maybe I should just pay for Joplin Cloud, that would have solved my Android sync problem.

1Password has a pretty functional little notes app in it, btw, but it doesn’t have the Markdown UI stuff I want, not its intended purpose.

Anyway, Joplin seems to be working for now. If I see something better I’ll try it. If Joplin breaks again I’m going to consider going back to Simplenote. I love how Automattic supports this little product.

Update: thanks to a comment from reader Gina I tried Obsidian, a closed-source Electron app. I like it! The UI is very nice, I particularly like the default Markdown editing mode where the markup syntax is hidden except for the line you’re editing. Also despite all the fancy features it has the basic data model is “text files in a folder” which is refreshingly transparent. The app has a well-used plugin architecture with a lot of third party plugins. It supports advanced things like a canvas, a graph view, and links between notes, but the basic stuff is pretty solid. I hope they aren’t going down the Evernote road of increasing complexity.

I was able to import from Joplin by exporting markdown from it, although I couldn’t get the updated/created metadata to come over (this might be fixable; joplin does export the dates). Obsidian doesn’t encrypt data files on local disk but supports end-to-end encryption in their $96/year cloud sync product. It also looks plausible to sync yourself via SyncThing, but you won’t have the fancy extra layer of conflict resolution that Joplin sync provides. All in all it looks like a very promising product.

Google Pixel security disaster

There’s a major, bad security flaw in Google Pixel phones and some Samsung phones

allow an attacker to remotely compromise a phone at the baseband level with no user interaction, and require only that the attacker know the victim’s phone number.

This notification has been published despite the bug not being patched. Google’s announcement blames Samsung; it’s their modem software that has the flaws and apparently they “hit their 90-day deadline” for disclosure and so now it comes out in public. Even so, Google decided to withhold the worst details because fixes aren’t out.

There is a patch for Google Pixel phones, the March 2023 security update. But that update isn’t available yet for my Pixel 6 phone; rumor has it that it might come out March 20. (Part of a pattern of late updates for what should have been a flagship product.) In the meantime, well, my phone could be owned at any moment. More discussion on Reddit.

The recommended workaround is to disable VOIP (“WiFi calling”). Which I’ve done, and which makes my phone basically useless. The cellular chip in the Pixel 6 Pro has never worked reliably, its connection performance is terrible. Also Verizon hasn’t gotten around to building cellular infrastructure in obscure, non-techy places like Noe Valley, San Francisco. At least I still sort of have cellular access; folks using T-Mobile and Google-Fi phones apparently are left without any way to make calls at all (I guess it requires Voice-over-LTE?)

Google really screwed up with the Pixel 6, it’s been a frustrating phone to own. I’d told myself the next phone I’d buy would be from Samsung but, well, they’re really the root cause of this problem. Apple often does seem to do a better job on building devices that work.

Nightly congestion: Starlink vs local WISP

I’ve complained a few times about Starlinks congestion. This past week we switched over to my local WISP (snow outage, then I’m not there to switch it back). Here’s IRTT measuring packet loss and latency, you can clearly see the change around March 4/5.

The WISP is also congested, I think probably worse than Starlink. During congestion it has lower packet loss but then higher latencies, and for longer periods of time. I assume that means the WISP is doing more buffering. My WISP connection is 2 radio links from the wired infrastructure (I think).

Chromebook first impressions

I got my first Chromebook, a cheap machine just to try it out. I like it! I’ll probably end up getting a fancier Chromebook to replace my 2017 Razer Blade laptop when I travel. I’d love to get one that could also replace the tablet I use for books and videos.

ChromeOS makes a great first impression! I’d not realized it’s basically a whole new desktop OS, a third way other than Windows and MacOS. (And I guess Linux on the desktop, lol.) It’s an interesting middle ground between a full desktop OS and a mobile OS like a phone or tablet.

I can’t quite decide whether I’ll want to use a Chromebook like a desktop computer or like a tablet. ChromeOS seems squarely in the middle. I think it could basically replace what I use a tablet for (reading books, watching videos, light web surfing) if I could find a Chromebook where the keyboard gets out of the way. Assuming the UI works well as a touch screen, which it seems to with tablet mode. These are marketed as “2-in-1” devices.

I ran into a problem with hardware though; no one makes the Chromebook I want as a tablet replacement. Part of the problem is price; Chromebooks tend to be under $400 and so don’t use very high quality screens, etc like the $800 Galaxy Tab S8+ I’d be replacing. (Although see Samsung’s Chromebook 2, 4K Chromebook, HP Dragonfly Pro, or this article). Part of the problem is mechanical. I’d love a “detachable” where the keyboard comes entirely off like the Lenovo Duet 3. But then the keyboard attachment is not a strong hinge, which means you can’t reliably support the weight of the whole machine with the keyboard while sitting or propped up in bed. Maybe one of the 180° folding screens would work better. Really need to get my hands on them to see.

The other big question is CPU type: ARM or Intel. I firmly believe ARM is the future for devices like this. But I’d say 80% of the Chromebooks out there are Intel, a few even AMD. And the ARM systems tend to be the cheaper / lower powered ones. No one is making anything like Apple’s laptops for ChromeOS, Linux, or really even Windows.

The machine I bought is an Acer 311 C722-K4CN, aka N20Q9, aka willow. It cost $120 on Amazon (new!) and is marketed as a school / student laptop. I think these were first introduced in 2020 for $350, mine was built in Feb 2021. It’s definitely not a powerhouse, $120 implies a lot of compromises, but so far the hardware exceeds my expectations other than screen quality. I deliberately chose an ARM system; it’s a MediaTek MT8183 which is maybe 2-3x more powerful than a Raspberry Pi 4 CPU? It seems powerful enough for web browsing at least. No HDMI, microSD, and limited USB ports.

First thing I did was update ChromeOS from v88 or so to v105 and now v111. A little surprised it’s a 32 bit build; the CPU is definitely 64 bit. I also installed Linux via the official route (“Crostini”) it’s a VM, arch reports aarch64. From what I’ve read on ARM the ChromeOS kernel is 64 bit but the userspace is 32 bit. I wonder if that’s partly a RAM savings thing?

Chrome OS is quite big; 14 GB! The Linux install wants another 10 GB (although 3 GB seems sufficient.)

One hassle: there aren’t ChromeOS apps for everything I’d expect. Particularly surprised there’s no Slack app. Slack works in a browser though, and Chrome makes it easy to “Create Shortcut” so it looks more like a separate app in the GUI.

I’m also a little confused: there’s both a “Web Store” and a “Play Store”. I think the Play Store is for Android apps, they run natively on ChromeOS now and many things (like Tailscale) are installed as generic Android apps. The Chrome Web Store is a mix of things for the Chrome browser (like extensions) and then some ChromeOS enhancements like a compose key input method (which is written in Javascript). There isn’t a whole lot on the Web Store.

Google has good docs for building Chrome OS apps. The basic message is “it’s an Android app with special accommodations for Chromebooks” with observations like “every Chromebook has a physical keyboard” and “A system-level back button is a pattern carried over from Android’s handheld roots—one that doesn’t fit as well in a desktop context.” It’s remarkable how many different kinds of systems Android runs on: phones, tablets, laptops, TVs, Android Auto, Android Automotive. That’s a lot of different UI metaphors!

I use Firefox everywhere else but feel like I should be using Chrome as my browser on a Chromebook. I mean, it’s in the name. Also the whole OS is basically one big Chrome instance? Firefox does work but it is the mobile Android app, not a desktop app. Without proper tabs, and the wrong user agent, and... I guess it’s possible to install a Linux version but I haven’t tried it.

The Linux support is interesting. It works via a system called Crostini which seems a bit like WSL2 in its approach; it creates a VM with an LXC container, then installs Debian inside that. See also the wiki here. You can install Arch Linux and Ubuntu, albeit with rough edges. Note Crostini is different than replacing ChromeOS with a full Linux install; that’s also often possible on Chromebook hardware. Crostini supports graphics via both X11 and Wayland. Crostini is an evolution of crouton, an earlier system for running different OSes inside ChromeOS.

The underlying Android system is mostly hidden in Chrome OS but accessible. Ctrl-Alt-T will launch crosh, the Chrome OS shell for the host OS. This isn’t a full Unix shell, it’s got its own weird command set, but ping and top are there.

I thought I would hack the OS a lot more but one joy of a Chromebook is it mostly works just fine and doesn’t need a lot of tinkering. I do want to eventually get a full development environment for Python and web frontend. Between the Linux system and VS.Code it seems entirely doable.

One big caveat: ChromeOS is designed as a cloud-centric system and definitely wants to be online all the time. It’s possible to run things offline but you have to do a little preparation. Honestly computers are mostly useless to me offline anyway, I can’t go 2 minutes without having to look something up on the Internet. As long as I can read a book or watch a downloaded video on an airplane, I’m good.

Tailscale key expiry

I had my first real problem with Tailscale. Not coincidentally, six months after first using and loving it. Tailscale expires keys every 180 days and you have to manually re-authenticate every single host. This is the first bad user experience I’ve had with Tailscale, the product is usually much friendlier.

I got no notice that this expiration was coming. And it’s potentially catastrophic; what if your host is unreachable except via Tailscale? (See below). I don’t use Tailscale a lot and I don’t have any proper monitoring. Maybe if I were paying closer attention I’d have known it was coming?

The rest of this note is a little ranty because I’m experiencing the indignation of a sharp corner on an otherwise very nicely designed product. Tailscale folks, I love your product. This part of it needs some attention. To be fair, key management and updates are a hard problem in all of software, Tailscale is not unusual.

How to update Tailscale key

Re-authenticating isn’t hard with the CLI: just run tailscale up --force-reauth. This gives you a URL that you load in a browser logged in to Tailscale’s management console. It’s a remarkably manual process. The Android GUI client is a little easier; you’re prompted to log in directly on the device itself.

But here’s the shit sandwich: “tailscale up --force-reauth currently involves bringing down the Tailscale connection and thus should not be done remotely over SSH or RDP.” Can confirm; I tried to update a remote host via ssh over Tailscale and the update hung before I saw the authentication URL. A terrible experience for a networking product whose major purpose is remote administration of machines. And the auth process is interactive, you can’t just fire it off in a cron job or something. (There’s a hint that maybe there’s a “Reauthenticate” option in the dashboard after a machine “has already signed a new authentication URL” but I no longer have an expired host to test that with.)

I do give the product team credit, they did think about the “what if I can’t access the host to update it?” problem. There’s a button you can press to temporarily enable an expired key (for 30 minutes), giving you access. You still have the “how do you update remotely” problem but at least you can get to the host.

There may be a better way to do all this; you can generate auth keys and automate using them. Maybe a more serious Tailscale deployment is managed that way, I haven’t looked into it. The default keys are a great user experience right until they expire.

Determining Tailscale key status

The software tools for detecting whether your Tailscale key is expired are not good. The best tool is the Machines dashboard; this does have a status line and you can filter for expired machines.

On a host with an expired key your first clue that something isn’t working is probably when you can’t access other hosts on the Tailnet. tailscale status reports a confusing message, “Health check: not connected to home DERP region 12. Logged out.”. If you try tailscale up it will prompt you to reauthenticate and afterwards tailscale status will keep showing you the auth URL until you reauth.

On a working connected host elsewhere on a tailnet tailscale status does not show you if another host has an expired key. The status shown is - which I think means “unknown”. It’s not offline or some special expired status. tailscale ping will report peer's node key has expired.

I could not find a way to see what machines were soon to be expired in the machine dashboard; the keys page doesn’t show the automatic keys that the default path uses. The command line tools don’t seem to tell you either, or at least I can’t find it. I guess you can periodically tailscale up --force-auth to refresh the keys but it’s up to you to know when to do that? Again, I assume using managed auth keys is the real solution for this.

Why expire at all?

I don’t quite understand why Tailscale expires host keys at all. There’s a general idea that expiring logins, etc is good security practice to solve various corner cases like a years-old server that gets recycled or is running an old insecure version. Sorta? But for that kind of thing I much prefer a system where an old auth token is only expired if it has not been used for awhile; expiring something that was trusted just minutes ago seems like a bad decision.

It’s possible to disable key expiration for specific hosts via the machines dashboard. The docs suggest this is for “trusted servers, subnet routers, or remote IoT devices that are hard to reach.” There’s no way to disable expiration for a whole tailnet; all you can do is set the expiration time from 1 to 180 days.

Windows update

This isn’t about key expiration really, but the Windows client still has no auto-updater. I was still running 1.30 with a security hole! They’re working on it (and recently changed the installer they use) but it doesn’t seem a high priority. Installing an update is easy enough but it really needs to be automatic.

Renting an electric vehicle

I had my first real experience with an EV these last two weeks, renting a Polestar 2 from Hertz to drive around the Ft. Lauderdale area. It was great! The Polestar 2 is a nice car, a comfortable sedan, more or less a Volvo S60. It’s a competitor to the Tesla Model 3 or maybe Model S. I miss the car and now wish I owned one! I used this as an opportunity to learn about how EVs work, these are my notes. I also posted about it as I was going on Mastodon.

Charging

The question “how do I charge this car?” almost stopped me from renting an EV. I’m glad it didn’t! It wasn’t as easy as filling up at a gas station but it wasn’t hard, and the free electricity + parking you get as a perq in some places kind of made up for it. There was a learning curve though, the variety of charger types is confusing. Hertz didn’t have much useful information for me.

The car has a 78kWh battery and about 220 miles of useful range. It uses 0.32kWh of electricity per mile. I was staying entirely in the urban area between Ft. Lauderdale and Palm Beach, so no experience of long distance trips far from chargers.

The first thing I learned about is the difference between slow, fast, and rapid chargers (or level 1, 2, 3). Slow / Level 1 is what you get with an ordinary AC socket, which in the US tops out at 1.5kW, so you’re getting 5 miles per hour of charging or 40 miles overnight. Not useful, I never did it. Fast / Level 2 is higher power AC, typically around 8kW. These are the ubiquitous chargers you see in parking garages, etc, and are often free. (See the green markers in the map above). It’s also what you’d have in your home. Fast charging is more useful; picking up 25 miles in range while having lunch for free is nice. But for a real fill-up you need a rapid charging station, a destination facility like a gas station. See the orange markers above. These have 50-150kW chargers and can fill a whole battery in under an hour.

Rapid chargers are what you need when far from home. There are not nearly enough of them, particularly between cities. And a typical location only has 3-6 chargers, each one occupied for up to an hour at a time by other cars. Also often several chargers are broken, none of these facilities are staffed and seem to be out of service for days at a time. Electrify America is one common brand, and expensive! But frequently found at Walmart locations. My favorite was an FPL Evolution charger in Wilton Manors, conveniently near a store and a good coffee place.

The other confusing factor is charger compatibility. There’s basically two options: Tesla and everyone else. In the US newer non-Teslas use the J-1772 connector at fast chargers and a J-1772/CCS combo at rapid chargers. Voltage and power are auto-negotiated. My Polestar had an adapter that let me charge with a Tesla fast charger and I think there’s some work towards making Tesla rapid / superchargers work with other cars, too.

EVs don’t want a full charge; it’s not good for the battery. Mine came pre-set to stop charging at 80%. The charging slows down towards the end too; that first 50% is very fast, up to 150kW (or more?) but it slows down to 50kW as it gets near the top.

Finding a charger proved pretty easy. I used the PlugShare app mostly. The Polestar maps app also has a database of chargers although it wasn’t quite as complete.

Paying for a charge was awkward. Many of the chargers want you to install their own proprietary app, even if the charge is free. I ended up with a small collection of apps and accounts, a hassle similar to paying for parking with an app. Electrify America had actual credit card readers, like a gas pump. That seemed great at first but one reader was broken and also then I didn’t have an app to easily check on my charging status as I went out shopping.

All in all charging wasn’t a big deal but it was definitely more planning and mental load than just putting gas in a car. A lot of this complexity was all about being in a rental car at hotels. If you own an EV you’ve probably made some arrangement to charge it at home, in which case most of the time you don’t need a public charger at all. For that matter one of the places I stayed had a free charger for guests; nice amenity!

Driving differences

The most fun thing for me was seeing how Polestar has re-considered the concept of car-as-product. Much like Tesla has.

It mostly drives like a normal car but not entirely. There’s no ignition! Just sit in the car and go. Gears are forward, reverse, and neutral. If you take your foot off the accelerator the car slows pretty aggressively, regenerative braking. This saves power and also means you can mostly drive with just the one pedal. Also the car doesn’t creep forward if you don’t have your foot on the accelerator. Both things too some getting used to but I ended up liking them quite a bit, they make sense for an electric motor. You can configure the car to simulate these gas engine legacies if you want.

A nice side effect is there’s no stigma of sitting in the car parked with the AC blasting cold air and the radio on. Just chilling in your portable living room. Sure, you’re using some battery, but that’s OK. There’s no gas engine idling, making noise and smell and waste.

The car controls and electronics are fully reimagined around a touch screen tablet and an Internet connection. No knobs for A/C, stereo, etc. The core software is Android Automotive. I found the UI very simple and straightforward with no unpleasant surprises. Maps works, car status apps work, all simple. I had a hard time figuring out how to turn the AC on. And finding the home button to get to the main UI. But those were both one-time things and once I learned them they were fine.

All in all it’s a nice car to drive. I was similarly impressed with a Tesla Model S when I test drove it. Reconsidering the car product and UX is a good thing.

Cost

I rented the car from Hertz at a nominal $53/day. That’s a pretty great price for a relatively high end car like a Polestar; I’d have expected to pay as much as $100/day for a gas car of that quality. Hertz seems to have made a major effort to promote EV rentals, they do a lot of Teslas too. I suspect they’re buying the cars at a discount, good marketing for Polestar.

Charging costs were anywhere from free to $0.30/kWh to $0.45/kWh. The car uses about 32 kWh per 100 miles, so it works out to $10-$14 per 100 miles if you’re paying for electricity. The similar Volvo S60 gets about 30 miles / gallon, so with $3.35 gas the combustion engine car costs about $11 per 100 miles. Bottom line, it costs about the same per mile in energy. Unless you skim electricity off of free chargers!

Hertz provided the car at 67% battery and told me to bring it back at 60% or more if I didn’t want to pay a battery recharging fee. I don’t remember what that fee was but it seemed about in-line with what you’d be charged if they had to add gas.

Summary

I really liked the Polestar 2. I miss it! I may end up buying one, or something similar. I’d gladly rent one again but if I were taking 100+ mile trips far from towns I’d consider the charging infrastructure available carefully. In a big US city, charging was only a minor hassle.

Starlink: snow outage

We got a lot of snow in Grass Valley, maybe 12 inches? Starlink works well in snow in general; not much signal fade, even has a heater to melt snow. But it stopped working last night around 5:25pm, just as the snow was stopping. I don’t exactly know why or if the heater was engaged. But it fixed itself in the morning.

My monitoring shows the dish started reporting “no downlink”. After a couple of minutes of that the dish started reporting azimuth and altitude of 0/0. Exactly 0/0, so I think that’s an error state and not a real measurement. (Also 0 is the horizon?) We unplugged it from our monitoring system so I don’t have any further info. After we plugged it in again this morning it’s working normally. It’s 30°F outside and it does not say it’s heating itself; I imagine the system only heats when it detects signal degradation, not just that it’s cold.

Starlink: worse service, higher prices

Starlink has announced a $10 price hike ($15 for some), the second in less than a year. Meanwhile in that time service has significantly degraded: cutting speeds from 100 Mbps to 20 Mbps, adding a data cap, increasing packet loss and evening congestion, and an SLA that promises as much as 15 minutes of downtime a day. It’s all kind of dismal.

But it also is a successful product because for many in the US, including me, Starlink is the best option they have. Years of not investing in broadband infrastructure left many of us with no good Internet option. Starlink is truly better in many ways. The main mistake they made was wildly overpromising before launch. I’m glad the FCC figured out they couldn’t deliver before handing them $900M based on their promises.

Weirdly the company announced tiered pricing: $120/mo for customers in heavily subscribed areas, but a discount to $90 in sparse areas. On Reddit it looked like about 10% of customers got a discount, so this is basically a price hike for almost all of the US.

I fear the Starlink product is going to keep getting worse; they keep adding customers. They are adding satellite capacity too but it hasn’t been keeping up in the US. Meanwhile they have way more capacity than customers in most of the rest of the world. It’s a difficult business.

Calorie Counting apps

I’m doing calorie counting, something I’ve found effective for managing my weight as long as I can stick to actually tracking everything. It’s a pain in the ass but being mindful about what I eat helps. Which means the tool I use for counting calories is important.

Boy, are the tools out there terrible. I’m using MyFitnessPal but other apps seem the same.

My immediate rant is the absolute garbage that’s in their food database. They are very proud to advertise they have 11 million entries. Like this one, where cream has the calorie density of enriched uranium:

Last night I had some delicious Königsberger Klopse. I had a sensible amount of the sauce, maybe 2 tablespoons of cream. How many calories was that?

Well according to the screenshot above, 5175 calories. No wonder I’m so fat! Mind you this database entry has a little green checkmark which supposedly means it’s verified good data. About as “verified” as Musk’s Twitter Blue, I guess. The image on right shows there’s a zillion different options for recording amount, a confusing mix of metric and imperial, volume and weight.

There’s three different ways to record “tbsp”. Depending on which you choose, 2 of those are 104 calories, 690 calories, or 5175 calories. Just total nonsense. And I can’t even use their edit workflow to fix it; apparently this particular item was entered by MyFitnessPal themselves so there’s no easy way to report an error.

This example is particularly bad but the database is full of all sorts of bad data. I don’t begrudge being off by ±10%, whatever. But there’s plenty of just wrong information, incomplete descriptions (is that yogurt sweetened or not?), and a lot of made-up-fiction where some other user hallucinated a number. Still particularly annoyed to see this error in a so-called verified item.

Database issues aside there’s all sorts of other problems with the actual tracking flow. The variance in ways of measuring things; volume vs weight, and the units. Many items have gram to ounce conversions so you can use either, but not all. Sometimes it’s not clear of “ounce” means weight or volume. A lot of things get listed as “1 serving” or “1 slice” which is meaningless.

I have a lot of other complaints too. The fad now in food tracking is macros, recording fat, carbohydrates, etc. I’m sure that’s helpful for some people but for me it’s too much; I’m having a hard enough time tracking just one number. Worse, MyFitnessPal decides to scold me about the other numbers I don’t care about. Entering my 2 tablespoons of cream comes up with a warning like “your daily goal is 97 grams of fat and this item has 22 grams”. That kind of nagging is actively harmful to my goals and I can’t figure out a way to turn it off. I did tell them my goal was 10 kilograms of salt a day, so at least it’s not harassing me when I eat a pickle. Don’t tell my doctor.

There’s a lot of other apps, maybe some are better. But what I really want is a real leap in food tracking. I have a theory that with contemporary AI you could build a tracker that works solely based on a photo of the food and maybe a little extra data: the weight of the dish, maybe a note like “made with extra butter”. I have no proof that’d work of course but I hope someone tries.

Ubiquiti, RFC3442, and Starlink routes

I’m still trying to find a solution for the problem I have with a router bug and Starlink. First, a meta commentary. A friend teased me for all this writing about Starlink and routers. Let me just say it sucks. Trying to understand a broken Internet connection without the means to really fix it is intensely frustrating. The router is a bit more in my control and I’ve come to the conclusion Ubiquiti’s newer routers just have bad software. Next time I work on this I’m going to try an OpenWRT router again, maybe the SmoothWAN variant with channel bonding.

I have a USG 3P router. Ubiquiti has a router bug where static routes don’t work with WAN failover. Starlink looks like a normal ISP gateway, with DHCP advertising a route to the internet. But it also has a special hidden route for 192.168.100.1 so you can access Dishy’s stats. The easy thing to do is add a static route. This works fine on the Ubiquiti router unless you have WAN failover enabled (a backup Internet). Then the static route breaks. This is a known bug discussed for many years now.

(An added complication; Starlink’s dish also listens at http://34.120.255.244/. Not sure why but I’d hoped maybe this would work even without a special route for it, since it’s a public IP address. No such luck.)

My reader Daniel Y wrote in to suggest an interesting fix: install this rfc3442-classless-routes script to run as a DHCP exit hook. Starlink advertises the extra routes via a DHCP option. Which Ubiquiti apparently ignores? It’s apparently necessary for some European ISPs, and it’d sure be handy for Starlink. This script will set them. As a side effect Daniel said this also fixed the other bug I was talking about, where the router just ignores the DHCP lease in certain scenarios. I worked around that bug by inserting an ethernet switch between Dishy and the router so the ethernet link stopped going down.

Anyway, I tried the RFC 3442 script and it didn’t work for me. I did some debugging... First, it looks like my USG 3P has the RFC3442 routes even without this script. Maybe Ubiquiti did implement it afterall? (Daniel has the older EdgeRouter, most discussion is about those.) Second, the script gets invoked in a way it doesn’t seem to be expecting; there’s no $reason environment variable set so it doesn’t work. I hacked around this and tried adding routes with ip route add like the script would and nothing worked.

It’s a weird failure. Here’s the routing table according to ip route or Ubiquiti’s show ip route

default via 100.64.0.1 dev eth0  proto zebra
10.33.1.0/24 dev eth2  proto kernel  scope link  src 10.33.1.31
34.120.255.244 dev eth0  scope link
100.64.0.0/10 dev eth0  proto kernel  scope link  src 100.103.201.245
127.0.0.0/8 dev lo  proto kernel  scope link  src 127.0.0.1
192.168.3.0/24 dev eth1  proto kernel  scope link  src 192.168.3.1
192.168.100.1 dev eth0  scope link

That sure looks good to me! So why can’t I reach 192.168.100.1? Even explicitly doing ping -I eth0 192.168.100.1 doesn’t work.

My suspicion, without evidence, is that failover on the USG 3P is implemented in some complicated way that totally bypasses normal IP routing. That the routing table I see there doesn’t work. That doesn’t explain why the explicit ping-through-an-interface also fails. Honestly it’s all just such a black box. A broken black box. Ugh.

Random other Ubiquiti bug: their UI only supports RSA ssh keys. Can’t use Ed25519 or the other newer key types. Crap like that makes me cranky.

Starlink and BBR congestion control

I improved my download throughput with a simple change, enabling TCP BBR on the server. This all from a tip from an online friend who I’ve been sharing technical Starlink info with, I’ve been learning a lot from him. There’s a guide here.

I didn’t test this very carefully but casually observing an rsync transfer at 8am, when Starlink is quiet... With the default cubic congestion algorithm the transfer was bouncing around between 5 MBytes/s and 12 MBps. After enabling BBR I got more like a steady 12 MBps. Eyeballing it, I got 2x the throughput! Could be coincidence though, Starlink performance is so variable. I should test more carefully with iperf3 -C but am too lazy.

Ubuntu 22.10 by default uses the cubic congestion algorithm, use sysctl net.ipv4.tcp_congestion_control to verify. Enabling BBR is as simple as running sysctl -w net.ipv4.tcp_congestion_control=bbr. This will load the tcp_bbr kernel module and enable it. You can edit /etc/sysctl.conf to make it permanent.

Worth noting BBR is a change you need to make on the high bandwidth sender, typically the server. It can’t hurt on the receiver but I don’t think it will help either. There doesn’t seem to be an easily installable BBR for Windows. But it’s very easy to enable on a Linux server!

The guide I linked also suggests using FQ queueing and considers TCP window scaling. I didn’t change those. FQ has a good reputation on a router device.

What is TCP BBR?

TCP congestion control is one of the more important parts of Internet magic that makes things work. Basically it detects when a network link is getting overloaded and slows down transmits, trying to find the optimal throughput. The details of how it does that are remarkably subtle and have changed over the years. I’ve often wondered if Starlink’s wildly variable throughput and ambient packet loss were bad for existing algorithms. Maybe so, and maybe BBR is better?

TCP BBR is a Google innovation dating to 2016 or so on its way to becoming an IETF standard. They reported a 4-14% improvement after deploying it on YouTube. An analysis here shows the improvements are not big for a high quality link but are enormous at 1.5% and 3% packet loss; that’s more like my Starlink situation. Classic TCP congestion control interpreted packet loss as a sign of congestion. But it could also just be a flaky wireless medium. A modern algorithm designed to do more subtle modelling of the connection could definitely improve things, particularly for a Starlink client with 1%+ packet loss, 100% jitter, and varying maximum throughput.

I didn’t do a deep dive into understanding all of TCP BBR. Geoff Huston has a great writeup. And there’s Neal Cardwell’s formal paper and this video about the paper. The gloss I got from looking at these is that BBR is explicitly building up a model of the link characteristics and testing to update or revalidate it frequently. That’s a good deal more complex than “react to lost packets by halving the rate”, the core of the classical algorithm. It’s no surprise that as computers have gotten better there’s more room for doing more sophisticated traffic shaping.

Setting up SSH in 2023

I’ve been using SSH for over 25 years now. Haven’t really re-evaluated how I do that in a long time. I’ve been using the same 2048-bit RSA key since 2007. And mostly without an ssh agent of any sort, typing my key passphrase (or worse, Unix password) like a barbarian. So I’m setting up something new.

I’m struck by how little has changed. I might have gotten something wrong, feel free to comment. The Arch docs were a primary reference for me.

For advanced users, the things I learned this time are: ed25519 keys, that the ancient keychain is still the tool of choice, and that it doesn’t work well with agent forwarding. Really, keychain? Has nothing changed in 20 years?

Generating a key

Go to a secure Linux box that’s been up for at least a few minutes (so it has some entropy in the random numbers) and run

ssh-keygen -t ed25519 -C "name@example.com 20230212" -f id_2023

Two files will be generated: id_2023 and id_2023.pub. The first is your private key and while it’s passphrase protected, best to keep it secret and safe. You can spread your public key far and wide. It will look like this

I’m following Github’s advice here on the type of key. 3072 bit RSA is the default and is probably fine. ed25519 is a fancy elliptic curve that a lot of folks like. I like it because the keys are shorter, not that it matters much. The comment includes a date it was generated; ssh doesn’t store that in the key file. Be sure to set a strong passphrase when prompted.

$ cat *pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEKye4EydeuVQ8h5wG8GyluQ5+RK7BeaW76d0aYchiUj nelson@monkey.org 20230212

$ ssh-keygen -lvf *pub
256 SHA256:nJE3PwWMgAhll0EDbmBCNRwEUG2AOHwtNJa6hnIOrco nelson@monkey.org 20230212 (ED25519)
+--[ED25519 256]--+
|B=%&B+=+.. o.    |
|++.O*oo. .. ..   |
| .o.+   o o   .  |
| . .   . + o .   |
|...     S   o    |
|+oo          .   |
|o=               |
|o .              |
|oE               |
+----[SHA256]-----+

Authorizing a key

Now that you have a key you can use the public key anywhere to authorize it. The whole public key is just one line of text so you can easily copy and paste it. Append it to ~/.ssh/authorized_keys and now most Linux machines will let you log in remotely with it. There’s also the fancy ssh-copy-id tool which will append the key for you.

Some websites like GitHub will let you add your key, generally you just paste in the one line from the .pub file.

Using a key manually

The simplest way to use a key is just name it on the command line

ssh -i ~/.ssh/id_2023 example.com

If all goes well you’ll be prompted for the passphrase for the key instead of your Unix password. I find this is a little confusing and unpredictable but ssh -v helps me sort out any problems. The “-i” flag to explicitly name the key isn’t necessary if you use one of the default filenames like id_rsa or id_ecdsa. You can also put stuff in ~/.ssh/config to name a key to use for a particular host.

Using ssh-agent and keychain in Unix tty consoles

Typing your passphrase all the time sucks. ssh-agent will maintain a persistent copy in memory of your unlocked key and use it automatically. eval `ssh-agent` is the easy way to start it, but you have to do that in every shell (and remember to kill it when the shell ends!).

The better solution for Unix console / ttys is keychain. keychain is a wrapper for ssh-agent that maintains a persistent agent process running all the time, even when you’re not logged in. (Sounds dangerous! But handy.) In a tty environment there’s an easy way to start it, just drop this in your .bash_profile

eval `keychain --eval --agents ssh id_2023`

Keychain will look for an ssh-agent and attach to it if it can. Otherwise it’ll start one and prompt you to type your passphrase to unlock it. It’s a chatty program, you may want the --quiet flag. Also it is a little obnoxious if your id_2023 file doesn’t exist on the machine, so my login script checks for that (see below)

You can run keychain --stop all to remove all agents. There’s also a --timeout option.

Keychain vs agent forwarding

SSH agent forwarding lets you forward your ssh credentials so they can be used on the remove server after you log in. The private key stays on your original machine but the intermediate machine can query your ssh agent to log in to further machines. It’s very handy if you regularly bounce through one host to another. You have to manually enable ssh agent forwarding for each host you log in to in your config file (see the link).

keychain interacts badly with agent forwarding; it’ll ignore that you have a working agent and override it with one running locally. So it’s best to only run keychain if there’s no agent already defined in SSH_AUTH_SOCK. This is what I have in my .bash_profile

SSH_KEY=$HOME/.ssh/id_2023
if [ -z "$SSH_AUTH_SOCK" -a -e "$SSH_KEY" ]; then
        eval `keychain --eval --agents ssh "$SSH_KEY"`
fi

GUIs for Keychain

All this setup is for 1970s Unix tty user interface. A modern system from the 1990s has a GUI. I used to have ssh-askpass wired up in my X session so I’d type my passphrase once per X GUI login, it was great. I’m sure MacOS folks have something similar, maybe using Apple’s own keychain. Windows also has some GUI ssh agents but none of them seem designed for a WSL-centric work mode. I’ll probably just stick to the tty thing unless it gets really annoying with VS.Code, the only Windows GUI program I use that uses ssh.

Passwordless / restricted access

All these instructions assume you have a passphrase you have to type to unlock your key. It’s possible to generate ssh keys without them, very useful for automation. But it’s also dangerous; now all your security is in the privacy of the file only. There’s ways to restrict an ssh key to only be able to run certain commands to make that safer. I’ve done this a couple of times but it makes me nervous.

Yubikey / FIDO

Ultimately ssh-agent is storing an unencrypted version of your login key in memory. Best practices now are to use a secure hardware device of some sort to store that key, particularly a Yubikey plugged in to USB. There’s support in OpenSSH for keeping your key on a Yubikey. Also for generic FIDO authentication, which I think will ultimately let you use the OS own secure enclave for key management. I bet MacOS already has a good system for that and Microsoft is working on it. I’m not using any of that, I’m content with 1970s-era security apparently.

Starlink outages

Starlink has a nice outage report. I got the data off the dish via gRPC and have been logging it. It’s interesting. There sure are a lot of outages. The service description says “99% uptime” which is not a very ambitious goal; 1% downtime is nearly a quarter hour a day. In practice I have several minutes of outages a day, although some may be specific to my site.

That’s about 105 hours of outage data. Total of 11.7 minutes of outages, or about 99.8% uptime.

About 40% are attributed to obstructions; I do legitimately have a minor obstruction. But there’s something like 10 satellites in view of my house at all times now and in theory Starlink is supposed to switch away anticipating an obstruction. Not sure why that doesn’t just give me no obstructions in practice but I think the switching is not as robust as I’d like.

The other 60% are about half “No Pings” and half “No Downlink”: the mobile app calls these “Network Issue” and “No Signal Received”. I have no idea what causes these or how the dish knows that “No Signal” is not “Obstruction”. They all seem to be failures of the medium though.

My main question is whether these obstructions are legitimately obstructions and cutting down a tree would make a difference. A friend has an install with a full clear view and he tells me he still gets obstructions logged but “not often”.

The mobile app (wisely) divides up outages into categories: 0.1s+, 2s+, and 5s+., Even an 0.1s outage is noticeable to a video stream or gaming session but eh, it’s pretty minor. 2s+ is a significant problem. I didn’t measure how many of my outages were 2s+ but you can kind of eyeball it in the graph above.

Below is a screenshot from the mobile app’s outage log. I’ve highlighted two outages: a 15s “network issue” at 9:32am and an 8s “obstructed” at 9:48am. The second one terminated an open TCP session I had, I think the first one might have also. Both are accompanied by at least a little “no signal received”. My take on this is Starlink’s satellites failed entirely twice this morning, at least for several seconds.

ISP connection monitoring with IRTT

I’ve set up some new monitoring for my Starlink residential connection recently, using IRTT as a sort of very fancy ping tool to measure latency and packet loss. Here’s a couple of screenshots

24 hours
1 hour

IRTT is a carefully written round trip measurement tool. I have it set up to send a small UDP packet every 100ms to a server in an LA data center at 45.66.249.240, very near where my Starlink connection goes after the satellite hop. The IRTT server responds immediately with a reply and the software records the round trip time and packet loss. (It also records asymmetric delays and other things that I’m skipping over.) I do these requests for 58 seconds once a minute and record the results for the last minute in the graph above.

The top graph is for a full 24 hours. Packet loss first, then round trip time, and finally a graph of Starlink’s data traffic. From 13:00 to 15:00 I downloaded something big (a game from Playstation). You can also see the evening congestion around 18:00 to 22:00.

The bottom graph (in green) is also packet loss and RTT but for one specific hour, the busiest 19:00 to 20:00 hour. The third IPDV graph is more or less a measure of jitter in RTT.

Interpreting

So what does this all mean?

First I want to highlight a top line number: my average packet loss is 1.5% for the whole day. That’s horrible. My packet loss on a great fiber ISP like Sonic is essentially zero. Even at very quiet times like 5am, Starlink packet loss is still around 0.5%. I realize satellite radio is inherently unreliable but I’d have expected with enough capacity that retransmits in the link layer should paper over most of that. Then again Starlink reports an “obstruction fraction” of 0.6% with obstruction duration of about 800ms every 20 minutes. So maybe this is related to my particular site. At a busy time, like 19:00 to 20:00, I’m at 5% packet loss when some minutes at 10% or more. I can definitely feel those using the Internet, it’s not good.

Another thing to highlight is the jitter in round trip times. At the busy 19:00 hour it’s 44-86ms RTT with 10ms standard deviation. Note these are min/max based on averages over one minute; individual packets can take as long as 400ms to get a reply (or maybe more?) The quiet hour is surprisingly bad too, 33-75ms with 8ms SD. The per-packet variance isn’t as bad as during a busy hour but it’s still notable. (I don’t have great visualizations of this data, I should focus more on it.)

One big pattern is a jump in packet loss and round trip during my download around 13:00. This is expected for a typical Internet node. It’d be nice if some traffic shaping lowered the RTT hit from the download but that’s hard and this basic behavior is is pretty common for an ISP. I’m OK with that.

The second big pattern, and much more problematic, is the increase in packet loss and RTT during the evening hours even though I’m not using my link myself. This is the #1 evidence of Starlink’s congestion and is getting worse over the months by every measure. They are overselling their capacity.

More Work

So that’s some preliminary results. Lots more to do. As I said above, I should do more to characterize the extremes of behavior; the 400ms round trips, the strings of 15 lost packets in a row. Those are more important to user experience than hour-long averages; you notice when the video pauses or the game disconnects you.

IRTT also logs details on every single packet and I should do more with that information. Someone I’m chatting with has some very interesting visualizations showing millisecond-scale phenomena in the connection, including visible changes in latency when the connection hops to a new satellite. Neat stuff!

IRTT is a good tool but not ideally suited for continuous monitoring. It wants to run to completion and then produce a report of summary stats like average RTT. (I run it every minute; for 58 seconds to give the last run time to finish before the next starts.) I’d rather have something running continuously and reporting exponentially weighted moving averages or the like.

I should get more serious about measuring my obstructions; they are certainly the cause of some of the packet loss I see, but not much. The Starlink app shows a log of obstruction events but I haven’t figured out how to get at it in my own code, it must be in the gRPC data somewhere.

A Note on Correctness

Trying to measure this stuff in a consumer setting is difficult. I am not running a lab here. But I do try to get it right. Everything is wired ethernet. My network connection is mostly pretty quiet. I did this testing with three different servers, the data above is from the best one. (A second server in LA showed occasional transient packet loss spikes; I suspect the cheap VM I’m on gets deprived of network or CPU occasionally.)

BTW one nice thing about these tools is they don’t use a lot of bandwidth, like 6 Kbps each way. It’s a much nicer way to measure connection health than speed tests. And the continuous UDP stream seems a better measure of real application experience than ICMP pings.

My Starlink rotated

My Starlink dish moved itself in the past week or two. It was pointing due north, azimuth about 1-2° east of north according to old data. Now it’s visibly pointing a bit west and the software tells me it’s at -19.7°. It’s visible in the cool 3d view of obstructions in the mobile app, too. Elevation is currently 64.0; it used to be 65.

For the past month or two there’s been reports of dishes pointing themselves towards the oceans for coastal users. The speculation is they’re trying to squeeze out more capacity, getting folks who can to use previously unused bandwidth over the oceans. That seems like a good change to me!

The one downside is some folks report how they had a clear view to the north and now the dish is pointing itself straight at a tree. That seems avoidable, the firmware knows where obstructions are. Maybe they haven’t gotten to it yet. In my case the westerly view is actually a little better than due north; I have one tall tree in the north east that was obstructing about 1-2% of the view. Now it’s a little less although I can’t quite prove that out with numeric data. See the tiny smidge of red here; it used to be more.

CO2 and Cognition

Last year I blogged an aside comment about how higher carbon dioxide concentration makes you dumber, based on this 2021 article. It turns out that the story is a little more complicated. See this Hacker News comment for one reference. Or even better, this 2020 overview by the Naval Submarine Medical Research Laboratory: Stressors Present in a Disabled Submarine Scenario: Part 2. Effects of Environmental, Mental, and Physical Stressors on Cognition.

Page 22 has the relevant details on CO2 and cognition. Here’s the gist of it (quote heavily edited)

the relationship between CO2 exposure and cognition is debated ... While some studies have found that elevated CO2 may impair cognitive functions including decision making, attention, mental efficiency, and mathematical processing, these findings are not consistently replicated. In fact, many studies have been unable to establish a relationship between CO2 exposure and cognitive deficits.

There’s more in the article and it is full of citations of 50 years of research; well worth a look if you want detail.

One thing that seems particularly important: is more CO2 by itself a problem? Or is CO2 a proxy for stale air and there’s lower oxygen or some other confounding contaminant like carbon monoxide? I imagine every good study controls for this but it’s hard to know in your own home.

To get a sense of scale, normal atmospheric composition is 200,000 ppm oxygen to 400 ppm carbon dioxide. A little more CO2 isn’t going to actually displace a meaningful amount of the O2 you are breathing.

WinCompose and other ways to type Unicode

I’ve long wanted a good general purpose Unicode input method on Windows. To type so-called “special characters” like ñ or ü or ű. MacOS has a great way of doing this; long-press a key and a popup appears. Both Android and iOS have something similar. Windows doesn’t. I do a lot of cut-and-pasting.

There’s a bunch of Windows solutions that don’t work very well. You can choose an input method that includes more than US English, but that’s intended more for regular typing of one specific character set than the diverse one-offs I need. There’s the ancient numeric keypad method but it requires knowing the Unicode code point number for the character. I’ve tried some Windows programs that emulate the MacOS long press UI but none worked reliably. PowerToys has Quick Accent but the default activation key (space) is too easy to activate by accident.

WinCompose may be the solution I want. It gives you a compose key; you press Right Alt, let go, then type a mnemonic key sequence like ~n to insert ñ. Some of the sequences are pretty arbitrary and there’s a lot of silly macros like TF for “table flip like a boss”: (ノಥ益ಥ)ノ彡┻━┻. But I think I can guess or learn most of the characters I want. One particular thing to remember; a lot of emoji are defined by pressing Compose-Compose and then typing the name of the symbol. Ie Alt-Alt-JOYSTICK to get 🕹️.

One thing missing from the default compose tables is the ʻOkina, the character used in Hawaiian for a glottal stop. Along with ñ it’s an important character for writing US English place names correctly; the state is properly Hawaiʻi, not Hawaii. The character in Unicode is MODIFIER LETTER TURNED COMMA (U+02BB). The question is how to type it.

I’m going with ``, <grave> <grave>, pressing the upper left key that’s also ~ twice. I found that definition on this random site and it seems pretty reasonable.

    <Multi_key> <grave> <grave>                     : "ʻ"    U02BB   # MODIFIER LETTER TURNED COMMA (Okina)

Not sure this is the best choice. <grave> <grave> already has a meaning in WinCompose: “ which is U+201C, Left Double Quotation Mark (also used in kragen’s xcompose configuration). Overriding it causes no problems and anyway there’s other ways to type it: Compose < ” for instance. This X11 man page suggests <grave> <grave> is the beginning of a bunch of Cyrillic characters but those composed diacritics look pretty unusual to me, maybe not essential.. Anyway this is going to work for me.

It’d be nice to have a standard. I filed an issue with kragen’s config opening the question. It seems to be a good place to define some sort of standard.

I should add that the compose key has a long history in Unix computing dating back to the VT220 in 1983. XCompose, the X Windows system for this, is a defacto standard. WinCompose basically implements XCompose and uses the same config file format.

More Starlink product failures

Been a bad month for Starlink.

The ISP service had a meltdown a week or two ago, see my previous blog posts. For a week+ there were a lot more dropouts. Then there was a 12 hour period of massive packet loss. My connection fixed itself 2023-01-22 at 22:40 (California time). My guess is they were doing experiments with traffic shaping that failed badly.

Starlink announced last fall they were imposing data caps in December. Then they pushed it back to February. Today, Jan 31, we learn it’s now “April at the earliest”. They don’t actually communicate these slipped deadlines to customers; the only way to learn about it is to read the terms of service document and see if they changed it.

A lot of Starlink v2 folks are finding their dishes are failing this winter. Best guess is it’s the cable connector at the antenna. (It’s a proprietary cable, costs $60-$100, and may not ship for a month+). There’s a lot of suspicion it’s related to dish heating in winter.

Starlink support has never been great but recently got much worse. I submitted a ticket complaining about service quality and it took 13 days to get a response. Lots of reports on the Reddit of a month+ without a response to things like “you said you shipped equipment and didn’t” or “the dish arrived but doesn’t work” or “I’ve been offline for 6 weeks now”. Here’s someone billed for service they haven’t received yet. Folks are starting to file FTC and FCC complaints; those do get a swift reply.

It’s just not going very well over at the Starlink division. It’s so frustrating. The service is an amazing engineering accomplishment. It worked great the first year until the company decided to sell to more customers than they have capacity for. Now it’s nearly unusable in the evenings. And all the execution around the product that you need in a consumer business is just terrible.

Not clear it’s going to improve either. From what I’ve seen they can only find a market in the US with our far-flung lousy Internet infrastructure. Other rich countries in Europe and Asia don’t need satellite Internet because local infrastructure is better. And the places that do need it, most customers can’t afford $100/mo for Internet. They have far too many customers for their capacity in the US and nowhere near enough customers where they have excess capacity. I wonder how much money they’re losing.

UDP metronome vs. Starlink

I created a custom tool for monitoring network connections. Here’s some notes on what I learned from it and what I plan next.

I wrote the tool in a couple of hours. It uses aioudp to send a UDP packet to a server every 100ms or so, the server reflects it back. This very vaguely mimics application traffic. I then log back whether the reply came back in order and how long it took. Data is sent to influx and graphed with Grafana. 1 second timeouts or packets out of order are marked as “errors”.

I left this running with the client behind Starlink and the server on my lightly loaded reliable machine in a datacenter. Quick and dirty and there’s some things I’d improve in the timing of packet sends (it only sends after it receives the last one, so slow RTT means fewer packets), but it got me some data pretty quick. However I’m going to stop running it because it’s kinda sloppy.

Going forward I am going to look at irtt for the network testing. It’s a ~5 year old program that does something similar with UDP to monitor connection latency. But written and tested much more carefully than mine. I haven’t dug into what all it can do but it seems to the task. This experiment made me realize it’s much more useful to graph anomalies and shifts in the general trend, not the basic sequence of successes you expect.

I was a little worried about this high frequency testing but the volume isn’t so bad. My data packets are about 20 bytes, so call it 50 bytes total for the packet (including headers) or 0.5 kbytes/sec or 43 megabytes a day. It’s negligible.

Starlink on a normal day

Here’s a graph of the data after a full day. For each slot I’m graphing the mean RTT and the max/min for the time interval. The scale here is about 1 minute a pixel, so there’s up to 600 packets being measured. Errors peak at about 10, or under 2% packet loss.

I like how this shows the daily congestion so clearly. The heavy line of mean RTT in the second graph is very clear; you can see the latency creep up from 100ms to 150ms in the busy times of day. The max/min also spreads significantly, showing the jitter. (Standard deviation just follows the same trend as mean.) The error rate graph at the top is also illuminating. Unfortunately I screwed up here because most errors are timeouts (1 second) and that delays my dumb code from sending another packet, so at 100% packet loss I’m only possibly getting 60 packets a minute through, not the 600 I intended.

For comparison here is a graph from ICMP pings in the same time interval. This shows roughly the same pattern of evening congestion, particularly in the packet loss red dots. But the picture with mean RTT isn’t nearly so clear. Not sure why that is but I think it’s because of my higher frequency sampling with the metronome; 600 a minute vs. 4 x 5 packets a minute with the pings.

One thing that’s instructive with this high frequency data is to graph every single packet. Here’s 1 minute worth of data representing 400-600 packets during a bad time when 11 of those packets got lost. You can see the spread of latencies is just all over. It should be 100ms but some packets are taking 4x as long.

Starlink’s bad day

I lucked out and got this monitoring running on 2023-01-22 when Starlink was having a bad day. I managed to capture the bad behavior and its fix pretty clearly.

You can see a radical change around 22:40 (22:41:27, precisely). Before then error rates were very high and latency was all over the map. Suddenly it smooths out; almost no lost packets, steady latency, and a lower minimum latency. Starlink changed something. FWIW here’s a closeup of the transition.

Starlink nearly unusable for real time apps

My Starlink connection has tipped over to being unusable for real time apps. It’s still OK for loading web pages although slower than the minimal 20 Mbps service level. But real time apps like gaming are completely broken right now. This is in addition to the weird DHCP problem I blogged about earlier today.

The main overriding problem with Starlink is still congestion. The service gets very slow every evening, bad enough I can’t reliably watch a single TV show on Amazon, Netflix, or Plex. They have oversold their capacity.

The new problem is some weird thing where the whole connection drops out for 1-2 seconds. Lots of reports on Reddit summarized here. It’s mostly gamers who notice this but it must affect video calls too. This feels like a new significant problem and it’s hard to guess what it might be.

I should add that Starlink’s support is terrible. Many folks on Reddit report going weeks with no response. To big simple things like “you said you shipped me hardware but it did not arrive” or “my service has been entirely offline for a week and I suspect my hardware is broken how do I get a replacement?”

Here’s some data monitoring. First a basic ping graph of the particularly bad last hour.

Look at that; 5% packet loss over an hour. Latencies all over the place from 50 to 200ms when it is working. Outages of minutes at a time. It’s not even prime time for congestion yet, still 5-6pm.

Today I wrote a new custom monitoring app I’m calling “metronome”. It sends a UDP packet to a server every 100ms. The server reflects it, the monitor measure round trip time. I wrote this to more closely monitor something like a game application; I don’t love using ICMP ping for connection monitoring. Also it’s nice to have something so high frequency. It’s still a little buggy but giving some useful results. Here’s a graph of that same hour; see those clusters of 200+ms? Ping to that server is about 100ms.

A change?

Edit: woke up this morning to 12 hours of data. Something changed abruptly at about 22:40 (local time); packet loss went way down both on my UDP metronome and my old reliable ping graph. There’s still a wide spread of jitter in the metronome but that slowly improves as it gets towards midnight and later, which is consistent with residential user congestion. The download speed graph at bottom (once an hour) confirms the usual nighttime congestion pattern.

Total guess here but I suspect Starlink is experimenting with traffic shaping algorithms and whatever they were doing before 22:40 was really not working. Either that or something was just broken. Glad to see basically no errors though. There’s no evidence of the 1-2 second microoutages I was seeing this last week. Need to try my game or something to confirm at an application level.

BTW this visualization is very sensitive to how I graph it in Grafana. The green graph at top is drawing max(rtt) every 200ms and leaving it blank / white if there’s no data (the jankiness before 22:40). My app logs data about every 100ms when the network is working, which results in a nice smooth green area after 22:40. I like this but it’s pretty slow & demanding on the graphing software. The usual Grafana graphs average on a time-scale appropriate level, like every 5s in this graph, but then all that averaging gives a very smooth picture that hides the packet loss and jitter. I need more direct visualizations of the variance. The error graph is one measure (it’s just a count of errors per time interval). I should try graphing the literal variance or SD.

Starlink vs Ubiquiti OS: outages with WAN failover

I’ve got a problem that’s recently gotten worse on my LAN. Starlink will stop working and my Ubiquiti router fails over to the backup. But then it never switches back even though it looks like Starlink is up. It appears to be a DHCP failure; my router can’t get an address for the Dishy interface.

Sometimes rebooting the router fixes it; that suggests it’s a UnifiOS problem. Sometimes I have to turn Dishy off for 10+ minutes and then it starts working again, suggesting it’s a Starlink problem. Or maybe it’s more complicated. Today when this happen I rebooted the router but not Dishy. It started working after a minute or three.

This problem has occurred off and on for two years but is now happening about once a day. Rebooting the router seems the best way to get it working again. But I think the problem has fixed itself at least once (after several hours). I may also have had to turn Dishy off entirely for awhile to get things working.

I know from other sources that Starlink’s ground infrastructure has some sort of reset that happens if Dishy is offline for a few minutes, so often unplugging for awhile fixes things. I also know DHCP has to go all the way through the satellite to the Starlink ground station, so if the network is overloaded it’s not as reliable. But this big failure happens at quiet times too, like just now at 7am.. Finally I know UnifiOS also has bugs in its failover system. So many bugs; I probably won’t buy another Ubiquiti product.

An idea for a fix.

I’m trying a fix right now, putting a Netgear ethernet switch between my router and the Dishy PoE injector. I’ve seen signs in the logs that maybe the ethernet link is failing. And coming back, but maybe that’s not working right? I’ve heard other folks suggest a switch may help smooth out problems.

DHCP Logs

I’ve got logs from the router. They are spammy so I’m narrowing in on just the DHCP part like this. grep DHCP *.1.log | grep -v eth1. Here’s what it looks like when things are going well:

2023-01-22T15:02:21,354 <30>Jan 22 07:02:21 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T15:02:21,440 <30>Jan 22 07:02:21 ubnt dhclient: DHCPACK from 100.64.0.1

2023-01-22T15:04:34,843 <30>Jan 22 07:04:34 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T15:04:34,918 <30>Jan 22 07:04:34 ubnt dhclient: DHCPACK from 100.64.0.1

2023-01-22T15:07:03,124 <30>Jan 22 07:07:03 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T15:07:03,208 <30>Jan 22 07:07:03 ubnt dhclient: DHCPACK from 100.64.0.1

Starlink leases are 5 minutes. So the router requests a new address from the 100.64.0.1 endpoint it knows about every 2.5 minutes and all is well.

Here’s what it looks like when it fails:

2023-01-22T15:07:03,124 <30>Jan 22 07:07:03 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T15:07:03,208 <30>Jan 22 07:07:03 ubnt dhclient: DHCPACK from 100.64.0.1

2023-01-22T15:08:37,364 <30>Jan 22 07:08:37 ubnt dhclient: DHCPRELEASE on eth0 to 100.64.0.1 port 67

2023-01-22T15:08:45,935 <30>Jan 22 07:08:45 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
2023-01-22T15:08:45,988 <30>Jan 22 07:08:45 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2023-01-22T15:08:45,988 <30>Jan 22 07:08:45 ubnt dhclient: DHCPOFFER from 100.64.0.1

2023-01-22T15:08:52,524 <30>Jan 22 07:08:52 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67

2023-01-22T15:09:07,104 <30>Jan 22 07:09:07 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
2023-01-22T15:09:07,171 <30>Jan 22 07:09:07 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2023-01-22T15:09:07,171 <30>Jan 22 07:09:07 ubnt dhclient: DHCPOFFER from 100.64.0.1

2023-01-22T15:09:14,163 <30>Jan 22 07:09:14 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67

2023-01-22T15:09:25,674 <30>Jan 22 07:09:25 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
2023-01-22T15:09:25,766 <30>Jan 22 07:09:25 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2023-01-22T15:09:25,767 <30>Jan 22 07:09:25 ubnt dhclient: DHCPOFFER from 100.64.0.1

The log starts with one working exchange. Then 1.5 minutes later my router spontaneously sent a DHCPRELEASE out to Starlink. Um, why? After that my router starts DHCP from ground zero, broadcasting DHCPDISCOVER and DHCPREQUEST on the link to 255.255.255.255. It’s lost all DHCP state. It logs that it got a DHCPOFFER from 100.64.0.1 and that’s good, right? But apparently Ubiquiti didn’t like the offer or ignored it because it just tries again in a few seconds. It gets stuck in this state, sending DISCOVER several times a minute, getting offers, and never working.

Here’s what happens after I reboot the router. Starlink didn’t come back right away after the reboot but did start working pretty quickly, within a minute or so.

2023-01-22T16:10:58,089 <13>Jan 22 08:10:58 ubnt shutdown[3967]: shutting down for system reboot

2023-01-22T16:13:28,518 <86>Jan 22 08:13:01 ubnt sudo: pam_unix(sudo:session): session closed for user root
2023-01-22T16:13:28,567 <86>Jan 22 08:13:01 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh -c echo \"LAN\" >/sys/class/net/eth1/ifalias

...

2023-01-22T16:13:34,806 <30>Jan 22 08:13:08 ubnt dhclient: DHCPDISCOVER on eth2 to 255.255.255.255 port 67 interval 6
2023-01-22T16:13:34,809 <30>Jan 22 08:13:08 ubnt dhclient: DHCPREQUEST on eth2 to 255.255.255.255 port 67
2023-01-22T16:13:34,809 <30>Jan 22 08:13:08 ubnt dhclient: DHCPOFFER from 10.33.1.1
2023-01-22T16:13:34,811 <30>Jan 22 08:13:08 ubnt dhclient: DHCPACK from 10.33.1.1

2023-01-22T16:14:16,367 <30>Jan 22 08:13:49 ubnt dhclient: DHCPREQUEST on eth2 to 255.255.255.255 port 67
2023-01-22T16:14:16,381 <30>Jan 22 08:13:49 ubnt dhclient: DHCPACK from 10.33.1.1

2023-01-22T16:14:16,408 <30>Jan 22 08:13:49 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2023-01-22T16:14:16,470 <30>Jan 22 08:13:49 ubnt dhclient: DHCPACK from 100.64.0.1

2023-01-22T16:16:14,856 <30>Jan 22 08:16:14 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T16:16:14,912 <30>Jan 22 08:16:14 ubnt dhclient: DHCPACK from 100.64.0.1

So the system requests reboot at 08:10:58 and finally reboots at 08:13:01. 7 seconds later it makes a DHCP request on eth2; that’s my backup WAN. It works. No hint of anything on eth0, the primary WAN which Dishy is plugged into. Why? But it gets around to asking for eth0 at 08:13:49, 41 seconds later, and it works. Another routine request succeeds at 08:16:14. We’re back online with Starlink.

More logs

Those samples above are all logs filtered on “DHCP”, but maybe important stuff is hiding in the other log spam. Here’s more detailed logs of the failure around 07:08:37 when the mystery DHCPRELEASE happened. Still doing a bit of filtering egrep -v 'mcad|ipsec|pam_unix' *.1.log

2023-01-22T15:07:03,124 <30>Jan 22 07:07:03 ubnt dhclient: DHCPREQUEST on eth0 to 100.64.0.1 port 67
2023-01-22T15:07:03,208 <30>Jan 22 07:07:03 ubnt dhclient: DHCPACK from 100.64.0.1
2023-01-22T15:07:07,613 <30>Jan 22 07:07:07 ubnt dhclient: bound to 100.103.201.245 -- renewal in 115 seconds.

2023-01-22T15:08:35,284 <30>Jan 22 07:08:35 ubnt netplugd[3542]: eth0: state ACTIVE flags 0x00011043 UP,BROADCAST,RUNNING,MULTICAST,10000 -> 0x00001003 UP,BROADCAST,MULTICAST
2023-01-22T15:08:35,284 <190>Jan 22 07:08:35 ubnt zebra[753]: interface eth0 index 2 changed <UP,BROADCAST,MULTICAST>.
2023-01-22T15:08:35,284 <30>Jan 22 07:08:35 ubnt netplugd[25603]: /etc/netplug/netplug eth0 out -> pid 25603
2023-01-22T15:08:35,293 <5>Jan 22 07:08:35 ubnt kernel: eth0: Link down

2023-01-22T15:08:35,951 <181>Jan 22 07:08:35 ubnt wlb: wlb-wan_failover-eth0 wlb-wan_failover-eth0 reachability failed, failover
2023-01-22T15:08:35,951 <181>Jan 22 07:08:35 ubnt wlb: group wan_failover, interface eth0 going Inactive
2023-01-22T15:08:36,211 <181>Jan 22 07:08:36 ubnt wlb: group wan_failover, interface eth2 going Active
2023-01-22T15:08:36,258 <13>Jan 22 07:08:36 ubnt wan-event: [WAN Transition] eth0 to state inactive
2023-01-22T15:08:36,659 <13>Jan 22 07:08:36 ubnt wan-event: [WAN Transition] eth2 to state active
2023-01-22T15:08:36,671 <86>Jan 22 07:08:36 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/conntrack -F

2023-01-22T15:08:37,260 <86>Jan 22 07:08:37 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/sbin/dhclient -q -cf /var/run/dhclient_eth0.conf -pf /var/run/dhclient_eth0.pid -lf /var/run/dhclient_eth0.leases -r eth0
2023-01-22T15:08:37,324 <30>Jan 22 07:08:37 ubnt netplugd[3542]: eth0: state OUTING flags 0x00001003 UP,BROADCAST,MULTICAST -> 0x00011043 UP,BROADCAST,RUNNING,MULTICAST,10000
2023-01-22T15:08:37,324 <190>Jan 22 07:08:37 ubnt zebra[753]: interface eth0 index 2 changed <UP,BROADCAST,RUNNING,MULTICAST>.
2023-01-22T15:08:37,333 <5>Jan 22 07:08:37 ubnt kernel: eth0: 1000 Mbps Full duplex, port 0
2023-01-22T15:08:37,364 <30>Jan 22 07:08:37 ubnt dhclient: DHCPRELEASE on eth0 to 100.64.0.1 port 67

2023-01-22T15:08:38,875 <86>Jan 22 07:08:38 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/sbin/ip route add 0.0.0.0/0 via 100.64.0.1 table 201
2023-01-22T15:08:38,965 <86>Jan 22 07:08:38 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/sbin/ip route add blackhole 0.0.0.0/0 table 201 metric 256
2023-01-22T15:08:39,707 <30>Jan 22 07:08:39 ubnt ntpd[2874]: Deleting interface #36 eth0, 100.103.201.245#123, interface stats: received=58, sent=58, dropped=0, active_time=6861 secs
2023-01-22T15:08:39,708 <30>Jan 22 07:08:39 ubnt ntpd[2874]: 65.108.121.104 interface 100.103.201.245 -> (null)
2023-01-22T15:08:39,708 <30>Jan 22 07:08:39 ubnt ntpd[2874]: 205.206.70.42 interface 100.103.201.245 -> (null)
2023-01-22T15:08:39,708 <30>Jan 22 07:08:39 ubnt ntpd[2874]: 103.242.68.69 interface 100.103.201.245 -> (null)
2023-01-22T15:08:39,708 <30>Jan 22 07:08:39 ubnt ntpd[2874]: 144.76.76.107 interface 100.103.201.245 -> (null)

2023-01-22T15:08:41,079 <86>Jan 22 07:08:41 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/ubnt-add-connected.pl
2023-01-22T15:08:41,610 <86>Jan 22 07:08:41 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/rm -f /var/run/dhclient_eth0.pid
2023-01-22T15:08:42,643 <86>Jan 22 07:08:42 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/opt/vyatta/sbin/vyatta-interfaces.pl --dev eth0 --restore-ipv6
2023-01-22T15:08:44,308 <30>Jan 22 07:08:44 ubnt netplugd[3542]: eth0: state OUTING pid 25603 exited status 0
2023-01-22T15:08:44,309 <30>Jan 22 07:08:44 ubnt netplugd[25761]: /etc/netplug/netplug eth0 in -> pid 25761
2023-01-22T15:08:45,718 <86>Jan 22 07:08:45 ubnt sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh -c /sbin/dhclient -q -nw -cf /var/run/dhclient_eth0.conf -pf /var/run/dhclient_eth0.pid  -lf /var/run/dhclient_eth0.leases eth0  2> /dev/null &
2023-01-22T15:08:45,935 <30>Jan 22 07:08:45 ubnt dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
2023-01-22T15:08:45,988 <30>Jan 22 07:08:45 ubnt dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
2023-01-22T15:08:45,988 <30>Jan 22 07:08:45 ubnt dhclient: DHCPOFFER from 100.64.0.1

I’ve put line breaks in logical groupings. Group 1 is a normal good DHCP exchange. Group 2 is 90 seconds later and looks like eth0 spontaneously went down. There’s nothing in the logs to explain why that might have happened. Group 3 is the failover system correctly realizing eth0 isn’t working and switching me to my backup WAN, eth2. Group 4 is eth0 coming back up just about 2 seconds after it went down. Note that the router sends the DHCPRELEASE at the end of this little group.

It then takes a good 7 seconds until the last group when the router sends a DHCPDISCOVER out the Dishy interface. Why so long? And even though it gets a DHCPOFFER reply immediately the router doesn’t seem to use it. And then we’re back to the logfile above; there’s no extra info in the extended logs to shed light on why it’s not accepting the offer.

So my guess of what’s going on based on these logs is..

  • Hardware gremlins cause eth0 to fail
  • The router correctly shuts down the eth0 interface and fails over
  • eth0 comes back up 2 seconds later
  • The router correctly releases the DHCP lease, then tries to get a new one
  • Starlink ?correctly? sends a DHCP offer as soon as asked
  • The router bugs out and fails to use the lease. It keeps trying several times a minute.
  • I have to reboot the router to fix it, or it magically fixes itself after minutes / hours.

These are all pretty rough guesses though. I’m poking at two black boxes with one crappy logfile as my only evidence. Anyway I put a switch in the path to maybe help defend against hardware gremlins. We’ll see. Update: so far so good, 7 days without a disconnect. OTOH the old setup used to go a week+ without a problem too so not certain. I’ve seen other failovers but nothing related to eth0 going down.

eth0 goes down a lot

I should note that eth0 seems to go down a lot; several times a day. But not every day? There’s a gap of a whole week where it never once went down, then another gap of a day+. Super weird. Anyway the DHCP failure doesn’t happen every single time eth0 goes down.

# grep -h 'eth0: Link down' *.1.log* | sort -n

2023-01-10T11:27:19,663 <5>Jan 10 03:27:19 ubnt kernel: eth0: Link down
2023-01-10T11:27:36,793 <5>Jan 10 03:27:36 ubnt kernel: eth0: Link down
2023-01-10T13:22:33,664 <5>Jan 10 05:22:33 ubnt kernel: eth0: Link down
2023-01-10T15:17:28,666 <5>Jan 10 07:17:28 ubnt kernel: eth0: Link down
2023-01-10T17:12:23,981 <5>Jan 10 09:12:23 ubnt kernel: eth0: Link down

2023-01-18T02:22:33,753 <5>Jan 17 18:22:33 ubnt kernel: eth0: Link down
2023-01-18T04:52:05,885 <5>Jan 17 20:52:05 ubnt kernel: eth0: Link down
2023-01-18T05:02:24,905 <5>Jan 17 21:02:24 ubnt kernel: eth0: Link down
2023-01-18T07:48:57,901 <5>Jan 17 23:48:57 ubnt kernel: eth0: Link down
2023-01-18T09:43:53,337 <5>Jan 18 01:43:53 ubnt kernel: eth0: Link down
2023-01-18T11:38:48,875 <5>Jan 18 03:38:48 ubnt kernel: eth0: Link down
2023-01-18T13:33:44,726 <5>Jan 18 05:33:44 ubnt kernel: eth0: Link down
2023-01-18T14:58:30,367 <5>Jan 18 06:58:30 ubnt kernel: eth0: Link down
2023-01-18T14:59:01,387 <5>Jan 18 06:59:01 ubnt kernel: eth0: Link down
2023-01-18T16:53:56,208 <5>Jan 18 08:53:56 ubnt kernel: eth0: Link down
2023-01-18T17:02:20,938 <5>Jan 18 09:02:20 ubnt kernel: eth0: Link down
2023-01-18T19:29:46,174 <5>Jan 18 11:29:46 ubnt kernel: eth0: Link down
2023-01-18T21:24:42,410 <5>Jan 18 13:24:42 ubnt kernel: eth0: Link down
2023-01-18T23:19:38,480 <5>Jan 18 15:19:38 ubnt kernel: eth0: Link down
2023-01-19T01:14:34,209 <5>Jan 18 17:14:34 ubnt kernel: eth0: Link down
2023-01-19T03:09:29,842 <5>Jan 18 19:09:29 ubnt kernel: eth0: Link down
2023-01-19T05:04:25,189 <5>Jan 18 21:04:25 ubnt kernel: eth0: Link down
2023-01-19T06:59:19,270 <5>Jan 18 22:59:19 ubnt kernel: eth0: Link down
2023-01-19T08:54:14,486 <5>Jan 19 00:54:14 ubnt kernel: eth0: Link down
2023-01-19T10:49:11,733 <5>Jan 19 02:49:11 ubnt kernel: eth0: Link down
2023-01-19T12:44:05,754 <5>Jan 19 04:44:05 ubnt kernel: eth0: Link down
2023-01-19T14:39:02,849 <5>Jan 19 06:39:02 ubnt kernel: eth0: Link down

2023-01-21T11:04:04,617 <5>Jan 21 03:04:04 ubnt kernel: eth0: Link down
2023-01-21T12:59:17,757 <5>Jan 21 04:59:17 ubnt kernel: eth0: Link down
2023-01-21T14:54:11,780 <5>Jan 21 06:54:11 ubnt kernel: eth0: Link down
2023-01-21T16:49:09,336 <5>Jan 21 08:49:09 ubnt kernel: eth0: Link down
2023-01-22T11:18:27,227 <5>Jan 22 03:18:27 ubnt kernel: eth0: Link down
2023-01-22T11:18:44,227 <5>Jan 22 03:18:44 ubnt kernel: eth0: Link down
2023-01-22T13:13:40,293 <5>Jan 22 05:13:40 ubnt kernel: eth0: Link down
2023-01-22T15:08:35,293 <5>Jan 22 07:08:35 ubnt kernel: eth0: Link down
2023-01-22T15:59:57,613 <5>Jan 22 07:59:57 ubnt kernel: eth0: Link down

Tools for writing simpler English

I want to improve my writing by making it simpler, stripping unnecessarily fancy words and complex sentence structures. There’s a lot of room for nuance here, I want automation to make suggestions for things that can be improved, not an automatic rewrite. Here’s some tools I found, see also this Ask Metafilter discussion.

Hemingway Editor is the best of the lot I’ve tried so far. It has an excellent UI. Its suggestions are helpful and clear without being overbearing. It catches things I like to fix. Also it’s fast. The whole thing is running in the browser, your text is not sent back to a server for analysis. Some suggestions it makes: using fewer adverbs, avoiding qualifying language, nonspecific language, passive voice, and complex words. The webapp appears fully free with no upsell. They sell a desktop editor app in a low key way.

Readable.com looks similar to Hemingway but a little more transparent in its heuristics and with a UI not quite as nice. There’s more emphasis on metrics: academic sounding things like “Flesch-Kincaid Grade Level”. Also counts of words and sentences. There are counts of cliches and adverbs. No highlighting of passive voice. The app shuttles you into a login or commercial version pretty quick.

Grammarly is the best known tool I’ve seen and has an emphasis on “correct” grammar. The free version doesn’t seem to offer much. The premium version promises to provide some fairly subtle types of editing depending on your goal; the domain and expertise of your audience, etc. I can’t evaluate how good the suggestions are without paying. (Even the free version requires a signup to use, ugh.)

Globish is a nice simple tool that simplify highlights which words in text are not part of a dictionary of 2000 “globish” words, presumably simple English that’s widely understood. I appreciate its straightforwardness but am not sure how useful it is to me.

Simplish tries to translate English text to Simple English, a formal subset of English that goes back nearly 100 years. It’s pretty idiosyncratic though, and I’m not sure (for instance) translating “mobile app” to “things not fixed telephone operation” is particularly helpful. It’s a valiant effort though! There’s other online apps in this vein: Online-Utility, Rewordify, Article Simplifier. The last is a garbage SEO tool, I should have realized that SEO folks would want to remix text like this easily.

3 scripts: a sort of simplest possible thing. Three shell scripts to identify problems in language. Boils down to grepping for problematic words and something that finds duplicate words. Mentioned mostly as an example of how even something very simple can be useful.

What is Hemingway Editor doing?

Some notes on a very light investigation to the browser version. Like I said above, it all runs in Javascript. It was mostly written in 2013, last update in 2017.

Source code is obscured. The oldest version I could find was 74kb of obfuscated Javascript. The current code is 77k and while no longer obfuscated, is minimized. Scanning through this code there’s at least some UI stuff here, I’d guess very little of that 77k is linguistics. Maybe just some straightforward heuristics?

At least some function names are intact in the minimized source code. You can see some numerical scoring functions there like countSentences and countLetters; “getReadingLevel” seems to be a simple arithmetical function of those counts. There’s also tables for heuristics. 150 or so suggestions for replacing complex words like “acquire” with “get”. Another 100 suggestions for passive voice; replace “written” with “wrote”. (There’s also a search for words like “is” or “were” which I think is how it scans for passive.) There’s a table of 150 or so adverbs to avoid. And maybe 40 or so qualifying language phrases like “I hope to”.

All in all it looks like some fairly simple analysis of the text with no fancy parsing or inference of meaning. But packaged very well into a simple product that provides clear suggestions. May be simple, but good!

Speculation on machine learning models

I suspect simple heuristics can get you a long way, as I think Hemingway demonstrates. I bet there’s more academic work in this area that would have good ideas. I know there’s a lot of work on measuring text readability: even something as simple as a UI that highlights readability score for every sentence might be useful.

Large language models are what I’m really curious about. What could GPT-3 do when brought to bear on the problem of simplifying an input text? There’s been some explorations of that idea but a lot of the focus has been on summarization. Or elaboration, SEO spam stuff to write things bigger / faster / in duplicate. But I took a quick try with ChatGPT.

First I asked ChatGPT “Please write a simpler version of the following essay” and pasted in a five paragraph blog post I’d already polished with Hemingway App. It did a pretty good writing a summary. A lot is lost but the gist is there and it’s definitely a lot shorter and simple to read. Amusingly ChatGPT emitted a few compound sentences (with comma errors?) of the type I’m trying to avoid.

I found a weather app called Windy that I really like. It’s available for mobile phones and has extra features like notifications and widgets for the home screen. The app also has a good design and layout. Windy shows information about wind speeds, radar, air quality, and thunderstorms. I also like the forecast view, which gives a lot of detail, like the weather forecast by hour for several days. Windy’s business model is a yearly subscription that costs $19 per month, and they promise not to share or sell your data to third parties. However, the app doesn’t have a feature like Dark Sky, which provides very specific and short-term forecasts.

But I don’t want my text rewritten, I just want suggestions. I got further by asking “please tell me which sentences in the following essay are too complicated and why. what is wrong with my writing?”. It gave me back a list of things, a couple examples:

“Also its UI is a little more understandable.” The use of “also” and “a little” could be more clearly defined.

“It’s a lot of detail packed into a very small tabular display.” This sentence might be confusing for readers who are not familiar with the concept of a tabular display.

“It’s all very nerdy in the way I want.” This sentence is subjective and may not be relatable to all readers.

I don’t agree with all the criticisms: my readers do know what tabular display is and the “nerdy” thing is supposed to be subjective and will be relatable. But they’re valid criticisms for generic writing, OpenGPT just doesn’t quite have my blogging context. Which is why an interactive tool is so important; I want to choose which suggestions I take myself, not just do what the robot says. Still it’s a remarkably good start and I think with the right interactive UI this approach could be quite fruitful.

Linkblog stats

I got an archive view of my linkblog working; 20,000+ links over 19 years!

Here’s a dump of links per year. I’ve been pretty consistent.

2003 477
2004 1487
2005 1218
2006 912
2007 1011
2008 665
2009 757
2010 815
2011 1463
2012 1182
2013 1010
2014 1168
2015 1007
2016 979
2017 1453
2018 1311
2019 915
2020 1133
2021 809
2022 927
2023 17

To generate some rollup stats in my database:

create temporary table stats as select year, month, count(year) as count from (select strftime("%Y", ts, "unixepoch") as year, strftime("%m", ts, "unixepoch") as month from links) group by year, month;

A full year of solar

I’ve had my solar system for just about a year now, time to collect full data.

In 2022 PG&E says I netted -1670 kWh. I used 16,000 kW in 2020 and 2021, so I generated about 17,700 kWh this year. Or just about 10% over my usage. My electricity bill should be 0, or maybe even a tiny bit negative.

My solar system was designed to generate 16,600 kWh a year (with 28 * 410W = 11.5kW of panels). So I generated about 7% more power than expected. Not complaining! I am also glad to be generating a bit more power than I use because I intend to convert to electric heat pumps and cars eventually. Although I don’t really have that much excess power...

Above is a graph of daily net power, based on PG&E’s data. You can see the seasonal effect very clearly. I’m net negative quite a bit in spring and summer. I start using more than I make in August and September, to run the air conditioner. (I was out of town in October, hence much less power usage.) I go full net positive once the days get shorter and the sky gets cloudier. It’s nice that my NEM 2 rate plan nets me out over a full year; it’d suck if they trued up once a month.

I was hoping to have better data with the fancy PVS6 monitoring software I built. That worked great right until the day the PVS6 died, stopped talking to the Sunpower servers. No idea what happened there. They eventually just replaced it for me and I haven’t plugged in my little Raspberry Pi to exfil the data since. I have no idea if my monitoring broke it but I don’t want to chance it. Honestly the kind of minute-by-minute data I was getting from the system isn’t very useful anyway, daily summaries are good. Sunpower’s website should give me that but like I said, only started getting good data in September. (Also their website is awful but I bet there’s a data download somewhere.)

Very glad I got solar, wish I’d done it sooner. My system will pay for itself in about 7 years total. The deal under NEM 3 isn’t nearly as good for California consumers, I’m lucky to have gotten in when I did.

Update: true-up bill

Got my bill which contains the full year’s “true-up” for my NEM 2 solar system. I don’t honestly understand much of this. But they agree that I supplied about 1800 kWh more power than I used and paid me the $0.06/kWh or so I expect. (Note they charge $0.40/kWh for the same electricity, but at least I zeroed that part of the bill out.) Also something like $5/mo for delivery charges, eh.

UPS battery replacements by size

Replacing the lead acid battery in a Cyberpower 1000AVR. Officially the battery is called a “RB1290”. It is is 12 volts, 9 amp-hours, dimensions are 5.92 x 2.53 x 3.69 inches. There are a zillion options for replacements at half the price of the OEM battery, the keyword is “1290”. I ordered this one.

What caught my attention is there’s folks out there selling replacement batteries with different specs. 12V/8Ah, 12V/7.5Ah, ... Presumably as long as it’s 12V and fits in the space, it will work. What I don’t know is what practical impact lower capacity has. Does the Cyberpower firmware measure capacity somehow? Or is it programmed to expect a 9Ah battery and thus will confuse everyone when it runs out of juice earlier than expected? I suspect it will still just work, they measure remaining capacity with voltage or something.

The 1000AVR is rated for 600W and 9 minutes at half load. That suggests it has 90Wh of capacity for AC power. The battery’s DC specs are 108Wh, so that’s in the same ballpark. They also sell a bigger 1500AVR with two 1280 or 1290 batteries. That’s 900W or 12 minutes at half runtime, or 180Wh. So the math all makes sense.

Can I buy a higher capacity battery that will fit? Probably no. This site lists a lot of options for 12V batteries that are the same size, ranging from 7AH to 9AH. The 7AH batteries are a tiny bit cheaper ($13 vs $15) but I can’t imagine why you’d pick that.

Some previous notes from me. My new favorite UPS is a CyberPower CP1500PFCLCD PFC Sinewave. Looking now I see someone sells a DC-only UPS for routers, USB devices, etc. Interesting product! The category seems to be called “mini UPS” and Amazon has several choices.

Bonus link: Replacing a UPS Battery With Super-Capacitors