When Cache Hits Starve the Event Loop
Comments
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Summary
Octri's Emad Khair shows that awaiting two million in-memory cache hits can starve an event loop. A 10 ms timer fired after about 270 ms in Python and 142 ms in Node.js, because neither runtime handed control back during the loop. Yielding every 1,024 lookups, with asyncio.sleep(0) or setImmediate, let the timer fire near 10 ms, but the batch finished later (336 versus 270 ms in Python, 163 versus 142 ms in Node). The test used five runs per variant and one timer, and no production traffic.