Some Bits: Nelson's log

15 posts in January 2017

ConEmu + ubuntu on windows: bell

I’m pretty happy with how my Unix setup on Windows is working. But there’s one horrible thing; the awful bell sound in the terminal emulator. Every time I hit tab in bash to complete it plays a good old ASCII 0x7 BEL, and it’s some earth-farty three tone loud sound that is just awful.

The solution is simple; go to the volume mixer and set the volume for “Console Window Host” to 0. Now your shells won’t make any audible noise. Of any kind. Peace and quiet.

What I really wanted was to reconfigure the bell sound. PuTTY has a whole set of options for this. I think it’s not really possible though. ConEmu can’t or won’t do it, as the author angrily keeps telling users. Apparently his code isn’t playing the bell at all, it’s being passed through to a lower level Windows console handler of some sort. There is an option for intercepting the bell but it’s not working for me for some reason, at least not on Ubuntu-on-Windows. It does seem to work for msys.

Another option often suggested is to configure your Unix programs not to use a bell for alerts. You can set it in bash, and GNU readline, and vim, and less, and... that way lies madness.

It turns out the sound is actually being played by Microsoft’s software, somewhere deep in their version of Bash or WSL or something. And it’s apparently not configurable. But you can find it in the volume mixer and cut off its air supply.

God that sound was awful.

Keeping time, time, time,
In a sort of Runic rhyme,
To the tintinnabulation that so musically wells
From the bells, bells, bells, bells,
Bells, bells, bells --
From the jingling and the tinkling of the bells.

Update: the plot thickens. The sound that’s being played is supposed to be a honest-to-good beep, the one generated by the motherboard with its integrated trashy speaker. Not your fancy stereo sound system. Modern hardware doesn’t have speakers, and starting in Windows 7 there was a special “beep driver” written to intercept this low level beep system ability and replace it by playing a wav file.

The sound Windows 10 seems to be playing is the sound event “Critical Stop” which is set to play “Windows Foreground.wav”, that horrible sound. I replaced it with “Windows Ding” and it’s better.

Chrome: open links in new window

New computer, old problem, I want Chrome to open links in new windows, not a tab in some existing window that may be minimized or on another desktop. I fixed this on a Mac with AppleScript; in Windows it’s easier, you just have to modify a registry setting.

Long story short, you want to modify the Default key at HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command to include the argument “-- new-window”.

This all reminds me I should set it up again so CapsLock searches Google. So far I’ve been putting off installing AutoHotkey. I can probably also use it to create some keys to change system volume and switch audio output devices.

Modern screen refresh: beyond 60hz

One of the fun things about my new gaming setup is it can render at frame rates other than 60Hz. I’ve now got it set up to run at 3440x1440@75 and it seems to be working well. Of course it won’t matter much for desktop work, but it does have an effect on game rendering. Can a human perceive it? Lots of folks say so, and this blind test confirms it.

The hardware I have is an NVidia GTX 1080 graphics card hooked to a Asus RoG Swift PG348Q display. It’s hooked up via DisplayPort 1.2, the 2009 standard. In theory there’s enough bandwidth to run 3840x2160@75, but for some reason my monitor only will show up to 60Hz unless I enable “overclocking”, where it will then display up to 100Hz. The overclocking didn’t work with the first decent quality cable I tried, but it did work with the cable included with the monitor.

The neat thing about this setup is it doesn’t have to be a constant 60Hz or 75Hz. The hardware all supports Adaptive Sync, a technology where the graphics card tells the LCD when a new frame is ready to be displayed. So games, etc can run at any speed; 20fps, 27fps, 60fps, 75fps and it displays without screen tearing. This is way better than the Vsync hack that we’ve been stuck with since the ancient days of CRTs. No more triple buffering required, no awkwardly being stuck with display rates that share common factors with the number 60, no tearing or stuttering. Just draw a frame when it’s ready.

gsync

