I’m coming up on my two-year anniversary of joining Amazon Web Services. More than half of this has been spent at home without any face-to-face meetings with colleagues. Or anyone else. I thought this would weaken my connection to the...
lo.calho.st - Using black magic to make a fast circular buffer.
Yesterday, I took a glance at the Wikipedia page for the circular buffer and was intrigued by an alleged optimization technique that I was not familiar with: A circular-buffer implementation may be optimized by mapping the underlying buffer to two contiguous regions of virtual memory. (Naturally, the underlying buffer‘s length must then equal some multiple of the system’s page size.) Reading from and writing to the circular buffer may then be carried out with greater efficiency by means of direct memory access; those accesses which fall beyond the end of the first virtual-memory region will automatically wrap around to the beginning of the underlying buffer. When the read offset is advanced into the second virtual-memory region, both offsets—read and write—are decremented by the length of the underlying buffer When implementing a circular buffer, we need to handle the case where a message spans the “discontinuity” in the queue and wraps around. The naive circular buffer’s write routine might employ a byte-by-byte write and look something like this: void put(queue_t *q, uint8_t *data, size_t size) { for(size_t i = 0; i < size; i++){ q->buffer[(q->tail + i) % q->buffer_size] = data[i]; } q->tail = (q->tail + size) % q->buffer_size; } The fact that a modulo operation is necessary to index into the array makes this function hard (if not impossible) to vectorize, and thus unnecessarily slow. Though there are other optimizations we can make, the technique offered in the above Wikipedia surpasses hardware-agnostic approaches by virtue of the fact that the memory management unit can handle most of the wrap-around logic on our behalf. I was so excited by this idea that I did no further research whatsoever, and implemented it based only on the brief description above. The next two sections overview the circular buffer’s design and the behavior of...
The Ultimate Guide to Decentralized Prediction Markets
Welcome to the Future: You wake up one early spring morning in 2036 and ask Siri’s granddaughter “Will it rain today?” “No,” she politely replies, “but according to Augur, we’ll see some scattered showers around 12:30pm next Tuesday.” When you open the refrigerator, you discover that your farm-to-fridge drone delivery service has bulked up on orange juice, since prices are forecasted to rise next week. Speaking of prices, you’re thinking about a new apartment, but you see that rental rates in y
How Two Bell Labs Researchers Set the Rules for the Modern Compiler – The New Stack
Two alumni of the historic Bell Labs research facility recently have received one of the highest honors in the computer programming field. Two @EPrinceton Ph.D. alumni have been named recipients of @TheOfficialACM's 2020 ACM A.M. Turing Award — often referred to as the "Nobel Prize of Computing." Congrats to Alfred Aho *67 and Jeffrey Ullman…
Numberless Soviet era phones. Used by high ranking officials, they rang through direct to the Kremlin. No dial required. All images found on Ebay. pic.twitter.com/NFLN9LmwIo— Present & Correct (@presentcorrect) June 8, 2021
Sunday Firesides: Despise Not the Thing That Would Save You | The Art of Manliness
In the heat of the afternoon, a stag stopped at a pool in the woods to drink. Seeing his reflection in its still waters, he took a moment to survey himself from head to foot. He admiringly appraised the shape and size of his noble, wide-spreading antlers. Yet he looked with disapproval upon his legs, […]
First: If you’re a frequent flyer on American and haven’t flown in over a year, it’s possible your miles are going to expire very soon. You can fix this by “donating” …
OS/2 Warp 4 on Emulation – The Sociopathic Mind of a Certified Eclectic
How to install OS/2 Warp onto a QEmu emulation software to use under Linux. Should also be the same under Windows, with slightly different command structures.
OS/2 Warp 3 was the operating system that led me into an adventure back in 1994. This OS made me escape MS-DOS and Windows, and then made me enter the Linux world when I couldn’t afford Warp 4. Let’s walk down the memory lane!
It originally means, “no longer believing in magic.” Humans like magic. It gives us solace and energy and hope. In many ways, the rational era of science and engineering and evidence an…
DevTerm is a portable terminal that might just be the perfect cyberdeck for sysadmins and writers too | Boing Boing
DevTerm is a portable computer tailored directly to the needs of developers, sysadmins, and anyone else who works with text and such. It’s so fully-featured (and uniquely featured) it’s…