Programming and Education Leftovers
-
Tony Finch ☛ inlined nearly divisionless random numbers
Lemire’s nearly-divisionless algorithm unbiased bounded random numbers has a fast path and a slow path. In the fast path it gets a random number, does a multiplication, and a comparison. In the rarely-taken slow path, it calculates a remainder (the division) and enters a rejection sampling loop.
When Lemire’s algorithm is coupled to a small random number generator such as PCG, the fast path is just a handful of instructions. When performance matters, it makes sense to inline it. It makes less sense to inline the slow path, because that just makes it harder for the compiler to work on the hot code.
Lemire’s algorithm is great when the limit is not a constant (such as during a Fisher-Yates shuffle) or when the limit is not a power of two. But when the limit is a constant power of two, it ought to be possible to eliminate the slow path entirely.
What are the options?
-
Karl Seguin ☛ Be Careful When Assigning ArenaAllocators
A bug was recently reported in pg.zig which was the result of a dangling pointer to an ArenaAllocator (1). This amused me since (a) I write a lot about dangling pointers (b) I write a bit about ArenaAllocators and (c) it isn't the first time I've messed this up.
-
Perl / Raku
-
Arne Sommer ☛ Broken Digits with Raku
This is my response to The Weekly Challenge #275.
-
-
Education
-
Yukinu ☛ Book: Free As In Freedom (2.0), Richard Stallman And The Free Software Movement
Free As In Freedom is a biographical (and partially autobiographical) account of the founder of the Free Software Movement, Richard Matthew Stallman (throughout the post I'll refer to him via the commonly used initials RMS). The book is broken up into 13 chapters, covering years from the: [...]
-