Unfortunately this variable sync rate comes in two flavors, G-Sync and Freesync, and monitors seem to only one or the other. NVidia does G-Sync so that’s what I’m using, and fortunately the higher end monitors seem to favor G-Sync as well. G-Sync requires that an expensive NVidia scaler be installed in the monitor (and may not technically be DisplayPort Adaptive Sync at all.) Freesync is the open / cheaper standard DisplayPort, but only AMD video cards support it so far, and AMD is way behind. Hopefully this will all get better in a couple of years.

Indus Script

Fun article in The Verge about deciphering Indus Script using statistical methods. I used to play with this stuff with the Voynich manuscript. But that text is sort of a honeypot, a largely irrelevant medieval European one-off, and quite possibly a hoax. Indus Script matters, there’s thousands of unreadable objects with Indus writing on it. The Harappan civilization is important to human history and so little is known about it.

Mostly I just wanted to make a note that Indus Script was proposed for Unicode in 1999. About 250 code points. It’s still pending.

jbareham_170124_1415_getty_02

Capture.PNG

Unix environments for Windows

One thing I miss about my Mac is having a usable Unix environment. Now I have two on my Windows machine, with different significant flaws. MacOS isn’t a great Unix, but it’s perfectly adequate for basic stuff. And it’s really handy having tools like rsync and command line ssh around. Windows has its own command line world with the venerable CMD.EXE (DOS) and the newer PowerShell. But screw that, I want Unix. Here are options.

Ubuntu-on-Windows (WSL)

This is the new hotness from Microsoft and is very nice. It feels like a legitimate Ubuntu environment. Except so far it doesn’t support networked filesystems.

WSL sits as its own OS on top of the NT kernel, just like Windows is an OS on the NT kernel. There’s not a proper Linux kernel running, instead Microsoft has emulated the Linux kernel at the syscall interface. The userspace then runs stock Ubuntu, actual Ubuntu x64 binaries unmodified. It’s an impressive piece of work.

The drawback is not everything works. ping doesn’t work unless you run bash as Administrator. (Some docs I’ve read say ICMP isn’t implemented at all.) Filesystems are limited. USB drives don’t work. Network file shares don’t work. There’s no NFS support in the Linux image, nor is there FUSE support. The view of the underlying Windows filesystem (in /mnt/c) is a bit strange too, like I can’t see a proper view of my Desktop folder. In general stuff that works seems to work right, and the Microsoft team is moving fast in adding new features. I’m tempted to join Windows Insider just to start running betas, but I think I have to get a whole new Windows version, not just an upgrade to WSL.

There is an honest /sbin/init process running in WSL, PID 1, but its only child by default is the bash shell you start the thing with. So no init scripts / systemd running services. You can open multiple bash processes that can all see each other and share a filesystem. But if you close the last bash, you lose the whole WSL environment, which makes daemons a bit awkward.

Other names for this system are Windows Subsystem for Linux (aka WSL) and “Bash on Ubuntu on Windows”. Note these make for awkward search terms on Google.

Cygwin

The granddaddy of Unix emulation for Windows. I haven’t tried it in a few years, but I used to hate its package manager and its approach to Windows integration. Weird path names and environment. But it works pretty well and has a significant set of tools. MobaXterm bundles Cygwin in with an X server and terminal emulator.

msys2

The other venerable Unix option for Windows, some evolution of msys / msys2 / MinGW / mgwin32 / MinGW-w64. It has some Cygwin roots in it too, I’m not sure how much, but the mingw philosophy is to make things more like Windows and less like Unix. The result is a lighter weight Unix environment with some compromises. For instance symlinks aren’t supported because they wouldn’t work in Win32 apps. So instead creating a symlink makes a copy of the file, which is pretty damn broken but you can live with it. The crazy neat thing is the Unix programs like make are actually Windows executables like MAKE.EXE and will work fine in Windows, without bootstrapping a Unix environment. Handy for ssh.

