cockroachdb / cockroachdb/cockroach
optimize timer allocations with stream pools
Open
C-enhancement
T-db-server
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
Stream pool implementation creates a timer in each iteration.
https://github.com/cockroachdb/cockroach/blob/6806299943a595425030f0ad3c54ccc680c89842/pkg/rpc/stream_pool.go#L127-L133
Each stream in the pool waits for a request to be sent before it timeout after 10s or the context is cancelled. If a request arrives within idle timeout, we create a timer unnecessarily. As of Go 1.23, the garbage collector will reclaim any unreferenced, unexpired timers, so we no longer have to worry about leaking timers. But we still room to avoid these allocations potentially by pooling them.
Jira issue: CRDB-50568
Contributor guide
Assessment
This issue has not been assessed yet.