Commit 4014ecb
buffer: speed up swap16/32, add swap64
* Speed up buffer.swap16 and swap32 by using builtins. Up to ~6x gain.
Drop transition point between JS and C++ implementations accordingly.
Amount of performance improvement not only depends on buffer size but
also memory alignment.
* Fix tests: C++ impl tests were testing 0-filled buffers so were
always passing.
* Add similar buffer.swap64 method.
* Make buffer-swap benchmark mirror JS impl.
doc/api/buffer.markdown has an entry of "added: REPLACEME" that should
be changed to the correct release number before tagged.
Because node is currently using a very old version of cpplint.py it
doesn't know that std::swap() has moved from <algorithm> to <utility> in
c++11. So until cpplint.py is updated simply NOLINT the line.
Technically it should be NOLINT(build/include_what_you_use), but that
puts the line over 80 characters causing another lint error.
PR-URL: #7157
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Backport-URL: #75461 parent 63d361b commit 4014ecbCopy full SHA for 4014ecb
File tree
Expand file treeCollapse file tree
5 files changed
+351
-111
lines changedOpen diff view settings
Filter options
- benchmark/buffers
- doc/api
- lib
- src
- test/parallel
Expand file treeCollapse file tree
5 files changed
+351
-111
lines changedOpen diff view settings
Collapse file
benchmark/buffers/buffer-swap.js
Copy file name to clipboard+52-23Lines changed: 52 additions & 23 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | 1 | |
2 | 2 | |
3 | 3 | |
| 4 | + |
4 | 5 | |
5 | 6 | |
6 | | - |
7 | | - |
8 | | - |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
9 | 11 | |
10 | 12 | |
11 | 13 | |
12 | 14 | |
13 | 15 | |
14 | | - |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
15 | 27 | |
16 | 28 | |
17 | 29 | |
18 | 30 | |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
| 31 | + |
| 32 | + |
23 | 33 | |
24 | 34 | |
25 | 35 | |
26 | 36 | |
27 | 37 | |
28 | | - |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
29 | 49 | |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
37 | 55 | |
38 | 56 | |
39 | 57 | |
40 | 58 | |
41 | | - |
| 59 | + |
| 60 | + |
42 | 61 | |
43 | 62 | |
44 | 63 | |
45 | | - |
| 64 | + |
46 | 65 | |
47 | 66 | |
48 | | - |
49 | | - |
50 | | - |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
51 | 74 | |
52 | 75 | |
53 | 76 | |
54 | 77 | |
55 | 78 | |
56 | 79 | |
57 | | - |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
58 | 87 | |
59 | | - |
| 88 | + |
60 | 89 | |
61 | 90 | |
Collapse file
+28-4Lines changed: 28 additions & 4 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1461 | 1461 | |
1462 | 1462 | |
1463 | 1463 | |
1464 | | - |
| 1464 | + |
1465 | 1465 | |
1466 | 1466 | |
1467 | | - |
| 1467 | + |
1468 | 1468 | |
1469 | 1469 | |
1470 | 1470 | |
| ||
1482 | 1482 | |
1483 | 1483 | |
1484 | 1484 | |
1485 | | - |
| 1485 | + |
1486 | 1486 | |
1487 | 1487 | |
1488 | | - |
| 1488 | + |
1489 | 1489 | |
1490 | 1490 | |
| 1491 | + |
| 1492 | + |
| 1493 | + |
| 1494 | + |
| 1495 | + |
| 1496 | + |
| 1497 | + |
| 1498 | + |
| 1499 | + |
| 1500 | + |
| 1501 | + |
| 1502 | + |
| 1503 | + |
| 1504 | + |
| 1505 | + |
| 1506 | + |
| 1507 | + |
| 1508 | + |
| 1509 | + |
| 1510 | + |
| 1511 | + |
| 1512 | + |
| 1513 | + |
| 1514 | + |
1491 | 1515 | |
1492 | 1516 | |
1493 | 1517 | |
|
Collapse file
+64-41Lines changed: 64 additions & 41 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | | - |
48 | | - |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | | - |
59 | | - |
60 | | - |
61 | | - |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | | - |
67 | | - |
68 | 27 | |
69 | 28 | |
70 | 29 | |
| ||
1320 | 1279 | |
1321 | 1280 | |
1322 | 1281 | |
| 1282 | + |
| 1283 | + |
| 1284 | + |
| 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 | + |
| 1310 | + |
| 1311 | + |
| 1312 | + |
| 1313 | + |
| 1314 | + |
| 1315 | + |
| 1316 | + |
| 1317 | + |
| 1318 | + |
| 1319 | + |
| 1320 | + |
| 1321 | + |
| 1322 | + |
| 1323 | + |
| 1324 | + |
| 1325 | + |
| 1326 | + |
| 1327 | + |
| 1328 | + |
| 1329 | + |
| 1330 | + |
| 1331 | + |
| 1332 | + |
| 1333 | + |
| 1334 | + |
| 1335 | + |
| 1336 | + |
| 1337 | + |
| 1338 | + |
| 1339 | + |
| 1340 | + |
| 1341 | + |
| 1342 | + |
| 1343 | + |
| 1344 | + |
| 1345 | + |
0 commit comments