Skip to content

optimize: revise lock in cb metric - #202

Open
ppzqh wants to merge 2 commits into
bytedance:developfrom
ppzqh:optimize/cb_metric_lock
Open

ppzqh wants to merge 2 commits into
bytedance:developfrom
ppzqh:optimize/cb_metric_lock

Conversation

@ppzqh

@ppzqh ppzqh commented Feb 4, 2024

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread cloud/circuitbreaker/metricer.go Outdated
w.rw.Lock()
rwx := w.rw.RLocker()
rwx.Lock()
b := w.getBucket()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If getBucket is a readonly op, it can be moved out of the critical zone.

func (w *window) Fail() {
w.rw.Lock()
rwx := w.rw.RLocker()
rwx.Lock()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since all the operations are atomic ops, is it really a need to lock here?

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