HNHacker News
TopNewBestAskShowJobs

stephencanon

5,607 karma · joined December 21, 2011

I manage the low-level swift team. Previously I worked on high-performance math libraries.
submissionscomments
stephencanon··on Faster asin() was hiding in plain sight
For the asinf libcall on macOS/x86, my former colleague Eric Postpischil invented the novel (at least at the time, I believe) technique of using a Remez-optimized refinement polynomial following rsqrtss instead of the standard Newton-Raphson iteration coefficients, which allowed him to squeeze out just enough extra precision to make the function achieve sub-ulp accuracy. One of my favorite tricks.

We didn't carry that algorithm forward to arm64, sadly, because Apple's architects made fsqrt fast enough that it wasn't worth it in scalar contexts.

stephencanon··on Faster asin() was hiding in plain sight
Ideally either one is just a library call to generate the coefficients. Remez can get into trouble near the endpoints of the interval for asin and require a little bit of manual intervention, however.
stephencanon··on Faster asin() was hiding in plain sight
Newer rsqrt approximations (ARM NEON and SVE, and the AVX512F approximations on x86) make the behavior architectural so this is somewhat less of a problem (it still varies between _architectures_, however).
stephencanon··on Faster asin() was hiding in plain sight
These sorts of approximations (and more sophisticated methods) are fairly widely used in systems programming, as seen by the fact that Apple's asin is only a couple percent slower and sub-ulp accurate (https://members.loria.fr/PZimmermann/papers/accuracy.pdf). I would expect to get similar performance on non-Apple x86 using Intel's math library, which does not seem to have been measured, and significantly better performance while preserving accuracy using a vectorized library call.

The approximation reported here is slightly faster but only accurate to about 2.7e11 ulp. That's totally appropriate for the graphics use in question, but no one would ever use it for a system library; less than half the bits are good.

Also worth noting that it's possible to go faster without further loss of accuracy--the approximation uses a correctly rounded square root, which is much more accurate than the rest of the approximation deserves. An approximate square root will deliver the same overall accuracy and much better vectorized performance.

stephencanon··on Yann LeCun's AI startup raises $1B in Europe's largest ever seed round
Yann is definitely more well-known outside of academia. Inside academia, it's going to depend a lot on your specific background and how old you are.
stephencanon··on BMW Group to deploy humanoid robots in production in Germany for the first time
Mechanically, you're probably right, but the screen-centric controls of the newer generation are _awful_ by comparison to the F generation's physical buttons and dials (this isn't BMW though, it's the whole industry).

My wife and I both have F31s, which we will drive until we can no longer source replacement parts unless the industry comes to its senses first (unlikely). Any time we've ever looked at plausible replacements, the screen-based controls are an immediate hard no.

stephencanon··on BMW Group to deploy humanoid robots in production in Germany for the first time
Our (~2015) 3-series controls are just about perfect. Where they differ from Honda/Toyota's controls that I am also very familiar with, they're noticeably better now that I'm familiar with them. Everything is really well thought-out.

Of course, now they (and almost every other manufacturer) have followed Tesla off the cliff and made everything a screen, so the current generation cars have abysmal controls.

stephencanon··on Schubfach: The smallest floating point double-to-string impleme
Schubfach's table is quite large compared to some alternatives with similar performance characteristics. swiftDtoa's code and tables combined are smaller than just Schubfach's table in the linked implementation. Ryu and Dragonbox are larger than swiftDtoa, but also use smaller tables than Schubfach, IIRC.

If I$ is all you care about, then table size may not matter, but for constrained systems, other algorithms in general, and swiftDtoa in particular, may be better choices.

stephencanon··on DEC64: Decimal Floating Point (2020)
IEEE 754 is a floating point standard. It has a few warts that would be nice to fix if we had tabula rasa, but on the whole is one of the most successful standards anywhere. It defines a set of binary and decimal types and operations that make defensible engineering tradeoffs and are used across all sorts of software and hardware with great effect. In the places where better choices might be made knowing what we know today, there are historical reasons why different choices were made in the past.

DEC64 is just some bullshit one dude made up, and has nothing to do with “floating-point standards.”

stephencanon··on Implicit ODE solvers are not universally more robust than explicit ODE solvers
The orbital example where BDF loses momentum is really about the difference between a second-order method (BDF2) and a fourth-order method (RK), rather than explicit vs implicit (but: no method with order > 2 can be A-stable; since the whole point of implict methods is to achieve stability, the higher order BDF formulas are relatively niche).

There are whole families of _symplectic_ integrators that conserve physical quantities and are much more suitable for this sort of problem than either option discussed. Even a low-order symplectic method will conserve momentum on an example like this.

stephencanon··on Pontevedra, Spain declares its entire urban area a "reduced traffic zone"
> Where you are not under any circumstances can be robbed by a random person on a street.

I will be very surprised if there's anywhere in the world where the expected loss from being robbed on the street while walking exceeds the expected loss from being in a car accident while driving.

Getting in a car is by far the most dangerous thing most people do routinely.

stephencanon··on Who Invented Backpropagation?
I don't think most people think to do either direction by hand; it's all just matrix multiplication, you can multiply them in whatever order makes it easier.
stephencanon··on White Mountain Direttissima
All 48 peaks on the AMC white mountains 4000-footers¹ list in one continuous trek (no driving/shuttling/etc between trailheads).

¹ this list is outdated vis-a-vis modern mapping and includes at least one peak shorter than 4000 feet (Tecumseh) and omits at least one peak that should qualify per the rules (Guyot), but if the list were updated they would still have completed the direttissima, since they passed over Guyot on the way to the Bonds (dropping Tecumseh could only make the diretissima easier, but I'm not sure it makes much of a difference; it's been a decade or so since I hiked that section of the whites).

As an aside, that day 5 from Wildcat to Cabot is absolutely brutal even if you're fresh, to say nothing of having already covered 180 miles in the previous four days.

stephencanon··on Operation Costs in CPU Clock Cycles (2016)
Worth noting that division (integer, fp, and simd) has gotten much cheaper in the last decade. Division is partially pipelined on common microarchitectures now (capable of delivering a result every 2-4 cycles) and have greatly reduced latency from ~30-80 cycles down to ~10-20 cycles.

This improvement is sufficient to tip the balance toward favoring division in some algorithms where historically programmers went out of their way to avoid it.

stephencanon··on Installing a mini-split AC in a Brooklyn apartment
Yeah, we live far north of NYC where it gets much colder, and have never spent nearly that much on heating. Even when we lived in a converted barn from the 1930s with single pane windows and no wall insulation, the most we ever spent was about $500/month. Now (new construction, triple-pane windows, ground-sourced heat pump) it’s more like $80/month
stephencanon··on AI Ethics is being narrowed on purpose, like privacy was
Raising children involves a whole lot of simple constraints that you gradually relax.

“Don’t touch the knife” becomes “You can use _this_ knife, if an adult is watching,” which becomes “You can use these knives but you have to be careful, tell me what that means” and then “you have free run of the knife drawer, the bandages are over there.” But there’s careful supervision at each step and you want to see that they’re ready before moving up. I haven’t seen any evidence of that at all in LLM training—it seems to be more akin to handing each toddler every book ever written about knives and a blade and waiting to see what happens.

stephencanon··on Consider using Zstandard and/or LZ4 instead of Deflate
"Only slightly faster in decompression time."

m5 vs -19 is nearly 2.5x faster to decompress; given that most data is decompressed many many more times (often thousands or millions of times more, often by devices running on small batteries) than it is compressed, that's an enormous win, not "only slightly faster".

The way in which it might not be worth it is the larger size, which is a real drawback.

stephencanon··on SF may soon ban natural gas in homes and businesses undergoing major renovations
It’s really not. We built an all-electric ADU for my parents, then ended up living in it while renovating our house. As someone who cooks pretty much all meals, the induction range is better in almost every way than the fancy gas range that came with our house, so we’re replacing it with an induction cooktop in the renovation.
stephencanon··on That XOR Trick (2020)
Right. Another way to see this is that for a general (possibly non-Abelian) group, the inverse of xy is y⁻¹x⁻¹ (because xyy⁻¹x⁻¹ = x1x⁻¹ = xx⁻¹ = 1 [using "1" for the identity here, as is typical for general groups], or more colloquially, "the inverse operation of putting on your socks and shoes is taking off your shoes and socks"). For an Abelian group, y⁻¹x⁻¹ = x⁻¹y⁻¹, and we're done.
stephencanon··on Swift Binary Parsing
Worth pointing out that we're already using this in the OS for "real work", so we consider it to be production-usable, despite the 0.x tag. The pre-1.0 tag is really about the fact that we expect to make some changes to the high-level patterns as we do more to adopt Span-based APIs over the coming months.

