Implement custom libevent adapter to fix timeout issues with event prioritization #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses timeout-related issues in Redis::Cluster::Fast by implementing a custom libevent adapter with event
prioritization.
Key Changes
src/adapters/libevent.h
to handle timeout issues specific to our use caserun_event_loop
truly non-blocking withEVLOOP_NONBLOCK
event_base_priority_init
Problem Background
When using hiredis-cluster's async context, we encountered situations where timeout events would fire even when Redis
responses were already available to read. This particularly affected scenarios where event loop execution was delayed due
to system load.
Approach Taken
After researching the issue and consulting with the hiredis community hiredis issue
#1286 , we learned that:
general-purpose adapter could introduce starvation risks in multi-client scenarios
from receiving necessary timeouts
Our Solution
Given Redis::Cluster::Fast's specific usage patterns and requirements, we decided to maintain our own libevent adapter:
Why this works for our use case
Implementation Details
Our custom adapter (
src/adapters/libevent.h
) implements:Test Plan
This change improves reliability for Redis::Cluster::Fast users while respecting the design decisions of the upstream
hiredis project.