There’s no visible init process, you just have a naked bash running according to ps, although its PPID shows as 1. Software is managed via pacman (as used in Arch Linux), there’s a large variety of packages and a toolchain for building your own. I’m not wild about the package and software versions and a bunch of basic stuff isn’t installed by default (like tar). Also some of the tools have idiosyncracies. And I have some problems like Ctrl-C not interrupting IO bound bash scripts. But it’s definitely a usable Linux environment, just not Ubuntu.

Git for Windows (aka msysGit)

This shows up as a recommended Unix option. It’s a tight, easy to install bash shell plus enough related utilities to run git. It is based on msys2, some of the history is here. It does not include much though, like there’s no rsync. And no compiler toolchain, no package manager for installing more stuff. It’s great for providing a git command line though.

Terminal window

Unix programs really want to be running in an xterm/vt100 emulator. There’s a bunch out there. I’m liking Cmder, which is an enhancement wrapper for ConEmu. mintty is another option, that’s what msys2 uses by default. wsltty is a customization of mintty for WSL. MobaXterm is also popular. Note that PuTTY/SecureCRT is not really needed any more. They are a combination of terminal emulator + ssh, but now you can just use a simple emulator plus OpenSSH command line. Still working on a good ssh-agent solution though.

History

As a historical footnote, WSL is not the first unmodified Ubuntu to run on Windows. There’s also andLinux, based on coLinux, a cooperative VM. There’s some other Unix-alike Windows options out there too, I think mostly abandoned. See also Interix and Windows Services for UNIX.

Windows 10 gripes

I’m now a week into switching from Mac to Windows and have mostly settled in. Here’s a list of gripes I have about the Windows experience. Compare to a similar post I wrote in 2011 when I switched to the Mac. Honestly mostly the Windows machine is fine and I think this change will take permanently. But you notice things when you try something new.

Operating system problems

Windows is actually not a bad operating system, the NT kernel is pretty good. But there’s still a lot of warts.

File paths are still broken in Windows. Stuff installs and writes files all over the filesystem: Program Files (two versions), root directory, various user directories. The fact that I need to know about a pathname like C:\Users\Nelson\AppData\Roaming\Sublime Text 2\Settings is terrible.

I have two GPUs: the motherboard and a fancy gaming card. It’s really unclear to me which GPU is used when. In theory I can use the motherboard plug but it still uses the card? I couldn’t make that work reliably, so I just used a plug on the card.

There’s no way to make Windows re-open programs you had open when you reboot and log in. And if you want a program to start when you log in, it’s a hideous process of opening one of two magic folders and creating and dragging shortcuts. Seriously, I have to make a shortcut and put it in C:\Users\Nelson\AppData\Roaming\Microsoft\Windows\Start Menu\Programs. That’s handy.

Legacy problems

It’s remarkable how 30 year old DOS software still works on Windows 10. But that legacy support comes at an increasing cost.

There’s an uncomfortable mix of Windows 7 and Windows 8 philosophy in Windows 10. For instance there’s two overlapping sets of system settings: Control Panel (Windows 7) vs Settings (Windows 10). Also there’s too many backup options. The Windows 10 things are better, but they aren’t complete so you need the legacy Windows 7 sometimes too.

Windows still comes in a 32 bit version! That’s nuts. Worse, applications are also distributed in both 32 bit and 64 bit builds. OMG why? I wonder how many users choose the right one? And they’re installed in separate folders. “Program Files (x86)” is a very awkward name for a folder. There’s uglier stuff hiding under the covers too, like file system redirection.

Windows 10 still expects DOS newlines in files. Files have both CR+LF to end a line, and tools like Notepad won’t display a file correctly if it only has LF like everyone else in the world. This continues to cause headaches when using Windows tools to edit Unix files.

UI problems

Windows 10 is ugly. MacOS is so calm and harmonious.

The biggest problem is the UI still seems designed for 75ppi screens. Modern LCDs are 100+ppi, so everything is too small. System tray icons are 16x16! A lot of apps default to 8 or 9 (points? pixels?). I get a headache from squinting and leaning close.

Microsoft has created display options to scale everything; 125% does look more or less the right size. But apparently every single app has to be smart about scalings; if they don’t, it goes blurry like it was up-sampled with a bicubic filter. Many apps are OK. But Electron apps like Slack and Discord have this problem right now, apparently a fix is on its way. Also Chrome up-scales all the images in a web page to 125% as well, which is entirely unacceptable and makes the scaling setting useless.

The fonts are ugly. They look spindly, thin. I’ve tried tweaking ClearType to make things better with not much success. Font rendering for CJK fonts is so bad a bunch of users have created alternate font renderers like MacType. But their installation is spooky and the English documentation is not great so I’m not using them.

So many apps play sound notifications. For instance, social apps like Adium and Discord love to make noise when people join/leave. You can turn these off in each app. But it’s hard to find which app is making noise. The Volume Mixer program will show you but the window is small and modal and not really practical to leave running all the time.

The default sound set in Windows 10 is goofy, too light and ethereal. I’m particularly missing a way to have a good clean beep sound for the BEL character in ttys.

The mouse scrolls backwards! This is actually Apple’s fault; they were the ones to reverse things in the first place. But now I’m used to it and switching back is annoying. There’s hacks to reverse it in Windows, but I’m soldiering on.

Mouse scrolling doesn’t feel good on Windows. The “scroll 3 lines at a time” hack in the driver seems dumb. And sometimes the wheel scrolls backwards at the end of a gesture, either through hardware flakiness or my fingers being inaccurate. Either way I never noticed a problem on a Mac.

It’s awkward that Windows uses Ctrl-C for copy and Unix uses it for terminate process. In general I prefer the Mac’s use of the Cmd key and wish Windows used Alt the same way. And don’t get me started on Windows’ apps love of Ctrl-Shift-Win-X type hotkeys.

Missing features

Here are some things from my Mac I miss on Windows.

I miss auto-correct for typos. I’m confused because this is built in to Windows 10, and does work for me in MSIE Edge. But it doesn’t work in Notepad, or in Chrome, or many other apps. Apparently Chrome does its own thing. Also autocorrect only works for UWP apps, ie new things. Notepad seems like a strange oversight.

I miss the MacOS/iOS way of entering “special characters”. Hold down the E key and instead of uselessly repeating the E, it pops up a little GUI for you to choose É or the like. Windows doesn’t really have this (I wonder if Apple has a patent?). The best alternative I’ve found is the Touch Keyboard, which has a similar UI with the mouse.

I miss the emacs editing keys in text areas, particularly Ctrl-E for end of line.

I miss Keychain. I didn’t use it much on the Mac, but having a central system for secrets is really smart. The specific thing I miss using is the SSH agent.

I miss iMessage. It was great getting my phone text messages on my desktop. Apple seems uninterested in opening iMessage to anyone else.

I miss having a brightness control for my monitor from software. There’s no volume hotkeys either. Actually I miss everything about how the iMac integrates display, etc in to the computer. I now have no webcam and no microphone. OTOH my new external monitor is lovely. Better be, it cost half as much as an iMac!

Good things

So those are the gripes. Here’s good things about the Windows switch.

Gaming. That was the #1 reason I switched back to Windows, I wanted to dip back into PC gaming. Apple is simply not competitive in desktop gaming, not in hardware and certainly not in software. Microsoft’s lock-in strategy with DirectX succeeded.

The hardware itself is better and faster. Apple has neglected the iMac line and fallen behind. The GPU is the main thing I have that a Mac can’t do. But it was also nice being able to build a machine with Kaby Lake parts the second week they were available retail. I was also surprised that it was relatively easy to spec a clean, quiet piece of hardware; that used to be a big PC drama. It wasn’t much cheaper than Apple hardware though, particularly when you consider the display.

Network file shares work better. I gave up on using SMB on my Mac when Apple dumped Samba for their own broken SMB implementation. Of course SMB is quite nice on Windows. NFS worked on the Mac but was awfully slow and didn’t include an authentication solution. SMB is grody but seems to work.

My Network printer just worked. I had to do literally zero setup; it was discovered and configured automatically. Not so lucky with the scanner though.

Ubuntu-on-Windows is shaping up to be a good Unix environment, certainly better than MacOS. Here’s a post about it.

 

 

River flow map

Via my friend Amit, I think someone has finally built the map I wanted so long ago. Rivers in the US colored by stream flow. I’m not quite sure what the data is, at least some of it must be models rather than measurements. But it’s good.

The map is at the NWS Enhanced Data Display. It’s some clunky Windows-GUI-in-Javascript thing. But the data is great! The layer we want is under “More Layers / Rivers / Nat. Water Model - Stream Flow”. I set the base map to ESRI Light Gray to see the river layer better.

Capture.PNG

New Windows gaming PC

After five years of running Macs I’m going to try Windows again. I only use the computer in front of me as a fancy terminal, web browsers and SSH sessions mostly. And gaming. But I’m not really using the OS as a real computer, so I can suffer with Windows. Also I’m fed up with a bunch of stuff related to Macs. MacOS is not a very good Unix, I went back to doing all my real work on Ubuntu last year. Mac gaming is just awful. And Apple has apparently abandoned the idea of updating iMac hardware.

Anyway, I ordered a PC. I went full max spec with brand new Kaby Lake parts because I intend to use this machine for 4+ years. Top end CPU, top end GPU, 16GB RAM, 500GB SSD, and some fancier cooling / quiet components. Here’s the parts list.

  • Motherboard:  Asus Z270-P
  • CPU: Intel Core i7-7700K 4.2GHz
  • GPU: EVGA 08G-P4-6286-KR NVIDIA Geforce GTX 1080 FTW
  • RAM: C769-V16B Corsair CMK16GX4M2B2800C14 16GB (2x8GB)
  • Drive: Samsung 960 EVO 500GB PCIe NVMe M.2 SSD
  • Power supply: Corsair CP-9020092-NA RMx RM750X 750W
  • Case: Fractal Design Define R5
  • CPU cooler: Noctua NH-D15S
  • Monitor: Asus ROG PG348Q 3440x1440

So far so good! The motherboard was a compromise, it doesn’t support SLI. The CPU and GPU are too far up on the price vs. performance curve but I was feeling spendy. The case is nice, it has sound baffling. The CPU cooler is absurdly huge; I don’t intend to overclock, but large = quiet.

Shopping for the monitor really made me appreciate what Apple has done with the iMac displays. It’s very hard to find something that quality for PC parts. I decided not to go with the 4k/5k/Retina high density displays, too expensive and no GPU can fill that many pixels in a game.

There’s some neat new things in PC hardware. The M.2 form factor for SSDs dispenses entirely with the history of hard drives, the SSD looks something like a RAM module. (Which begs the question; why are PC cases still so giant? Cooling.) And GPUs have a nice new feature called G-Sync or Freesync. For 20+ years we run the screen at 60Hz and hope the GPU can keep up with 60fps vsync interrupts. Now the GPU just renders frames as fast as it can and the LCD only updates when there’s a new frame to draw.

I had Central Computers build it for me, a local screwdriver shop. They did a great job on the quote and build process for $80 labor plus maybe a 10% markup on parts. The computer priced out about $2150, the monitor $1100. Expensive! But I use this literally all day every day, and like I said I don’t intend to upgrade for a long while.

 

Rendering 10M+ points from S3 to a map

Michal Migurski is working on a new project, rendering previews of OpenAddresses datasets in slippy maps. We’re using S3 to store stuff and trying for stateless servers. He just described the architecture plan to me, I’m writing it up here. He’s doing all the work, currently in a test git repo. The fun part is a FUSE file system for MBTiles on S3. Read on.

