Francesco Mazzoli writes technical posts on Linux performance, io_uring, CPU behavior, SIMD, and type theory.
HN commenters praise its performance posts, such as speeding up atan2f and beating the L1 cache, and link its Linux threads and huge pages articles.
https://mazzo.li/posts/fast-pipes.html#splicing :
> In general when we write to a socket, or a file, or in our case a pipe, we’re first writing to a buffer somewhere in the kernel, and then let the kernel do its work. In the case of pipes, the pipe is a series of buffers in the kernel. All this copying is undesirable if we’re in the business of performance.
> Luckily, Linux includes system calls to speed things up when we want to move data to and from pipes, without copying. Specifically:
> - splice moves data from a pipe to a file descriptor, and vice-versa.
> - vmsplice moves data from user memory into a pipe.
> Crucially, both operations work without copying anything.
But then to scale to more than one node, everything has to be copied from the pipe buffer to the network socket buffer; unless splice()'ing from a pipe to a socket is Zero-copy like sendfile() (which doesn't work with pipes IIRC).
"SOCKMAP - TCP splicing of the future" (2019)
https://blog.cloudflare.com/sockmap-tcp-splicing-of-the-future/
> On modern CPUs, avoiding branch misprediction is a key technique to speed up programs.
This is true but it's misleading. The reality is that modern out-of-order superscalar CPUs are so good at branch prediction that it's nearly always better to branch in a tight loop (to allow more ILP) than introduce a data-dependency in a tight loop (which limits ILP). Cf. https://mazzo.li/posts/value-speculation.html, https://yarchive.net/comp/linux/cmov.html
Branchless code should generally be avoided because modern CPUs are not designed to optimize that use case. There are exceptions of course, but those are exceptions.
Well in the articles case, it's the linked list `next` pointers:
https://mazzo.li/posts/value-speculation.html#value-speculation-bailing-us-out
In a happy case, those will be laid out sequentially in memory so you can guess the value of the pointer easily.
(That said your comment still stands, since using linked lists in the first place is much more rare). But I suppose there's probably a lot of other domains where you might have a performance critical loop where some hacky guessing might work.
Surprisingly, I only came across Francesco's blog this month. I stumbled upon the 2021 post "Speeding up atan2f by 50x" while searching for others who have to reimplement trigonometry in SIMD every other year. I've also enjoyed "Beating the L1 cache with value speculation" from the same year, as well as the 2013 Agda sorting example.
Highly recommend checking it out: https://mazzo.li/archive.html
I talk about the cancelability state and how it can help us shortly after that statement: https://mazzo.li/posts/stopping-linux-threads.html#controlled-thread-cancellation . In hindsight I should have made a forward reference to that section when talking about C++. My broad point was that combining C++ exceptions and thread cancellation is fraught with danger and imo best avoided.
The article mentions this: "A few years back, Linux added a way for software to wait on several events at once, which is something Windows had built in for decades, but Linux didn't."
This is not really my area, but from a quick web search, I think they mean io_uring. Here's a blog post about it: https://mazzo.li/posts/uring-multiplex.html