Huon on the internet

Huon Wilson's writings
https://huonw.github.io/ (RSS)
visit blog
Async hazard: mmap is secretly blocking IO
21 Aug 2024 | original ↗

Memory mapping a file for reading sounds nice: turn inconvenient read calls and manual buffering into just simple indexing of a memory… but it does blocking IO under the hood, turn a &[u8] byte arrays into an async hazard and making “concurrent” async code actually run sequentially! Code affected likely runs slower, underutilises machine...

GitHub tip-hub: habitual permalinks
24 Jul 2024 | original ↗

GitHub offers permalinks to versions of files and lines, within a repository. They’re easy to create (y keyboard shortcut) and have some nifty affordances like displaying a preview, plus they don’t become invalid as code changes. Use them! The permalinks use the commit hash of a particular version of the file, and thus the contents never changes,...

10 > 64, in QR codes
31 Mar 2024 | original ↗

Encoding data in decimal requires many more characters than the same data encoded in base64—06513249 vs YWJj—but using decimal is better when stored in a QR code. The magic of QR modes means all those extra digits are stored efficiently, almost as though there was no encoding at all. Decimal encoding makes for QR codes that store more data, or...

Mechanical sympathy for QR codes: making NSW check-in better
13 Oct 2021 | original ↗

Governments here in Australia have been telling us to keep distance from each other. Surprisingly, the same government has simultaneously put out posters that required people to get close, unnecessarily. They contain QR codes for contact-tracing check-ins that are small and dense, meaning they’re hard to scan. How could they be better? Here’s...

QR error correction helps and hinders scanning
28 Sept 2021 | original ↗

Error correction sounds good. It means fewer errors, right? When it comes to QR codes, that’ll mean easier scanning for people, surely? It seems like that’s not the whole story. I wondered about this, and couldn’t find an answer, so I did some exploration, and found there’s two factors in tension: the error correction on one hand, and the...

The joy of cooking (an app)
30 Aug 2021 | original ↗

Taking shortcuts? Leaving edge-cases unconsidered and unhandled? Is this engineering?! My approach to programming and software engineering has been shaped by years of building open source compilers and libraries, where those edge cases matter, reliability is crucial and flexibility is important. It’s been a breath of fresh air to take a step back...

Git worktrees and pyenv: developing Python libraries faster
15 Apr 2020 | original ↗

It’s glorious to work on one task at a time, to be able to take it from start to finish completely, and then move onto the next one. Sounds great, but reality is messier than that and context switches are common. Doing so can be annoying and inefficient, but not switching means tasks and colleagues are delayed. I combine git worktrees and pyenv...

Myths and Legends about Integer Overflow in Rust
29 Apr 2016 | original ↗

The primitive integer types supported by CPUs are finite approximations to the infinite set of integers we’re all used to. This approximation breaks down and some computations will give results that don’t match real integers, like 255_u8 + 1 == 0. Often, this mismatch is something the programmer didn’t think about, and thus can easily result in...

Memory Leaks are Memory Safe
4 Apr 2016 | original ↗

Memory unsafety and memory leaks are arguably the two categories of bugs that have received the most attention for prevention and mitigation. As their names suggest, they are in the same part of “bug space”, however they are in some ways diametric opposites, and solving one does not solve the other. The widespread use of memory-safe managed...

Rreverrse Debugging
27 Oct 2015 | original ↗

Imagine being able to step forward and backwards as code runs in your debugger. Imagine being able to do an test run multiple times with exactly the same sequence of instructions and values, right down to memory addresses and IO. Imagine being able to run an executable thousands of times and then do all that in the one execution that triggers the...

simple_parallel 0.3: Revisiting k-NN
24 Oct 2015 | original ↗

I recently released version 0.3 of my simple_parallel crate, which builds on Aaron Turon’s crossbeam to resolve the stability and safety difficulties: the crate now works with Rust 1.3.0 stable, and offers safe data-parallel for loops and maps. I still don’t recommend it for general use, but I think it’s a neat demonstration of what Rust’s type...

