-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add MD.Clone function #177
Conversation
0426d7e
to
288c991
Compare
metadata.go
Outdated
// Preserve nil values. ReverseProxy distinguishes | ||
// between nil and zero-length header values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think we shouldn't copy this comment verbatim from the HTTP implementation. Any mention of a ReverseProxy
is a potential source for confusion, as ttrpc which is typically used for communication between two process on the same physical machine, using a unix domain socket as the transport.
Maybe we should just leave
if vv == nil { // Preserve nil values.
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion @klihub . SGTM, updated the PR.
288c991
to
f976f5f
Compare
b80dcd2
to
1a82100
Compare
Signed-off-by: Jin Dong <[email protected]>
1a82100
to
430f734
Compare
Hi @fuweid thanks for approving/merging this PR! I wonder if we could do a ttrpc release recently (ideally also include this dependency upgrade PR #178 but it's optional). This is mainly to fix a concurrent map write panic in otelttrpc (containerd/otelttrpc#2), which is reported in containerd/containerd#11138) thanks |
ping @djdongjin https://github.com/containerd/ttrpc/releases/tag/v1.2.7 this is new tag. |
Great, thanks for the quick release! |
MD
is not thread-safe so sometimes we need to make a copy before modification, e.g. in containerd,https://github.com/containerd/containerd/blob/c3efa0cb339ffc2d6c9f03d7fb4e5e6577d0194b/pkg/namespaces/ttrpc.go#L30-L36
This PR adds a
MD.Clone
function, similar to golang'shttp.Header.Clone
(the code is copied there). Also add a benchmark that shows golang's implementation is better than a simple copy approach (both memory&latency):