• tzongw's avatar
    improve latency when a client is unblocked by module timer (#9593) · f5160ed0
    tzongw authored
    Scenario:
    1. client block on command `XREAD BLOCK 0 STREAMS mystream  $`
    2. in a module, calling `XADD mystream * field value` via lua from a timer callback
    3. client will receive response after some latency up to 100ms
    
    Reason:
    When `XADD` signal the key `mystream` as ready, `beforeSleep` in next eventloop will call
    `handleClientsBlockedOnKeys` to unblock the client and add pending data to write but not
    actually install a write handler, so next redis will block in `aeApiPoll` up to 100ms given `hz`
    config as default 10, pending data will be sent in another next eventloop by
    `handleClientsWithPendingWritesUsingThreads`.
    
    Calling `handleClientsBlockedOnKeys` before `handleClientsWithPendingWritesUsingThreads`
    in `beforeSleep` solves the problem.
    f5160ed0
server.c 267 KB