Skip to content

Update fastify.listen() method invocations - #5395

Merged
wemeetagain merged 2 commits into
unstablefrom
nflaig/update-fastify-listen
Apr 21, 2023
Merged

Update fastify.listen() method invocations#5395
wemeetagain merged 2 commits into
unstablefrom
nflaig/update-fastify-listen

Conversation

@nflaig

@nflaig nflaig commented Apr 21, 2023

Copy link
Copy Markdown
Member

Motivation

With update to Fastify v4 in #5369, the following invocations are valid as per migration guide v4:

fastify.listen()
fastify.listen({ port: 8000 })
fastify.listen({ port: 8000 }, (err) => { if (err) throw err })

Other invocations will show a deprecation warning

@deprecated — Variadic listen method is deprecated. Please use .listen(optionsObject) instead. The variadic signature will be removed in fastify@5

and create deprecation log

(node:6766) [FSTDEP011] FastifyDeprecation: Variadic listen method is deprecated. Please use ".listen(optionsObject)" instead. The variadic signature will be removed in `fastify@5`.

See Fastify v4 GA for further details on what changed with Fastify v4.

Description

Updates fastify.listen() method invocations, pass options object instead of multiple separate parameters.

@nflaig
nflaig requested a review from a team as a code owner April 21, 2023 11:54
@github-actions

github-actions Bot commented Apr 21, 2023

