[SERVER-75722] Avoid memory copies on gRPC's read path Created: 05/Apr/23 Updated: 06/Apr/23 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Amirsaman Memaripour | Assignee: | Backlog - Service Architecture |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | perf-improvement | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Service Arch
|
||||||||
| Participants: | |||||||||
| Description |
|
We use a custom memory layout for our SharedBuffer objects, which reserve a few bytes at the beginning of each contiguous memory region for metadata (e.g., the capacity of the buffer). As a result, we cannot have SharedBuffer own the memory allocated by gRPC to read from a server stream. This requires an additional heap allocation and memory copy on the critical path. We can avoid the copy by either changing the layout of the byte-array sent through gRPC streams, or modify SharedBuffer to accepts raw buffers. |