SIMD in Rust
24 Aug 2015 | original ↗

A new scheme for SIMD in Rust is available in the latest nightly compilers, fresh off the builders (get it while it’s hot!). For the last two months, I’ve been interning at Mozilla Research, working on improving the state of SIMD parallelism in Rust: exposing more CPU instructions in the compiler, and an in-progress library that provides a...

What is SIMD?
10 Jul 2015 | original ↗

I’m currently in San Francisco doing an internship at Mozilla Research, working on creating functionality for SIMD in the Rust programming language. (This post is designed to describe what I’m doing for people not necessarily familiar with programming or SIMD.) What is SIMD? SIMD stands for “Single Instruction, Multiple Data”, and refers to...

travis-cargo 0.1.3: --no-sudo
30 Jun 2015 | original ↗

I just pushed travis-cargo version 0.1.3, which adds a --no-sudo command to the coveralls and coverage subcommands to allow recording/uploading test coverage without needing sudo. This is based0 on @seanmonstar’s investigation/implementation of sudo-less kcov. It works because Travis’s apt addon has whitelisted everything necessary....

Announcing Primal: Putting Raw Power Into Prime Numbers
8 Jun 2015 | original ↗

Over the past few weeks I’ve been working on improving my slow_primes library, culminating in needing rename and the 0.2 release of primal, a Rust crate for computing properties of prime numbers with state-of-the-art algorithms, while still maintaining an idiomatic and easy-to-use interface. primal My computer takes a quarter of a second and...

Defaulting to Thread-Safety: Closures and Concurrency
26 May 2015 | original ↗

Rust has some powerful tricks to model properties of aggregate types via unsafe traits with default and negative implementations. These features motivated by offering flexible concurrency/parallelism, and allow powerful closure-based APIs without losing any thread-safety (or memory-safety) guarantees at all. I realised that my recent post on the...

Rust 1.0 in Numbers
20 May 2015 | original ↗

Rust 1.0 was made with0… .number { text-align: right; } table { max-width: 600px; border-spacing: 0 0.4em; border-collapse: separate; } td { vertical-align: top; } 1stable release 2‘Rust’ compilers 3bots on Github 4years of bootstrapping (7b95b5c is the innocuous commit of the first snapshot) 5years of git ~9years total 120.x releases ~28launch...

Finding Closure in Rust
8 May 2015 | original ↗

Have you ever used an iterator adapter in Rust? Called a method on Option? Spawned a thread? You’ve almost certainly used a closure. The design in Rust may seem a little complicated, but it slides right into Rust’s normal ownership model so let’s reinvent it from scratch. The new design was introduced in RFC 114, moving Rust to a model for...

Where Self Meets Sized: Revisiting Object Safety
6 May 2015 | original ↗

The concept of object safety in Rust was recently refined to be more flexible in an important way: the checks can be disabled for specific methods by using where clauses to restrict them to only work when Self: Sized. This post is a rather belated fourth entry in my series on trait objects and object safety: Peeking inside Trait Objects, The...

Travis on the train, part 2
1 May 2015 | original ↗