Copy link
Copy Markdown
Contributor

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: de743fc Previous: fb192bf Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 988.52 us/op 721.78 us/op 1.37
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 48.474 us/op 48.913 us/op 0.99
BLS verify - blst-native 1.2242 ms/op 1.2447 ms/op 0.98
BLS verifyMultipleSignatures 3 - blst-native 2.5059 ms/op 2.5650 ms/op 0.98
BLS verifyMultipleSignatures 8 - blst-native 5.3873 ms/op 5.5203 ms/op 0.98
BLS verifyMultipleSignatures 32 - blst-native 19.563 ms/op 19.837 ms/op 0.99
BLS aggregatePubkeys 32 - blst-native 26.182 us/op 26.935 us/op 0.97
BLS aggregatePubkeys 128 - blst-native 101.96 us/op 103.38 us/op 0.99
getAttestationsForBlock 57.949 ms/op 64.471 ms/op 0.90
isKnown best case - 1 super set check 257.00 ns/op 279.00 ns/op 0.92
isKnown normal case - 2 super set checks 252.00 ns/op 275.00 ns/op 0.92
isKnown worse case - 16 super set checks 248.00 ns/op 273.00 ns/op 0.91
CheckpointStateCache - add get delete 5.5360 us/op 6.2390 us/op 0.89
validate gossip signedAggregateAndProof - struct 2.7980 ms/op 2.8864 ms/op 0.97
validate gossip attestation - struct 1.3122 ms/op 1.3822 ms/op 0.95
pickEth1Vote - no votes 1.2324 ms/op 1.4212 ms/op 0.87
pickEth1Vote - max votes 10.493 ms/op 10.615 ms/op 0.99
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.8334 ms/op 9.4887 ms/op 0.93
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 15.871 ms/op 17.723 ms/op 0.90
pickEth1Vote - Eth1Data fastSerialize value x2048 642.04 us/op 804.53 us/op 0.80
pickEth1Vote - Eth1Data fastSerialize tree x2048 8.7694 ms/op 9.3120 ms/op 0.94
bytes32 toHexString 487.00 ns/op 952.00 ns/op 0.51
bytes32 Buffer.toString(hex) 350.00 ns/op 461.00 ns/op 0.76
bytes32 Buffer.toString(hex) from Uint8Array 558.00 ns/op 697.00 ns/op 0.80
bytes32 Buffer.toString(hex) + 0x 363.00 ns/op 476.00 ns/op 0.76
Object access 1 prop 0.16100 ns/op 0.24000 ns/op 0.67
Map access 1 prop 0.16100 ns/op 0.17700 ns/op 0.91
Object get x1000 6.6950 ns/op 8.3250 ns/op 0.80
Map get x1000 0.62200 ns/op 0.73300 ns/op 0.85
Object set x1000 56.884 ns/op 86.286 ns/op 0.66
Map set x1000 44.538 ns/op 64.053 ns/op 0.70
Return object 10000 times 0.23050 ns/op 0.30460 ns/op 0.76
Throw Error 10000 times 4.1352 us/op 4.7827 us/op 0.86
fastMsgIdFn sha256 / 200 bytes 3.3890 us/op 3.8580 us/op 0.88
fastMsgIdFn h32 xxhash / 200 bytes 302.00 ns/op 358.00 ns/op 0.84
fastMsgIdFn h64 xxhash / 200 bytes 448.00 ns/op 546.00 ns/op 0.82
fastMsgIdFn sha256 / 1000 bytes 11.975 us/op 12.280 us/op 0.98
fastMsgIdFn h32 xxhash / 1000 bytes 465.00 ns/op 515.00 ns/op 0.90
fastMsgIdFn h64 xxhash / 1000 bytes 532.00 ns/op 601.00 ns/op 0.89
fastMsgIdFn sha256 / 10000 bytes 105.66 us/op 108.73 us/op 0.97
fastMsgIdFn h32 xxhash / 10000 bytes 2.0090 us/op 2.1120 us/op 0.95
fastMsgIdFn h64 xxhash / 10000 bytes 1.4990 us/op 1.5380 us/op 0.97
enrSubnets - fastDeserialize 64 bits 1.3300 us/op 1.9040 us/op 0.70
enrSubnets - ssz BitVector 64 bits 543.00 ns/op 696.00 ns/op 0.78
enrSubnets - fastDeserialize 4 bits 185.00 ns/op 243.00 ns/op 0.76
enrSubnets - ssz BitVector 4 bits 568.00 ns/op 707.00 ns/op 0.80
prioritizePeers score -10:0 att 32-0.1 sync 2-0 115.91 us/op 129.23 us/op 0.90
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 147.93 us/op 181.94 us/op 0.81
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 175.03 us/op 239.46 us/op 0.73
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 321.62 us/op 374.13 us/op 0.86
prioritizePeers score 0:0 att 64-1 sync 4-1 370.62 us/op 435.76 us/op 0.85
array of 16000 items push then shift 1.6200 us/op 1.7801 us/op 0.91
LinkedList of 16000 items push then shift 8.8100 ns/op 10.026 ns/op 0.88
array of 16000 items push then pop 87.293 ns/op 114.63 ns/op 0.76
LinkedList of 16000 items push then pop 8.5280 ns/op 9.5000 ns/op 0.90
array of 24000 items push then shift 2.3946 us/op 2.4945 us/op 0.96
LinkedList of 24000 items push then shift 9.0610 ns/op 10.233 ns/op 0.89
array of 24000 items push then pop 87.361 ns/op 92.094 ns/op 0.95
LinkedList of 24000 items push then pop 8.9400 ns/op 10.441 ns/op 0.86
intersect bitArray bitLen 8 13.411 ns/op 32.375 ns/op 0.41
intersect array and set length 8 93.041 ns/op 102.72 ns/op 0.91
intersect bitArray bitLen 128 45.840 ns/op 70.377 ns/op 0.65
intersect array and set length 128 1.1673 us/op 1.3294 us/op 0.88
Buffer.concat 32 items 2.8030 us/op 3.2410 us/op 0.86
Uint8Array.set 32 items 2.2090 us/op 2.7410 us/op 0.81
pass gossip attestations to forkchoice per slot 3.0477 ms/op 3.4681 ms/op 0.88
computeDeltas 4.6423 ms/op 3.4194 ms/op 1.36
computeProposerBoostScoreFromBalances 1.9283 ms/op 1.8748 ms/op 1.03
altair processAttestation - 250000 vs - 7PWei normalcase 2.7988 ms/op 3.4719 ms/op 0.81
altair processAttestation - 250000 vs - 7PWei worstcase 5.2129 ms/op 4.7791 ms/op 1.09
altair processAttestation - setStatus - 1/6 committees join 151.34 us/op 150.73 us/op 1.00
altair processAttestation - setStatus - 1/3 committees join 289.66 us/op 284.46 us/op 1.02
altair processAttestation - setStatus - 1/2 committees join 393.84 us/op 394.67 us/op 1.00
altair processAttestation - setStatus - 2/3 committees join 479.58 us/op 478.49 us/op 1.00
altair processAttestation - setStatus - 4/5 committees join 705.37 us/op 687.19 us/op 1.03
altair processAttestation - setStatus - 100% committees join 917.44 us/op 786.03 us/op 1.17
altair processBlock - 250000 vs - 7PWei normalcase 22.356 ms/op 19.866 ms/op 1.13
altair processBlock - 250000 vs - 7PWei normalcase hashState 33.901 ms/op 29.611 ms/op 1.14
altair processBlock - 250000 vs - 7PWei worstcase 65.746 ms/op 57.298 ms/op 1.15
altair processBlock - 250000 vs - 7PWei worstcase hashState 81.559 ms/op 78.047 ms/op 1.04
phase0 processBlock - 250000 vs - 7PWei normalcase 3.3296 ms/op 2.4653 ms/op 1.35
phase0 processBlock - 250000 vs - 7PWei worstcase 32.577 ms/op 31.087 ms/op 1.05
altair processEth1Data - 250000 vs - 7PWei normalcase 796.10 us/op 643.19 us/op 1.24
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 13.352 us/op 10.827 us/op 1.23
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 37.661 us/op 32.762 us/op 1.15
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 17.496 us/op 15.159 us/op 1.15
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 13.687 us/op 13.689 us/op 1.00
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 123.99 us/op 113.98 us/op 1.09
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 753.67 us/op 778.15 us/op 0.97
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 934.65 us/op 1.0975 ms/op 0.85
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 1.2440 ms/op 941.57 us/op 1.32
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 3.5046 ms/op 3.1660 ms/op 1.11
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 2.3385 ms/op 1.7494 ms/op 1.34
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 6.1968 ms/op 4.4430 ms/op 1.39
Tree 40 250000 create 468.49 ms/op 582.73 ms/op 0.80
Tree 40 250000 get(125000) 206.20 ns/op 203.38 ns/op 1.01
Tree 40 250000 set(125000) 1.3002 us/op 1.3292 us/op 0.98
Tree 40 250000 toArray() 23.475 ms/op 29.882 ms/op 0.79
Tree 40 250000 iterate all - toArray() + loop 25.169 ms/op 28.727 ms/op 0.88
Tree 40 250000 iterate all - get(i) 79.825 ms/op 80.826 ms/op 0.99
MutableVector 250000 create 12.939 ms/op 11.643 ms/op 1.11
MutableVector 250000 get(125000) 6.7260 ns/op 7.1360 ns/op 0.94
MutableVector 250000 set(125000) 345.54 ns/op 521.70 ns/op 0.66
MutableVector 250000 toArray() 4.3045 ms/op 4.4363 ms/op 0.97
MutableVector 250000 iterate all - toArray() + loop 4.9749 ms/op 4.8298 ms/op 1.03
MutableVector 250000 iterate all - get(i) 1.5594 ms/op 1.6995 ms/op 0.92
Array 250000 create 3.7660 ms/op 4.3538 ms/op 0.86
Array 250000 clone - spread 1.2703 ms/op 1.4609 ms/op 0.87
Array 250000 get(125000) 0.59000 ns/op 0.91300 ns/op 0.65
Array 250000 set(125000) 0.67400 ns/op 1.1750 ns/op 0.57
Array 250000 iterate all - loop 88.236 us/op 113.18 us/op 0.78
effectiveBalanceIncrements clone Uint8Array 300000 42.262 us/op 69.333 us/op 0.61
effectiveBalanceIncrements clone MutableVector 300000 353.00 ns/op 490.00 ns/op 0.72
effectiveBalanceIncrements rw all Uint8Array 300000 174.48 us/op 186.87 us/op 0.93
effectiveBalanceIncrements rw all MutableVector 300000 89.810 ms/op 122.13 ms/op 0.74
phase0 afterProcessEpoch - 250000 vs - 7PWei 118.81 ms/op 130.81 ms/op 0.91
phase0 beforeProcessEpoch - 250000 vs - 7PWei 44.166 ms/op 47.385 ms/op 0.93
altair processEpoch - mainnet_e81889 326.44 ms/op 335.21 ms/op 0.97
mainnet_e81889 - altair beforeProcessEpoch 64.855 ms/op 73.165 ms/op 0.89
mainnet_e81889 - altair processJustificationAndFinalization 17.870 us/op 24.808 us/op 0.72
mainnet_e81889 - altair processInactivityUpdates 6.3816 ms/op 6.7402 ms/op 0.95
mainnet_e81889 - altair processRewardsAndPenalties 47.615 ms/op 57.333 ms/op 0.83
mainnet_e81889 - altair processRegistryUpdates 2.7500 us/op 3.0200 us/op 0.91
mainnet_e81889 - altair processSlashings 496.00 ns/op 614.00 ns/op 0.81
mainnet_e81889 - altair processEth1DataReset 460.00 ns/op 1.1780 us/op 0.39
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2488 ms/op 1.3751 ms/op 0.91
mainnet_e81889 - altair processSlashingsReset 4.1430 us/op 6.8620 us/op 0.60
mainnet_e81889 - altair processRandaoMixesReset 7.1230 us/op 9.4580 us/op 0.75
mainnet_e81889 - altair processHistoricalRootsUpdate 945.00 ns/op 1.3070 us/op 0.72
mainnet_e81889 - altair processParticipationFlagUpdates 3.1100 us/op 4.6160 us/op 0.67
mainnet_e81889 - altair processSyncCommitteeUpdates 895.00 ns/op 1.0110 us/op 0.89
mainnet_e81889 - altair afterProcessEpoch 128.77 ms/op 132.70 ms/op 0.97
phase0 processEpoch - mainnet_e58758 433.87 ms/op 405.91 ms/op 1.07
mainnet_e58758 - phase0 beforeProcessEpoch 135.35 ms/op 166.15 ms/op 0.81
mainnet_e58758 - phase0 processJustificationAndFinalization 23.563 us/op 22.853 us/op 1.03
mainnet_e58758 - phase0 processRewardsAndPenalties 42.858 ms/op 68.801 ms/op 0.62
mainnet_e58758 - phase0 processRegistryUpdates 8.9680 us/op 11.140 us/op 0.81
mainnet_e58758 - phase0 processSlashings 652.00 ns/op 652.00 ns/op 1.00
mainnet_e58758 - phase0 processEth1DataReset 770.00 ns/op 652.00 ns/op 1.18
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.1052 ms/op 1.2026 ms/op 0.92
mainnet_e58758 - phase0 processSlashingsReset 4.3230 us/op 7.6120 us/op 0.57
mainnet_e58758 - phase0 processRandaoMixesReset 7.5440 us/op 5.1890 us/op 1.45
mainnet_e58758 - phase0 processHistoricalRootsUpdate 570.00 ns/op 599.00 ns/op 0.95
mainnet_e58758 - phase0 processParticipationRecordUpdates 8.1370 us/op 4.4810 us/op 1.82
mainnet_e58758 - phase0 afterProcessEpoch 99.822 ms/op 101.59 ms/op 0.98
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.3360 ms/op 1.2813 ms/op 1.04
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.5668 ms/op 1.4880 ms/op 1.05
altair processInactivityUpdates - 250000 normalcase 19.344 ms/op 26.792 ms/op 0.72
altair processInactivityUpdates - 250000 worstcase 24.824 ms/op 29.661 ms/op 0.84
phase0 processRegistryUpdates - 250000 normalcase 9.5470 us/op 11.689 us/op 0.82
phase0 processRegistryUpdates - 250000 badcase_full_deposits 359.00 us/op 286.11 us/op 1.25
phase0 processRegistryUpdates - 250000 worstcase 0.5 133.97 ms/op 142.73 ms/op 0.94
altair processRewardsAndPenalties - 250000 normalcase 64.557 ms/op 71.428 ms/op 0.90
altair processRewardsAndPenalties - 250000 worstcase 66.936 ms/op 81.181 ms/op 0.82
phase0 getAttestationDeltas - 250000 normalcase 7.0265 ms/op 8.7636 ms/op 0.80
phase0 getAttestationDeltas - 250000 worstcase 7.2608 ms/op 8.6102 ms/op 0.84
phase0 processSlashings - 250000 worstcase 3.5939 ms/op 3.8264 ms/op 0.94
altair processSyncCommitteeUpdates - 250000 179.00 ms/op 194.82 ms/op 0.92
BeaconState.hashTreeRoot - No change 313.00 ns/op 294.00 ns/op 1.06
BeaconState.hashTreeRoot - 1 full validator 62.005 us/op 56.637 us/op 1.09
BeaconState.hashTreeRoot - 32 full validator 711.07 us/op 621.98 us/op 1.14
BeaconState.hashTreeRoot - 512 full validator 8.2422 ms/op 5.8540 ms/op 1.41
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 85.398 us/op 68.699 us/op 1.24
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.2781 ms/op 949.64 us/op 1.35
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 13.155 ms/op 13.139 ms/op 1.00
BeaconState.hashTreeRoot - 1 balances 54.394 us/op 54.735 us/op 0.99
BeaconState.hashTreeRoot - 32 balances 445.41 us/op 469.46 us/op 0.95
BeaconState.hashTreeRoot - 512 balances 4.8571 ms/op 4.6164 ms/op 1.05
BeaconState.hashTreeRoot - 250000 balances 79.458 ms/op 74.579 ms/op 1.07
aggregationBits - 2048 els - zipIndexesInBitList 17.400 us/op 18.266 us/op 0.95
regular array get 100000 times 44.357 us/op 35.059 us/op 1.27
wrappedArray get 100000 times 33.267 us/op 39.886 us/op 0.83
arrayWithProxy get 100000 times 15.693 ms/op 15.968 ms/op 0.98
ssz.Root.equals 606.00 ns/op 601.00 ns/op 1.01
byteArrayEquals 580.00 ns/op 600.00 ns/op 0.97
shuffle list - 16384 els 6.9653 ms/op 7.1355 ms/op 0.98
shuffle list - 250000 els 103.93 ms/op 104.35 ms/op 1.00
processSlot - 1 slots 9.1070 us/op 9.3710 us/op 0.97
processSlot - 32 slots 1.5097 ms/op 1.3898 ms/op 1.09
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 42.825 ms/op 38.503 ms/op 1.11
getCommitteeAssignments - req 1 vs - 250000 vc 3.1940 ms/op 2.9863 ms/op 1.07
getCommitteeAssignments - req 100 vs - 250000 vc 4.4191 ms/op 4.3075 ms/op 1.03
getCommitteeAssignments - req 1000 vs - 250000 vc 4.6048 ms/op 4.7006 ms/op 0.98
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.8400 ns/op 5.0700 ns/op 1.15
state getBlockRootAtSlot - 250000 vs - 7PWei 766.87 ns/op 1.1022 us/op 0.70
computeProposers - vc 250000 11.337 ms/op 11.485 ms/op 0.99
computeEpochShuffling - vc 250000 104.73 ms/op 105.82 ms/op 0.99
getNextSyncCommittee - vc 250000 200.34 ms/op 195.01 ms/op 1.03
computeSigningRoot for AttestationData 15.161 us/op 15.162 us/op 1.00
hash AttestationData serialized data then Buffer.toString(base64) 3.0784 us/op 2.5687 us/op 1.20
toHexString serialized data 2.2104 us/op 1.8395 us/op 1.20
Buffer.toString(base64) 377.44 ns/op 386.75 ns/op 0.98

by benchmarkbot/action


// To parse our ApiError -> statusCode
server.setErrorHandler((err, req, res) => {
if ((err as FastifyError).validation) {

@nflaig nflaig Apr 21, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinda unrelated change but might as well clean this up, err is now properly typed

@wemeetagain
wemeetagain merged commit 10d2839 into unstable Apr 21, 2023
@wemeetagain
wemeetagain deleted the nflaig/update-fastify-listen branch April 21, 2023 13:23
@wemeetagain

Copy link
Copy Markdown
Member

🎉 This PR is included in v1.8.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants