Better slice management for windows reads#17377
Better slice management for windows reads#17377jtattermusch wants to merge 2 commits intogrpc:masterfrom
Conversation
|
The fix is important enough to be backported to v1.17.x |
|
|
|
|
|
I think it might be better to merge #17378 first and then upmerge to master, rather than merging in both branches? @muxi @nicolasnoble |
|
I thought upmerge is not performed until before next release, so merging both PR right now sounds better by helping reduce the conflicts when we upmerge later. |
|
@muxi I think that's wrong. The upmerge should be performed as soon as possible after stuff gets merged to a release branch (because if there's an important fix in the release branch, we can be 99.9% sure that the same fix will be needed in the master branch as well). I think upmerges should be frequent (which makes them simple) and should not be delayed unnecessarily. I think merging the same PR twice is not a good idea in general (especially if the PR is non-trivial and has more than 1 commit), merging it just once to the release branch and then merging the branch with master makes it easier to track what fixes got merged where. |
| if (info->bytes_transfered != 0 && !tcp->shutting_down) { | ||
| sub = grpc_slice_sub_no_ref(tcp->read_slice, 0, info->bytes_transfered); | ||
| grpc_slice_buffer_add(tcp->read_slices, sub); | ||
| GPR_ASSERT((size_t)info->bytes_transfered <= tcp->read_slices->length); |
There was a problem hiding this comment.
Please use C++-style cast.
Similar through this file.
| grpc_closure* write_cb; | ||
| grpc_slice read_slice; | ||
|
|
||
| /* garbage after the last read */ |
There was a problem hiding this comment.
Not sure why it's called "garbage". But I'm okay with this since it's used elsewhere before this PR.
|
This was upmerged to master as part of #17423 |
Based on #17355.
Fixes #16464.
tcp_windows is much more basic implementation than tcp_posix (which supports resource quota, counters and a few other things missing in tcp_windows).
The scenario from #16464:
To fix, I basically used the same logic that is currently used by tcp_posix.cc -> a "leftover" buffer is kept between reads (buffer_trim is used to split the actual read data and the leftover), so all the slices allocated are fully utilized.
I've verified with an example that the memory consumption per channel is now much more reasonable (reduction from ~500MB to ~35MB for ty example app).
Please refer to tcp_posix when reviewing, as the logic used is almost identical
https://github.com/grpc/grpc/blob/master/src/core/lib/iomgr/tcp_posix.cc