Cache calls to Process.pid

04-Mar-2023 922
Cache calls to Process.pid to avoid lots of useless system calls on modern Linux.Ruby's Process.pid calls the standard libc getpid(2), historically pretty much all implementations of the libc have been caching this function to avoid doing a syscall everytime.However glibc 2.25 released in 2017 removed that cache, causing a performance regression for application frequently monitoring the PID.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle