Skip to content

refactor socket pool - #1484

Merged
lihuiba merged 1 commit into
alibaba:mainfrom
lihuiba:new-socket-pool
Jun 26, 2026
Merged

refactor socket pool#1484
lihuiba merged 1 commit into
alibaba:mainfrom
lihuiba:new-socket-pool

Conversation

@lihuiba

@lihuiba lihuiba commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator
refactor socket pool

1. define a new interface ```ISocketPool``` that supports connection grouping by user-defined keys, in addition to Endpoints

2. allow for user-defined callback for connection heartbeat, as construction argument

3. support TCP-Keepalive

4. re-design the implementation to support these new features

5. optimization of the data structure to eliminate redundant stores of keys (Endpoints), as well as fds

6. merge the timer and the collector thread

The keys (Endpoints) were stored 3 times in: unordered_map (fdmap), StreamListNode, and PooledTCPSocketStream. Now they are stored once in StreamListHead, located at the end of StreamListHead to support variable length. And the unordered_map is changed to unordered_set.

The maintainance routines, e.g. evict(), release(), collect(), etc., are changed accordingly.

@lihuiba
lihuiba requested review from Coldwings and WaberZhuang June 20, 2026 03:06
@lihuiba
lihuiba force-pushed the new-socket-pool branch 7 times, most recently from 2d544d3 to 162c50a Compare June 22, 2026 15:01

@Coldwings Coldwings left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

1. define a new interface ```ISocketPool``` that supports connection grouping by user-defined keys, in addition to Endpoints

2. allow for user-defined callback for connection heartbeat, as construction argument

3. support TCP-Keepalive

4. re-design the implementation to support these new features

5. optimization of the data structure to eliminate redundant stores of keys (Endpoints), as well as fds

6. merge the timer and the collector thread

The keys (Endpoints) were stored 3 times in: unordered_map (fdmap), StreamListNode, and PooledTCPSocketStream. Now they are stored once in StreamListHead, located at the end of StreamListHead to support variable length. And the unordered_map is changed to unordered_set.

The maintainance routines, e.g. evict(), release(), collect(), etc., are changed accordingly.
@lihuiba
lihuiba merged commit e7c182a into alibaba:main Jun 26, 2026
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants