Module: Wurk::PidCache
- Includes:
- CoreExt
- Defined in:
- lib/wurk/pid_cache.rb
Overview
Process.pid is a real syscall on Linux — glibc dropped its getpid cache in
2.25 — and the fetch+execute path reads it twice per job (Component.tid
and the fetcher's per-queue key cache, both of which read it only to notice
a fork). Measured at ~640ns a call against ~110ns for this memo, which is
about 1% of a job's CPU spent asking the kernel a question whose answer
changes at most once in a process's life.
Refreshed in the child half of every fork, so a swarm child never answers with the pid it inherited — the whole reason those two call sites read it.
Same shape as redis-client's PIDCache, deliberately not borrowed from it: that is a private constant of a dependency, and this one is on our hot path.
Defined Under Namespace
Modules: CoreExt
Class Attribute Summary collapse
-
.pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Attribute Summary collapse
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Class Method Summary collapse
Methods included from CoreExt
Class Attribute Details
.pid ⇒ Object (readonly)
Returns the value of attribute pid.
19 20 21 |
# File 'lib/wurk/pid_cache.rb', line 19 def pid @pid end |
Instance Attribute Details
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
40 41 42 |
# File 'lib/wurk/pid_cache.rb', line 40 def pid @pid end |
Class Method Details
.update! ⇒ Object
21 22 23 |
# File 'lib/wurk/pid_cache.rb', line 21 def update! @pid = ::Process.pid end |