Which means, yes, using it now is signing up for some source breaks, but they won't be too abrupt and this is considerably more stable than a typical first 0.x release would be.

stephencanon··on Highly efficient matrix transpose in Mojo
The one pure transpose case that does come up occasionally is an in-place non-square transpose, where there is a rich literature of very fussy algorithms. If someone managed to make any headway with compiler optimization there, I'd be interested.
stephencanon··on Is TfL losing the battle against heat on the Victoria line?
Or -1 to 1 Celsius, for that matter.
stephencanon··on Linguists find proof of sweeping language pattern once deemed a 'hoax'
dust on crust, firn, mashed potatoes (with or without gravy), graupel, chowder, crud, packed powder, blower pow, chop, fluff, smoke, ...
stephencanon··on I decided to pay off a school’s lunch debt
Varies enormously between states and school districts.

In our public elementary school, there are two or three options each day: a hot meal of some sort, some days a hot vegetarian meal, and a salad bar that kids can choose what they want from (which usually includes some options that you wouldn't call "salad").

It's not fine dining, but the quality and variety is generally pretty decent. The kids have accounts, and parents are expected to refill a negative balance, but every kid gets the lunch of their choice regardless.

stephencanon··on Fundamental flaws of SIMD ISAs (2021)
The basic problem with almost every "SIMD is flawed, we should have vector ISAs" article or post (including the granddaddy, "SIMD Instructions Considered Harmful"), is that they invariably use SAXPY or something else trivial where everything stays neatly in lane as their demonstration case. Of course vector ISAs look good when you show them off using a pure vector task. This is fundamentally unserious.

There is an enormous quantity of SIMD code in the world that isn't SAXPY, and doesn't stay neatly in lane. Instead it's things like "base64 encode this data" or "unpack and deinterleave this 4:2:2 pixel data, apply a colorspace conversion as a 3x3 sparse matrix and gamma adjustment in 16Q12 fixed-point format, resize and rotate by 15˚ with three shear operations represented as a linear convolution with a sinc kernel per row," or "extract these fields from this JSON data". All of which _can totally be done_ with a well-designed vector ISA, but the comparison doesn't paint nearly as rosy of a picture. The reality is that you really want a mixture of ideas that come from fixed-width SIMD and ideas that come from the vector world (which is roughly what people actually shipping hardware have been steadily building over the last two decades, implementing more support for unaligned access, predication, etc, while the vector ISA crowd writes purist think pieces)

stephencanon··on Verus: Verified Rust for low-level systems code
Indeed. Exhaustively testing a 64b input space requires about 600 machine years for each nanosecond that the function under test takes to run. So, _very_ short-running critical functions are testable on a cluster, but not efficiently testable, and if a function is simple enough to be testable, then it's usually easier to prove that it's correct instead.
stephencanon··on The Greatest Motorcycle Photo
The desert in question isn't all sandy dunes; there's a lot of rocky or compacted surface (see photo), so you can make pretty decent time (but yeah, sustaining 4mph would be pushing it for most people).
stephencanon··on The Greatest Motorcycle Photo
In the desert, you often really don't want to be walking midday, but if the moon is out doing 20 miles in a night isn't too bad, and doing it split over two days is fine. 5 or 6 liters of water plus some food would be plenty, depending on what you have available to carry that ~15 pounds splitting into two days may be more comfortable. Either way, infinitely less risky than building a motorcycle.
stephencanon··on The Greatest Motorcycle Photo
Yeah, walking 20 miles, desert or not, is a far better plan.
stephencanon··on When I converted my home from gas to electric my utility bills nearly doubled
Absolutely correct. Given that they're in California and the house wasn't new construction, we can pretty safely assume that it was under-insulated compared to what's possible. Doing a proper audit and fixing air leaks and insulation is usually the most cost-effective improvement you can make to a house (getting it right to begin with is even more cost-effective, but lots of builders still don't know what they're doing).

As sibling notes, it can be invasive and disruptive vs. just replacing some appliances in a few days, but it's still more cost effective (and will allow your eventual replacement HVAC system to be sized smaller, netting additional savings when you do that).

← PreviousPage 2 of 34Next →