Part of #378.
| shape |
rubyrs |
CRuby 3.4 |
× |
Thread.current |
150 |
25 |
6 |
Thread.current[:k] |
248 |
27 |
9 |
Mutex#synchronize {} |
1257 |
53 |
24 |
Per Rails request there are about 20 Thread.current and about 15 Fiber.current calls. IsolatedExecutionState, CurrentAttributes, the logger and Concurrent::Map all go through them. Monitor/Mutex sit on the logger and cache paths.
Do:
- Profile each path with
sample.
- Serve
Thread.current and Fiber.current as cached handles (no lookup or allocation per call).
- Make
Thread#[] / #[]= direct fiber-local table reads.
- Make
Mutex#synchronize a native lock/yield/ensure-unlock, with no Ruby-level begin/ensure frame.
Done when:
- Each shape is within 2× of CRuby.
- Existing Thread/Fiber/Mutex specs pass.
- A diff_cruby fixture covers fiber-local vs thread-local semantics.
Part of #378.
Thread.currentThread.current[:k]Mutex#synchronize {}Per Rails request there are about 20
Thread.currentand about 15Fiber.currentcalls.IsolatedExecutionState,CurrentAttributes, the logger andConcurrent::Mapall go through them.Monitor/Mutexsit on the logger and cache paths.Do:
sample.Thread.currentandFiber.currentas cached handles (no lookup or allocation per call).Thread#[]/#[]=direct fiber-local table reads.Mutex#synchronizea native lock/yield/ensure-unlock, with no Ruby-levelbegin/ensureframe.Done when: