perf: avoid unnecessary operation for improve performance#698
Merged
mcollina merged 7 commits intofastify:masterfrom Apr 19, 2024
Merged
perf: avoid unnecessary operation for improve performance#698mcollina merged 7 commits intofastify:masterfrom
mcollina merged 7 commits intofastify:masterfrom
Conversation
ivan-tymoshenko
requested changes
Mar 19, 2024
Contributor
|
Why closed? |
Contributor
Author
|
@Uzlopak I thought you don't want to merge anymore :D |
Member
|
I want to check the V8 bytecode to see if a switch typeof uses string comparison or not, |
Contributor
|
The problem is, that we have always maendering interests, so it is kind of hard to always get things done in a timely manner. So just dont think we are not interested, we are just busy, like you ;). |
Member
|
Seems like I cannot get the const a = (b) => {
if (typeof b === "function") {
return b;
}
};[generated bytecode for function: a (0x328e80b5b9f1 <SharedFunctionInfo a>)]
Bytecode length: 11
Parameter count 2
Register count 0
Frame size 0
Bytecode age: 0
3174 S> 0x328e80b5ccae @ 0 : 0b 03 Ldar a0
0x328e80b5ccb0 @ 2 : 20 06 TestTypeOf #6
0x328e80b5ccb2 @ 4 : 99 05 JumpIfFalse [5] (0x328e80b5ccb7 @ 9)
3209 S> 0x328e80b5ccb4 @ 6 : 0b 03 Ldar a0
3218 S> 0x328e80b5ccb6 @ 8 : a9 Return
0x328e80b5ccb7 @ 9 : 0e LdaUndefined
3223 S> 0x328e80b5ccb8 @ 10 : a9 Return
Constant pool (size = 0)
Handler Table (size = 0)
Source Position Table (size = 12)
0x328e80b5ccc1 <ByteArray[12]>const a = (b) => {
switch (typeof b) {
case "function":
return b;
}
};[generated bytecode for function: a (0x1ded2941b9f1 <SharedFunctionInfo a>)]
Bytecode length: 18
Parameter count 2
Register count 1
Frame size 8
Bytecode age: 0
3174 S> 0x1ded2941ccc6 @ 0 : 0b 03 Ldar a0
0x1ded2941ccc8 @ 2 : 56 TypeOf
0x1ded2941ccc9 @ 3 : c4 Star0
0x1ded2941ccca @ 4 : 13 00 LdaConstant [0]
0x1ded2941cccc @ 6 : 6c fa 00 TestEqualStrict r0, [0]
0x1ded2941cccf @ 9 : 98 04 JumpIfTrue [4] (0x1ded2941ccd3 @ 13)
0x1ded2941ccd1 @ 11 : 8a 05 Jump [5] (0x1ded2941ccd6 @ 16)
3221 S> 0x1ded2941ccd3 @ 13 : 0b 03 Ldar a0
3230 S> 0x1ded2941ccd5 @ 15 : a9 Return
0x1ded2941ccd6 @ 16 : 0e LdaUndefined
3235 S> 0x1ded2941ccd7 @ 17 : a9 Return
Constant pool (size = 1)
0x1ded2941cc79: [FixedArray] in OldSpace
- map: 0x0624cc240211 <Map(FIXED_ARRAY_TYPE)>
- length: 1
0: 0x0624cc246351 <String[8]: #function>
Handler Table (size = 0)
Source Position Table (size = 12)
0x1ded2941ccd9 <ByteArray[12]> |
gurgunday
requested changes
Apr 11, 2024
Signed-off-by: francesco <francesco.bagnoli.69@gmail.com>
Signed-off-by: francesco <francesco.bagnoli.69@gmail.com>
Contributor
Author
|
@gurgunday done MASTER |
gurgunday
approved these changes
Apr 11, 2024
Member
|
@ivan-tymoshenko ptal |
Contributor
Author
|
@mcollina seem all "ok" for the merge! |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR has some microptimization for reduce the overhead of function call that can replaced with more faster inline control
Side note: the code become a bit ugly but seems more faster
PS. someone can run benchmark on github (master vs PR)? I have noticed my PC is a bit unstable on benchmark results
Master
PR
Checklist
npm run testandnpm run benchmarkand the Code of conduct