After announcing travis-cargo a few days ago in Helping Travis catch the rustc train, I got some great hints/contributions from Jan Segre and had a fun little time automating code coverage collection via coveralls.io. Unfortunately, this is a breaking change for existing users of travis-cargo, but the migration is easy. (If you’re wondering what...

Helping Travis catch the rustc train
28 Apr 2015 | original ↗

I’ve been putting off configuring my continuous integration settings to match the Rust train model: it involves non-trivial branching on the configuration, and duplicating that over a pile of repos is not something I looked forward to. So, instead, I wrote travis-cargo to make things easier. Branching on configuration? One approach to developing...

Little libraries
27 Apr 2015 | original ↗

I’ve been having a lot of fun recently solving “little” problems in Rust. I have a long term project to make something for displaying my (GPS-tagged) photos nicely and, along the way, I’ve discovered and filled in a few gaps by creating focused crates for small tasks. My travels over the last few years, as...

Rust infrastructure can be your infrastructure
17 Mar 2015 | original ↗

Rust is a reasonably large project: the compiler and standard libraries are over 350kloc, built across nearly 40000 commits by the hands of around 900 contributors. Not only that: there are more than 30 other repositories in the rust-lang GitHub organisation that shouldn’t fall by the wayside, and, for rust-lang/rust alone, there are often more...

Some notes on Send and Sync
20 Feb 2015 | original ↗

If you’ve been in the #rust-internals IRC channel recently, you may’ve caught a madman raving about how much they like Rust: 1 2 3 4 5 ... [15:50:03] I love this language ... [20:02:07] did you know: Rust is awesome. ... I was (and still am) losing my mind over how well Sync and Send interact with everything, especially now that the...

Rust Sydney's first meetup: trip report
14 Feb 2015 | original ↗

Rust Sydney had its first event last Monday! The first Rust gathering I know of in Sydney, in Australia, or in the whole southern hemisphere. I had fun meeting all sorts of people interested in Rust: some who’d dived in deep already, some who’d only recently started playing with it, and some who’d been following for a while but had unfortunately...

Object Safety
13 Jan 2015 | original ↗

A trait object in Rust0 can only be constructed out of traits that satisfy certain restrictions, which are collectively called “object safety”. This object safety can appear to be a needless restriction at first, I’ll try to give a deeper understanding into why it exists and related compiler behaviour. This is the second (and a half) in a short...

The Sized Trait
12 Jan 2015 | original ↗

An important piece in my story about trait objects in Rust0 is the Sized trait, so I’m slotting in this short post between my discussion of low-level details and the post on “object safety”. Other posts in this series on trait objects Peeking inside Trait Objects The Sized Trait Object Safety Where Self Meets Sized: Revisting...

Peeking inside Trait Objects
10 Jan 2015 | original ↗

One of the most powerful parts of the Rust programming language0 is the trait system. They form the basis of the generic system and polymorphic functions and types. There’s an interesting use of traits, as so-called “trait objects”, that allows for dynamic polymorphism and heterogeneous uses of types, which I’m going to look at in more detail...

crates.io crate graph
4 Jan 2015 | original ↗

Rust is a systems programming language that comes with an awesome package manager Cargo, which hooks into the crates.io registry as one of its possible sources of packages. The packages can have dependency relationships between each other, making the database into a natural directed graph. Rust as we have it today is still relatively new, Cargo...

What does Rust's “unsafe” mean?
24 Jul 2014 | original ↗

Rust is an in-development0 systems programming language with a strong focus on no-overhead memory safety. This is achieved through a powerful type system (with similarities to Haskell), and careful tracking of ownership and pointers, guaranteeing safety. However, this is too restrictive for a low-level systems language, an escape hatch is...

Error handling in Rust: a k-NN case study
11 Jun 2014 | original ↗

After posting a Rust translation of some k-nearest neighbour code, I got a few comments asking “how would you handle errors if you wanted to?”. This is the perfect chance to briefly demonstrate a few idioms. See my previous post for context and the original code; like with the code in that post, this code compiles with rustc 0.11.0-pre-nightly...

Comparing k-NN in Rust
10 Jun 2014 | original ↗

In my voyages around the internet, I came across a pair of blog posts which compare the implementation of a k-nearest neighbour (k-NN) classifier in F# and OCaml. I couldn’t resist writing the code into Rust to see how it fared. Rust is a memory-safe systems language under heavy development; this code compiles with the latest nightly (as of...

↑ these items are from RSS. Visit the blog itself at https://huonw.github.io/ to find other articles and to appreciate the author's digital home.