cockroachdb / cockroachdb/cockroach

rpc: investigate large amount of mutex contention in rpc.RemoteClockMonitor and VerifyClockOffset

Open
#159,601 0 comments 0 reactions 0 assignees View on GitHub
C-investigation O-25.4-scale-testing P-2 T-db-server
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

During 25.4 scale testing, we noticed that mutex profiles from most nodes show that the total contention time summed across all goroutines is on the order of millions of seconds. The profile shows that the mutex in RemoteClockMonitor and related code is under heavy contention.

Image

See attached files. These profiles were captured with no workload actively running.

- [mutex-profile.pb.gz](https://github.com/user-attachments/files/24194496/mutex-profile.pb.gz)
- [goroutine-profile.pb.gz](https://github.com/user-attachments/files/24194499/goroutine-profile.pb.gz)

One immediate question is: Can we change `GetOffset` to use `RLock()` instead of `Lock()`?

A slightly more involved question is: Can we replace this mutex with a `syncutil.Map`?

Jira issue: CRDB-57943

Contributor guide

Open the contributing guide

Research direction

Start with RemoteClockMonitor, VerifyClockOffset, and GetOffset, then inspect the attached mutex-profile.pb.gz and goroutine-profile.pb.gz files to trace the contention. Compare the locking behavior with the proposed RLock and syncutil.Map approaches. Done means documenting the contention cause and determining whether either change is safe and effective.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
distributed-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.