Skip to content

wasm: fix sending initial metadata in gRPC callouts. - #16502

Merged
mattklein123 merged 2 commits into
envoyproxy:mainfrom
PiotrSikora:wasm-fix_grpc_initial_metadata
May 27, 2021
Merged

mattklein123 merged 2 commits into
envoyproxy:mainfrom
PiotrSikora:wasm-fix_grpc_initial_metadata

Conversation

@PiotrSikora

Copy link
Copy Markdown
Contributor

Signed-off-by: Piotr Sikora [email protected]

@PiotrSikora

Copy link
Copy Markdown
Contributor Author

Tests broken due to a memory leak in the C++ SDK. Fixed in proxy-wasm/proxy-wasm-cpp-sdk#114, I will update this PR once it's merged there.

Shikugawa
Shikugawa previously approved these changes May 15, 2021
@Shikugawa

Copy link
Copy Markdown
Member

@PiotrSikora https://github.com/envoyproxy/envoy/pull/16502/files#diff-c386f59113c79157fdc6b88ce0c4c14e307509bd7038ce816821985293d55410L1127-R1127

I think that this extra copy is not avoidable. But it will be pretty heavy to be copied per gRPC callout. What do you think about this?

@PiotrSikora

Copy link
Copy Markdown
Contributor Author

@PiotrSikora https://github.com/envoyproxy/envoy/pull/16502/files#diff-c386f59113c79157fdc6b88ce0c4c14e307509bd7038ce816821985293d55410L1127-R1127

I think that this extra copy is not avoidable. But it will be pretty heavy to be copied per gRPC callout. What do you think about this?

Note that only the gRPC initial metadata is copied (added) to the existing HTTP headers, so it should be relatively lightwieght.

But no, I don't see a way to avoid the extra copy using existing APIs. @mattklein123 any ideas?

@Shikugawa

Shikugawa commented May 15, 2021 •

Copy link
Copy Markdown
Member

This is just my sight and may have wrong idea. But also, I think that we will face wasm -> host -> initial metadata copy path will occur per gRPC call in the current implementation. This is just only my concern and we don't have to do that. But should we optimize this? cc @mattklein123

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).

🐱

Caused by: #16502 was synchronize by PiotrSikora.

see: more, trace.

@repokitteh-read-only repokitteh-read-only Bot added the deps Approval required for changes to Envoy's external dependencies label May 15, 2021
@PiotrSikora

Copy link
Copy Markdown
Contributor Author

OK, the C++ SDK was updated to a version with the memory leak fixed, so this should be good to go.

@moderation

Copy link
Copy Markdown
Contributor

/lgtm deps

@repokitteh-read-only repokitteh-read-only Bot removed the deps Approval required for changes to Envoy's external dependencies label May 16, 2021
@PiotrSikora

Copy link
Copy Markdown
Contributor Author

This is just my sight and may have wrong idea. But also, I think that we will face wasm -> host -> initial metadata copy path will occur per gRPC call in the current implementation. This is just only my concern and we don't have to do that. But should we optimize this? cc @mattklein123

I'm not sure I follow. Could you please elaborate on which copies do you think could be avoided?

The reason why std::move() was changed to Http::HeaderMapImpl::copyFrom() is that the old code didn't work.

@Shikugawa

Copy link
Copy Markdown
Member

@PiotrSikora This is just a concept. But host -> initial metadata copies may be avoided by just passing initial_metadata data pointer into gRPC datagram, just like introducing RawAsyncRequestCallbacks::onCreateInitialMetadataPtr. But, we don't have this feature in the current implementation, So this feature may not be needed.

@PiotrSikora

Copy link
Copy Markdown
Contributor Author

@PiotrSikora This is just a concept. But host -> initial metadata copies may be avoided by just passing initial_metadata data pointer into gRPC datagram, just like introducing RawAsyncRequestCallbacks::onCreateInitialMetadataPtr. But, we don't have this feature in the current implementation, So this feature may not be needed.

Initial/trailing gRPC metadata are really HTTP headers/trailers at the HTTP level, so that would only delay the copy, since they need to be merged with the "regular" HTTP headers/trailers at some point anyway.

Also, considering that literally no one is using this feature (since it does't work prior to this PR), I'm going to say that it's a premature optimization, and not something we need to worry about just yet.

@Shikugawa

Copy link
Copy Markdown
Member

Initial/trailing gRPC metadata are really HTTP headers/trailers at the HTTP level, so that would only delay the copy, since they need to be merged with the "regular" HTTP headers/trailers at some point anyway.

Also, considering that literally no one is using this feature (since it does't work prior to this PR), I'm going to say that it's a premature optimization, and not something we need to worry about just yet.

Got it. Thank you!

@mattklein123
mattklein123 merged commit 2d07447 into envoyproxy:main May 27, 2021
leyao-daily pushed a commit to leyao-daily/envoy that referenced this pull request Sep 30, 2021
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.

6 participants