Python gRPC interceptor that uses Shared Memory#6
Open
aaron-ni wants to merge 4 commits intoni:TestInterceptorsfrom
Open
Python gRPC interceptor that uses Shared Memory#6aaron-ni wants to merge 4 commits intoni:TestInterceptorsfrom
aaron-ni wants to merge 4 commits intoni:TestInterceptorsfrom
Conversation
…t; also add length of response as first 4 bytes of response
Author
|
FYI @ccifra (I'm not able to add you as a reviewer directly) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a functioning gRPC interceptor in Python that uses shared memory (
SidebandStrategy::SHARED_MEMORY). This required a tweak to the C++ code to add a 4-byte (int32_t) length to the beginning of the sideband_memory space (after the 8 bytes for_writeReadyand_readReady).The top of SharedMemoryForwardingInterceptor.py also includes
use_Python_shared_memorythat allows toggling between using Python'smultiprocessing.shared_memory(which is compatible with what we do) and calling intoni_grpc_sideband.dlldirectly. The latter is the default and probably preferred because we probably want to move all the memory offset management to C++ for performance and avoiding duplicating details of memory layout that can change over time.Also, I noticed the C++ code was potentially accessing out-of-bounds memory -
InitClientSidebandDataandInitOwnerSidebandDatawere being created at 4096 bytes, but then the first 8 bytes were used for read and write signals and thesideband_memorypointer was incremented by 8. However subsequent memcpy calls still addressed 4096 bytes, meaning they addressed the 8 bytes after the end of what was allocated viaInit*SidebandData. In testing this isn't likely to come up, but some memory protections might cause a crash, and of course sometimes prototypes become production code.