OpenAddresses is a collection of address data points. Big CSV files full of latitude, longitude, street name. We collect the data from government sources. Every time someone finds a new government source they create a pull request like this one for Luzern with metadata for the source; stuff like the URL and how to parse it into our format. Mike has some GitHub integration hooks that look at the pull request and renders a preview image of the data file. It looks cool, but it’s also a useful debugging tool. We’d like to transform that static preview image into a slippy map. Here’s how it’s going to work.

  1. GitHub integration hook: use Tippecanoe to boil down the address points into a tiled dataset. Write the resulting MBTiles file to S3 somewhere. Note this hook and processing is on a transient server that disappears once the processing is done.
  2. Web page: slippy map using Leaflet or the like to request OpenAddresses tiles and render the points in the browser.
  3. Tile server: persistent Flask server that uses TileStache to serve the MBTiles file to the web browser.
  4. Tile server: a FUSE filesystem that mounts the S3 MBTiles file and provides it to TileStache.

 

It’s that last step that’s particularly clever. Serving an MBTiles file locally is easy. But what do you do if your MBTiles file is on S3 somewhere? It might be quite large, 10 million points or 100 megabytes. But each map view only needs like 16 tiles or a megabyte of data. You’d rather not have to copy the whole thing from S3 first.

So instead of caching the whole file locally, Mike has written a simple read-only FUSE driver to remotely mount the S3 file. To normal Linux processes it just looks like a file, but behind the scenes read requests are being turned into HTTP Range-restricted requests to get the bytes and return them.

Why go through the hoops of FUSE? The challenge here is MBTiles are actually Sqlite databases, and Sqlite really wants to open an actual file down in the depths of its highly optimized C code. So we give it a file.

The big question here is performance. It seems to be OK on first testing! Sqlite should be pretty efficient about reading data. I’m a bit more concerned about llfuse, the Python FUSE driver framework Mike is using. It seems to have a single global lock so only one S3 read request can be active at a time, maybe per mounted MBTiles device. So this might not work so well; in practice multiple tile requests are happening in parallel, even for a single user looking at a single slippy map. But we don’t imagine many users so it may not be too bad.

 

League of Legends server IPs

Just writing this down so I don’t lose it. I haven’t verified these. But most of the old lists I’ve seen are no longer valid since Riot started doing its own peering.

  • NA - ping 104.160.131.3
  • EUW - ping 104.160.141.3
  • EUNE - ping 104.160.142.3
  • OCE - ping 104.160.156.1
  • LAN - ping 104.160.136.3

Source is this Reddit discussion about yet another ping checker. I wish Riot would build a small network diagnostic into the client, before a game starts. Many of these third party tools don’t measure round trip time correctly and none that I’ve seen measure packet loss.

Also I was curious so I just did an mtr to the NA address. Average response to the end is 92ms, which is about the same number the league reports as ping. Standard deviation is 12ms, best/worst is 73/140. That’s with ICMP probes, I don’t get responses from UDP probes.

Verizon tethering for real

I’m glad I did that tethering experiment; I had to use my cell phone for Internet in anger today after yet another local WISP outage. Big storm, power outages, but also some robustness problems in equipment and/or service. I do have sympathy, the ISP depends on $300 wireless devices installed in trees scattered all over the county.

Anyway my iPhone worked fine for tethering. I put it in an east-facing window. Only one or two dots of service, but my Mac through it was reliable and seemed fast. I didn’t measure but it felt 10Mbps fast, at least. I quickly forgot I was tethered.

Doing my ordinary daily routine my iMac alone seems to use about 100 MB / hour. Call it 1GB a day. My data plan is only 2GB, but with another 2GB carryover that’s good for 3-4 days before it costs money. Overage charges at Verizon are $15/GB, but you can also avoid overage by adjusting your data plan size; no switching cost and it’s retroactive for the whole month. The plan price is about $5/GB.

