I finally got around to reading "How does Sidekiq really work?" by Dan Svetlov dansvetlov.me/sidekiq-inte.... Dang, it did not disappoint. What an enjoyable and in-depth read! A few things that stuck out to me 1/11 🧵
Post
1) @mike.contribsys.com is a exceedingly clever! 2) I've used Ruby for 12+ years now, and I learned new Hash methods from this article 3) The design of Ruby thread interrupts seem heavily influenced by linux signals 4) My next article "when good threads go bad" will pair nicely with this! 2/11 🧵
1) @mike.contribsys.com you clever devil, that Signal.trap approach is ingenious! In my post on thread interrupts, I mentioned that you cannot use rails.logger inside of a signal.trap: bit.ly/43c23Ym. Similarly, you cannot use the Sidekiq logger in trap, which is inconvenient. 3/11 🧵
The full reasons for that are explained in docs.ruby-lang.org/en/3.4/signa..., and have to do with a concept called "reentrancy". But mike bypasses all of that by using using IO.pipe. The io writer is safe to write to in the trap, so that's all it does, it writes the signal. 4/11 🧵
You can change the default return value of a hash by using `default=` on the hash. docs.ruby-lang.org/en/3.4/Hash..... Now instead of nil, you'll return whatever `default` you provided! Very handy. 7/11 🧵
If you read my article on ruby thread interrupts and bitmasks, this will be very familiar! jpcamara.com/2025/10/22/b... I asked koichi if signals were the inspiration, and he confirmed it. It was fun to see the connection and what can be an inspiration for central language apis! 10/11 🧵
0 reposts1 like