- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitc4ab7da
committed
Avoid needless large memcpys in libpq socket writing
Until now, when calling pq_putmessage to write new data to a libpqsocket, all writes are copied into a buffer and that buffer gets flushedwhen full to avoid having to perform small writes to the socket.There are cases where we must write large amounts of data to the socket,sometimes larger than the size of the buffer. In this case, it'swasteful to memcpy this data into the buffer and flush it out, instead,we can send it directly from the memory location that the data is alreadystored in.Here we adjust internal_putbytes() so that after having just flushed thebuffer to the socket, if the remaining bytes to send is as big or biggerthan the buffer size, we just send directly rather than needlesslycopying into the PqSendBuffer buffer first.Examples of operations that write large amounts of data in one messageare; outputting large tuples with SELECT or COPY TO STDOUT andpg_basebackup.Author: Melih MutluReviewed-by: Heikki LinnakangasReviewed-by: Jelte Fennema-NioReviewed-by: David RowleyReviewed-by: Ranier VilelaReviewed-by: Andres FreundDiscussion:https://postgr.es/m/CAGPVpCR15nosj0f6xe-c2h477zFR88q12e6WjEoEZc8ZYkTh3Q@mail.gmail.com1 parenta97bbe1 commitc4ab7da
1 file changed
+53
-21
lines changedLines changed: 53 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
120 | 120 |
| |
121 | 121 |
| |
122 | 122 |
| |
123 |
| - | |
124 |
| - | |
| 123 | + | |
| 124 | + | |
125 | 125 |
| |
126 | 126 |
| |
127 | 127 |
| |
| |||
143 | 143 |
| |
144 | 144 |
| |
145 | 145 |
| |
146 |
| - | |
147 |
| - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
148 | 150 |
| |
149 | 151 |
| |
150 | 152 |
| |
| |||
1268 | 1270 |
| |
1269 | 1271 |
| |
1270 | 1272 |
| |
1271 |
| - | |
| 1273 | + | |
1272 | 1274 |
| |
1273 | 1275 |
| |
1274 |
| - | |
1275 |
| - | |
1276 | 1276 |
| |
1277 | 1277 |
| |
1278 | 1278 |
| |
| |||
1282 | 1282 |
| |
1283 | 1283 |
| |
1284 | 1284 |
| |
1285 |
| - | |
1286 |
| - | |
1287 |
| - | |
1288 |
| - | |
1289 |
| - | |
1290 |
| - | |
1291 |
| - | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
1292 | 1310 |
| |
| 1311 | + | |
1293 | 1312 |
| |
1294 | 1313 |
| |
1295 | 1314 |
| |
| |||
1321 | 1340 |
| |
1322 | 1341 |
| |
1323 | 1342 |
| |
1324 |
| - | |
| 1343 | + | |
1325 | 1344 |
| |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
1326 | 1358 |
| |
1327 | 1359 |
| |
1328 | 1360 |
| |
1329 |
| - | |
1330 |
| - | |
| 1361 | + | |
| 1362 | + | |
1331 | 1363 |
| |
1332 | 1364 |
| |
1333 | 1365 |
| |
1334 | 1366 |
| |
1335 | 1367 |
| |
1336 |
| - | |
| 1368 | + | |
1337 | 1369 |
| |
1338 | 1370 |
| |
1339 | 1371 |
| |
| |||
1373 | 1405 |
| |
1374 | 1406 |
| |
1375 | 1407 |
| |
1376 |
| - | |
| 1408 | + | |
1377 | 1409 |
| |
1378 | 1410 |
| |
1379 | 1411 |
| |
1380 | 1412 |
| |
1381 | 1413 |
| |
1382 | 1414 |
| |
1383 | 1415 |
| |
1384 |
| - | |
| 1416 | + | |
1385 | 1417 |
| |
1386 | 1418 |
| |
1387 |
| - | |
| 1419 | + | |
1388 | 1420 |
| |
1389 | 1421 |
| |
1390 | 1422 |
| |
|
0 commit comments
Comments
(0)