It’d be $135/month if I wanted to just buy 30GB a month. But I really use more like 100GB / month once you factor in other devices, discretionary downloads, etc. That’d be $450/month (!).

The plan flexibility makes Verizon a pretty good low cost backup option.

 

Overwatch netcode

I’ve been playing a lot of Overwatch, on PS4. It’s fun! Also it feels super responsive and reliable on the network, I almost never perceive lag. Blizzard is uniquely good at building games like this so it’s no surprise, but what are they doing to make an Internet game feel like real time?

This video from Blizzard developers is good info (but outdated; keep reading). It goes into detail into server prediction, client prediction, and perceived lag. I think they’re mostly doing what other games have in the past, but there’s a lot of choices and tradeoffs they make. One choice they say is new is they make the assumption that most clients have reliable, fast networking. That means they don’t need to buffer nearly as much. Specifically they say that with most games you may be buffered 4 ticks (or 80ms), but if they think your network is good they’ll buffer you just 1 tick (20ms), so it feels even more real time.

The server runs the simulation at 62.5Hz. When that video was posted, clients got network updates at 20.8Hz. In August they pushed an update so PC clients get updates at 62.5Hz. PS4 and XBone also got the faster tick rate on September 13. The rate is adaptive, so your client will drop down if you have low bandwidth.

The game is a UDP protocol. I’m not sure about bandwidth usage. Back in the 20.8Hz days this post claimed it’s about 60-100Kbps in both directions. So maybe triple that? Bandwidth consumption was the reason Blizzard originally went with the lower tick rate.

I’m really curious why it’s 62.5Hz and not the obvious 60Hz. Maybe you want the network updates to be just a bit faster than the screen updates for smoothness?

For comparison, League of Legends runs at 30 Hz on the server. I’m not sure about the network / client update rate, it may be the same. CS:GO is 64Hz (or even 128Hz).

Internet in the mud

This is what happens when my Ubiquiti wi-fi antenna outside falls off its mast into the mud

The network was surprisingly useful in the bad period. I didn’t really notice for basic web stuff, although I did notice video streaming was unreliable. The main thing I could measure was my ping time to the antenna (as measured by mtr) had a standard deviation of 28ms. 5% packet loss too. So something was wrong, but the hardware handled it robustly. What’s with the delayed pings, btw, is there some retransmit logic involved somewhere? In the wireless devices?

“In the mud”, btw, mostly meant on the ground. Fortunately it fell facing my house. But with little or no line of sight to the house. Mind you the other antenna in the house is literally behind a wall; it works well enough I’ve never bothered to mount it in the window.

Local stream flows: Yuba and Deer Creek

We’re about to get a lot of rain, and like every year I get interested in the local rivers and waterflow around Grass Valley, CA in Nevada County. Here’s some rough notes and resources.

Yuba River, particularly the South Fork

  • Yuba River at Marysville: flow history and forecast. This is below Englebright Dam, so includes the choices of how much water they’re releasing there. But is excellent data from NOAA.
  • South Yuba at Highway 49: flow history, forecast. From Dreamflows.
  • Yuba River at Jones Bar: flow history. From CDEC. This is either the exact same sensor Dreamflows is showing at Highway 49 or else is a mile downstream.
  • Yuba River flow history along the whole river. This is California state data (CDEC) and the website has lots of neat stuff.
  • Watershed map
  • Wild and Scenic River Act protects the river from Lang Crossing to Bridgeport. This is the much loved stretch of scenic river with lots of swimming holes, etc.
  • BLM management plan

Deer Creek in Nevada County

This ArcGIS map of World Hydro Reference Overlay does a good job showing labelled rivers against towns and major roads.

Where did source code merging come from?

