While on a hike with colleagues, one asked a thought provoking question: Should the United States Post Service (USPS) operate as an Internet Service Provider (ISP)? This post is an opinion piece playing with that idea; here are my thoughts. It’s far from a hot take, and has been discussed before. Article 1 Section 8 of the United States Constitution…
Nick Desaulniers
https://nickdesaulniers.github.io/ · 43 posts · history since 2001 · active
10 Mar 2023
If you’re new to the Arm ecosystem, consider this a quick primer on terms you likely have seen before but might have questions about. The Arm architecture is a family of Reduced Instruction Set Architectures (RISC) with simple addressing modes. Data processing is done on register operands otherwise relying on loads and stores to move data into and out of…
1 Feb 2023
The Open Source software development model is a powerful approach to collaboratively iterating on a shared solution to a common problem. Rather than competitors duplicating effort to come up with multiple suboptimal solutions, they can collaborate together to build something greater. Forking is the term used to denote making a copy of a codebase. The copy, known as a “fork”…
27 Jan 2023
A maximal length sequence of branch-free code that terminates with a branch or jump is referred to as a basic block. A basic block that branches to another forms an edge in the Control Flow Graph (CFG). The initial basic block starting an edge is the predecessor; it precedes and is succeeded by the successor basic block. An edge between…
20 Jan 2023
Unless work is done per architecture to implement HAVE_ARCH_VMAP_STACK / CONFIG_VMAP_STACK, the Linux kernel defaults to two pages worth of stack per thread. Note: on many contemporary systems the page size is 4KiB, but this is actually configurable for many architectures. The trade offs probably require a separate post. If you see code that checks for alignment via bitwise tricks…
6 Apr 2020
“War stories” in programming are entertaining tales of truly evil bugs that kept you up at night. Inspired by posts like My Hardest Bug Ever, Debugging an evil Go runtime bug, and others from /r/TalesFromDebugging, I wanted to share with you one of my favorites from recent memory. Recent work has given me much fulfilment and a long list of…
12 May 2019
TL;DR Prefer f(void) in C to potentially save a 2B instruction per function call when targeting x86_64 as a micro-optimization. -Wstrict-prototypes can help. Doesn’t matter for C++. The Problem While messing around with some C code in godbolt Compiler Explorer, I kept noticing a particular funny case. It seemed with my small test cases that sometimes function calls would zero…
18 Jan 2019
Support for a long awaited GNU C extension, asm goto, is in the midst of landing in Clang and LLVM. We want to make sure that we release a high quality implementation, so it’s important to test the new patches on real code and not just small test cases. When we hit compiler bugs in large source files, it can…
24 Oct 2018
Typically, when we modify a program, we’d like to run it to verify our changes. Before booting a compiled Linux kernel image on actual hardware, it can save us time and potential headache to do a quick boot in a virtual machine like QEMU as a sanity check. If your kernel boots in QEMU, it’s not a guarantee it will…
2 Jun 2018
ccache, the compiler cache, is a fantastic way to speed up build times for C and C++ code that I previously recommended. Recently, I was playing around with trying to get it to speed up my Linux kernel builds, but wasn’t seeing any benefit. Usually when this happens with ccache, there’s something non-deterministic about the builds that prevents cache hits.…
5 Sept 2017
A blog post from a few years ago that really stuck with me was Martin Olsson’s Browser Engines 2015: Commit Rates and Active Developer Counts, where he shows information about the number of authors and commits to popular web browsers. The graphs and analysis had interesting takeaways like showing the obvious split in blink and webkit, and relative number of…
31 May 2017
Clang-Tidy is a linter from the LLVM ecosystem. I wanted to try to run it on the Linux kernel to see what kind of bugs it would find. The false positive rate seems pretty high (a persistent bane to static analysis), but some patching in both the tooling and the source can likely help bring this rate down. The most…
16 May 2017
After working on the Linux kernel for Nexus and Pixel phones for nearly a year, and messing around with the excellent Eudyptula challenge, I finally wanted to take a crack at submitting patches upstream to the Linux kernel. This post is woefully inadequate compared to the existing documentation, which should be preferred. http://elixir.free-electrons.com/linux/latest/source/Documentation/process https://kernelnewbies.org/FirstKernelPatch I figure I’d document my workflow,…
20 Nov 2016
This is the second post in a series on memory segmentation. It covers working with static and dynamic libraries in Linux and OSX. Make sure to check out the first on object files and symbols. Let’s say we wanted to reuse some of the code from our previous project in our next one. We could continue to copy around object…
13 Aug 2016
What was supposed to be one blog post about memory segmentation turned into what will be a series of posts. As the first in the series, we cover the extreme basics of object files and symbols. In follow up posts, I plan to talk about static libraries, dynamic libraries, dynamic linkage, memory segments, and finally memory usage accounting. I also…
1 Jul 2016
Let’s say you want to build a hello world command line application in C or C++ and run it on your Android phone. How would you go about it? It’s not super practical; apps visible and distributable to end users must use the framework (AFAIK), but for folks looking to get into developing on ARM it’s likely they have an…
18 Jun 2016
I was looking to set up the mutt email client on my Ubuntu box to go through my gmail account. Since it took me a couple of hours to figure out, and I’ll probably forget by the time I need to know again, I figure I’d post my steps here. I’m on Ubuntu 16.04 LTS (lsb_release -a) Install mutt: $…
30 May 2016
This post is a follow up to my previous blog post about word size. Three C/C++ programmers walk into a bar. One argues that sizeof(void*) is equivalent to sizeof(long), one argues that sizeof(void*) is equivalent to sizeof(int), and the third argues it’s sizeof(long long). Simultaneously, they’re all right, but they’re also all wrong (and need a lesson about portable C…
15 May 2016
Recently, there some was some confusion between myself and a coworker over the definition of a “word.” I’m currently working on a blog post about data alignment and figured it would be good to clarify some things now, that we can refer to later. Having studied computer engineering and being quite fond of processor design, when I think of a…
20 Jan 2016
I’m hacking on an assembly project, and wanted to document some of the tricks I was using for figuring out what was going on. This post might seem a little basic for folks who spend all day heads down in gdb or who do this stuff professionally, but I just wanted to share a quick intro to some tools that…
14 Aug 2015
I was recently lucky enough to get to attend my first SIGGRAPH conference this year. While I didn’t attend any talks, I did spend some time in the expo. Here is a collection of some of the neat things I saw at SIGGRAPH 2015. Sorry it’s not more collected; I didn’t have the intention of writing a blog post until…
23 Jul 2015
21st Century C by Ben Klemens was a great read. It had a section with an intro to autotools, git, and gdb. There are a few other useful tools that came to mind that I’ve used when working with C and C++ codebases. These tools are a great way to start contributing to Open Source C & C++ codebases; running…
25 May 2015
Interpreters and compilers are interesting programs, themselves used to run or translate other programs, respectively. Those other programs that might be interpreted might be languages like JavaScript, Ruby, Python, PHP, and Perl. The other programs that might be compiled are C, C++, and to some extent Java and C#. Taking the time to do translation to native machine code ahead…
22 Feb 2015
How is it possible for us to communicate securely when there’s the possibility of a third party eavesdropping on us? How can we communicate private secrets through public channels? How do such techniques enable us to bank online and carry out other sensitive transactions on the Internet while trusting numerous relays? In this post, I hope to explain public key…
25 Jan 2015
It’s a feeling of immense satisfaction when we complete a major achievement. Being able to say “it’s done” is such a great stress relief. Recently, I completed work on my first publication, a chapter about Emscripten for the upcoming book WebGL Insights to be published by CRC Press in time for SIGGRAPH 2015. One of the life goals I’ve had…
18 Apr 2014
…"‘Our speech interposes itself between apprehension and truth like a dusty pane or warped mirror. The tongue of Eden was like a flawless glass; a light of total understanding streamed through it. Thus Babel was a second Fall.’ And Isaac the Blind, an early Kabbalist, said that, to quote Gershom Scholem’s translation, ‘The speech of men is connected with divine…
1 Mar 2014
Your application just broke, oh no! It couldn’t have been your code, right? I’ve always had trouble spotting mistakes in my own work such as spelling, grammar, mathematical, or even in programming. With spelling or grammar, office applications quickly pick up on my mistakes and underline them for me, but most of my mistakes come from my own hubris. I’m…
26 Sept 2013
ECMAScript 5’s Function.prototype.bind is a great tool that’s implemented in all modern browser JavaScript engines. It allows you to modify the context, this, of a function when it is evaluated in the future. Knowing what this refers to in various contexts is key to being a professional JavaScript developer; don’t show up to an interview without knowing all about it.…
28 Aug 2013
Node.js is a great runtime for writing applications in JavaScript, the language I primarily develop in. CoffeeScript is a programming language that compiles to JavaScript. Why would we write a reusable piece of code, a module , in CoffeeScript? CoffeeScript is a very high level language and beautifully brings together my favorite aspects of JavaScript, Ruby, and Python. In this…
25 Jul 2013
Just a quick post on something I just discovered and found neat (I always find obscure C syntax interesting). I was trying to figure out how to use a C designated initializer, where a member was a pointer to another designated initializer. At this point, you need a compound literal. Just a quick background on C initialization: // verbosely create…
3 Jul 2013
If you’ve done nothing wrong, then you’ve got nothing to hide. Wrong. Nothing ever justifies giving up your human rights , especially to prove lack of wrong doing, and any government that asks you to do so is not your friend. Terrorism has become a weapon used against us by those elected to lead to keep us compliant, like blinders…
13 Jun 2013
Besides 3 months interrupted to finish degree requirements, and including an internship, I’ve been at Mozilla for about 8 months now. After reading a blog post of another software engineer’s experience at Microsoft, I count my blessings. Reading that article set off too many alarms in my head. It was well written, and I sugguest you go read it, but…
7 May 2013
The other day I was thinking about the function for performing dynamic memory allocation in the C standard library, malloc. From the manual pages, If successful, the malloc() function returns a pointer to allocated memory. If there is an error, it returns a NULL pointer and sets errno to ENOMEM. One of the most common errors when using malloc is…
29 Apr 2013
I would like to die on Mars… Elon Musk Elon Musk, the 21st Century Industrialist, Bloomberg Well, isn’t that forward thinking? Granted, the full quote I would like to die on Mars, just not on impact is meant to sound hopeful of his company, SpaceX. I agree that some day, humans will be buried on Mars. But is it forward…
3 Apr 2013
Ever since I learned about Just In Time Compilation from the various Ruby VMs and JavaScript VMs, I’ve been inspired. I could tell you all about how just in time (JIT) compilation worked, and how it could give your interpreted language a speed boost. It was so cool. Well, it still is! There’s a ton of research going on around…
28 Feb 2013
Over the past few years, there’s been certain paradigm shifts in web development. When you think of milestones that really changed how development on the web was done, the two biggest were Ajax and HTML5. Development was identifiably different before and after such technological advancements. There were some who initially doubted the technologies, but I’m sure such doubters eventually saw…
26 Jan 2013
On an interview with Square, I made the mistake of stating that one of the benefits of working with JavaScript over C is that functions are first class in JavaScript, therefore they may be passed around. To which the interviewer replied, “Well, C can do that, what about function pointers?” What? Luckily, I was able to get out of that…
19 Jan 2013
Last week, the Internet community lost a member in the on going war against the copyright industry. While I’ve never met the deceased, or even heard of the deceased before his suicide, I’m horrified. I’m horrified that the government we are asked to put so much faith in, would give someone, not that different from myself, such a ridiculous sentence.…
14 Jan 2013
It’s all about closures. Understanding scope is paramount to coding. What can you access and what can’t you access. Closures allow us to access variables that otherwise might be awkward to pass into a function. Closures can help us out of tricky situations, but can confuse those from backgrounds with (typically) statically typed languages that may not support closing over…
1 Jan 2001
Nick Desaulniers is a software engineer at Google working on compiling the Linux Kernel with Clang (and LLVM). Nick has previously worked on TensorFlow’s Accelerated Linear Algebra (XLA) JIT compiler for Tensor Processing Units (TPUs), and the Linux kernel for the Nexus and Pixel phones while at Google. Nick also hacked on open source projects like Firefox, Firefox OS, Emscripten,…
2023 Mar 10 USPS as an ISP 2023 Mar 10 Disambiguating Arm, Arm ARM, Armv9, ARM9, ARM64, AArch64, A64, A78, ... 2023 Feb 1 Forking is not free; the hidden costs 2023 Jan 27 Critical Edge Splitting 2023 Jan 20 Debugging -Wframe-larger-than= 2020 Apr 6 Off by Two 2019 May 12 f() vs f(void) in C vs C++ 2019 Jan…
Desaulniers, Nick. “WebGL Off the Main Thread.” Mozilla Hacks. Mozilla. January 22, 2015. Link Desaulniers, Nick. “Better than Gzip Compression with Brotli.” Mozilla Hacks. Mozilla. November 6, 2015. Link Desaulniers, Nick. “Stereoscopic Rendering in WebVR.” Mozilla Hacks. Mozilla. September 16, 2015. Link Desaulniers, Nick. “Streaming media on demand with Media Source Extensions.” Mozilla Hacks. Mozilla. July 1, 2015. Link Desaulniers,…
2019 Compiling the Linux Kernel with LLVM Tools FOSDEM ‘19’ - Brussels, Belgium - February 2-3 slides - video 2018 Compiling the Linux Kernel with Clang Linux Plumbers Conference 2018 - Vancouver, Canada - November 13-15 slides - video 2017 Compiling Android Userspace and Linux Kernel with LLVM 2017 US LLVM Developers’ Meeting - San Jose, CA - October 18-19…