Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[m3msg] Specialize messageWriter acker map #4113

Merged
merged 4 commits into from
May 5, 2022
Merged

[m3msg] Specialize messageWriter acker map #4113

merged 4 commits into from
May 5, 2022

Conversation

vdarulis
Copy link
Collaborator

@vdarulis vdarulis commented May 3, 2022

What this PR does / why we need it:

There's no need for shard in metadataKey for internal messageWriter ack map, as it's always the same shard.

name    old time/op  new time/op  delta
Ack-12  56.0ns ± 7%  48.5ns ± 4%  -13.51%  (p=0.000 n=9+9)

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:


Does this PR require updating code package or user-facing documentation?:


delete(a.ackMap, meta.metadataKey)
a.Unlock()
a.mtx.Lock()
defer a.mtx.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Not opposed to the defer here but the old way read just as well? Also just for internal consistency within the class--the other methods also don't defer, so could keep it the same here.

Not hugely important though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure

defer w.RUnlock()
w.m.messageConsumeLatency.Record(time.Duration(w.nowFn().UnixNano() - expectedProcessNanos))
w.m.messageAcked.Inc(1)
m := w.m
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm w.m is a pointer--do we not need to keep holding the lock when use it?

I guess w.m.messageConsumeLatency might be safe.

Dunno maybe we should make the metrics type handle its own locking instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this metrics thing is very awkward, might as well fix it now vs deferring

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

w.m is replaced wholesale when consumers are changed (and so are metric labels)

@vdarulis vdarulis merged commit 898bcf8 into master May 5, 2022
@vdarulis vdarulis deleted the v/msg_writer branch May 5, 2022 18:01
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