The concept of merging changes is central to modern source code control. Specifically the technology of a three way merge, like diff3, which allows two different developers to change the same file and then reconcile their changes together. In the bad old days before we had good merge tools locking files when editing them was common practice. “Yeah I’ll be done in about three days, then you can do your work”. The key insight of CVS in 1990 (and others) was it was OK to let people work on the same thing at the same time if you could reconcile any conflicts later.

So where did the idea of three way merging come from? The oldest code I’ve found is diff3 from V7 Unix, written by Doug McIlroy and dated January 1979.

Wikipedia doesn’t have any history for diff3, but the entry for diff has helpful history on the basic two-way diff saying it goes back to the early 70s, again by McIlroy, based on ideas from other computer scientists. There’s a short technical paper from 1976 about diff, but it doesn’t mention three way diffs.

That same diff page has an intriguing reference

Diff3 compares one file against two other files. It was originally developed by Paul Jensen to reconcile changes made by two people editing a common source. It is also used internally by many revision control systems for merging.

Unfortunately I can’t figure out who this Paul Jensen would be. There’s no citation. The text was in Wikipedia way back in 2004, added by someone from the University of Vermont while fleshing out the history section. But I couldn’t learn anything more.

The use of three way merge in version control dates back to at least 1985, where it’s mentioned in Tichy’s paper on RCS. SCCS dates back to 1972, but I didn’t look into the history of its merge tools. (A 1975 article seemed to say merging was dangerous.)

(Surely there are plenty of people alive today who have personal knowledge of the answer to my question, but I’m too shy to bother them with my idle curiosity.)

Big update with authoritative info

My old Google pal Dan Bentley was kind enough to ask his father (a former Bell Labs person) to ask Doug McIlroy himself about the history of diff3. Here’s the reply Doug wrote, edited a bit:

Paul Jensen’s role was to say, “I’ve wanted a program that ...” As far as I know he never made one. But Paul’s nudge was more than sufficient to spur the creation of a candidate program for the purpose. Is it good enough? I don’t know; it strays from an important Unix lesson: programs tend to be better if their authors use them.

There’s an obvious 3D analog for the 2D longest-common-subsequence dynamic program; and the improvements discovered by Harold Stone, Hunt/Szymanski (Harry Hunt, not my coauthor) and Gene Myers likely have analogs too. Whether I considered such–or even thought of them–at the time I can’t remember. Diff3 works by combining results of 2D diffs. This keeps it at O(n^2) worst case for two sequences of length n vis a vis O(n^3) for a true LCS of three.

I’m curious about where Wikipedia learned of Jensen’s role in diff3, for I can’t think of any description of diff3 other than Unix man pages.

Paul was (and still is) a creative type from a development department, who took a sabbatical in 1127. Paul moved on to the Denver Labs, then set up shop in Boulder, .

The details of the output report would be mine; such things don’t get worked out in corridor conversations.

Presumably diff3 has been reimplemented out from under Unix licensing, but if it still has that name, then it has proved Paul’s instinct right. And it gratifyingly proves me wrong in having thought that diff3 “persists mainly as a curiosity”.

Update 2024

Interesting discussion about the 50th anniversary of diff which resulted in Rob Pike getting a comment from Doug McIlroy

‘I’m flattered, but must point out that diff was just one of a sequence of more capable and robust versions of proof(1), which Mike Lesk contributed to Unix v3. It, in turn, copied a program written by Steve Johnson before Unix and general consciousness of software tools. Credit must also go to several people who studied and created algorithms for the “longest common subsequence” problem: Harold Stone (who invented the diff algorithm at a blackboard during a one-day visit to Bell Labs), Dan Hirschberg, Tom Szymanksi, Al Aho, and Jeff Ullman.

For a legal case in which I served as an expert witness, I found several examples of diff-type programs developed in the late 1960s specifically for preparing critical editions of ancient documents. However, Steve Johnson’s unpublished program from the same era appears to be the first that was inspired as a general tool, and thus as “social software”.’