Commit b43c056
Use writeChain instead of writev in Transport::write to have zerocopy support
Summary:
Switch both Transport::write() overloads (ByteRange and IOBufQueue) to
use writeChain instead of writev/write. This enables the zero-copy
(MSG_ZEROCOPY) code path in AsyncSocket::writeChainImpl, which checks
zeroCopyEnabled_, isManaged(), and the enable threshold before adding
MSG_ZEROCOPY to individual writes.
The old writev/write path bypassed writeChainImpl entirely, so zero-copy
decisions were never evaluated even when zero copy was enabled on the
socket.
For the IOBufQueue overload, this also avoids an intermediate
std::vector<iovec> allocation from getIov().
For the ByteRange overload, wrapBuffer creates an unmanaged IOBuf so
isManaged() returns false, meaning MSG_ZEROCOPY won't be added (which is
correct since ByteRange data may point at stack memory).
Reviewed By: dmm-fb
Differential Revision: D96616945
fbshipit-source-id: 5a53269db20b8f3a0ae53d71530a2ee879a0de4e1 parent 6b45386 commit b43c056
2 files changed
Lines changed: 54 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
| 123 | + | |
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| |||
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | | - | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
271 | 322 | | |
272 | 323 | | |
273 | 324 | | |
| |||
0 commit comments