This repository was archived by the owner on Sep 30, 2024. It is now read-only.
[Backport 5.1] grpc: symbols: spread LocalCodeIntel response symbols across multiple messages#55292
Merged
Merged
Conversation
ggilmore
approved these changes
Jul 25, 2023
Contributor
BolajiOlajide
approved these changes
Jul 26, 2023
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 PR changes the LocalCodeIntel symbols gRPC method to return a stream of chunks of symbols, rather than the entire result set in a single message.
gRPC has default limits on how large individual messages can be. This is because gRPC is a message-based framework, which means that messages have to be entirely loaded into memory for both sending and receiving. As such, large allocations can negatively impact server performance and stability. The go-grpc default limit is 4MB.
The original LocalCodeIntel RPC implementation (both gRPC and REST) returned the entire set of returned symbols in one message. For certain repositories / files, this message can contains thousands of symbols, which can add up to hundreds of MB or even gigabytes of memory.
This PR adjusts the server-side implementation of LocalCodeIntel to chunk up its full result set into smaller chunks (so that each individual gRPC message is smaller). It does this in a few steps.
chunkutility I found in the Gitaly project that can intelligently send a group of protobuf messages in smaller chunks (all ~ 1MB): https://github.com/sourcegraph/sourcegraph/pull/55242/commits/59ba6d0aba0c98a82d46b7a2f24127bbf97181ccchunkutility in the Symbols service to divide up the list of returned symbols into ~ 1MB batches and sending it across the result stream: https://github.com/sourcegraph/sourcegraph/pull/55242/commits/77fc77ee88e638c31c3ba8cba2b9f50f225503c5Note that this PR doesn't "fix" the real issues with the underlying application itself. Notably:
However, we still aren't any worse off than we were before (the REST implementation still has the same memory allocation problems and sends the results in one giant JSON message). This PR does "work around" the gRPC-specific message size complaints while providing a building block to improve this in the future.
cc @sourcegraph/code-intel ^
Test plan
Backport 2a6c569 from grpc: symbols: spread LocalCodeIntel response symbols across multiple messages #55242