-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(v8/scripting): swap from msgpack-lite to msgpackr #3018
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Linden <[email protected]>
throw new Error('Unknown extension type ' + type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw this will break compatibility for any type that has no extension. For example, unpacking a vector2 from Lua results in
return {
"buffer": {
"type": "Buffer",
"data": number[] // i.e. [11,205,143,63,183,230,7,64]
},
"type": 20
}
I will be submitting a "breaking" PR for vectors anyway to actually support them, but might cause some complaints (e.g. where those buffers are manually handled).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably just handle the conversions here anyways, since sending vectors to/from scrts is currently very hacky and I doubt may people do it currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an array containing 100 objects and another with 1000 objects. Performed 1000 iterations.
msgpack-lite
Running benchmark for packing...
Pack - Min: 0.0568 ms, Max: 1.1691 ms, Avg: 0.080365 ms
Running benchmark for unpacking...
Unpack - Min: 0.0482 ms, Max: 1.1444 ms, Avg: 0.061173 ms
Running benchmark for packing...
Pack - Min: 5.2618 ms, Max: 13.8522 ms, Avg: 5.99034 ms
Running benchmark for unpacking...
Unpack - Min: 5.0637 ms, Max: 20.6582 ms, Avg: 5.366889 ms
msgpackr
Running benchmark for packing...
Pack - Min: 0.0185 ms, Max: 4.2132 ms, Avg: 0.03549 ms
Running benchmark for unpacking...
Unpack - Min: 0.035 ms, Max: 1.9161 ms, Avg: 0.059167 ms
Running benchmark for packing...
Pack - Min: 1.8215 ms, Max: 10.3579 ms, Avg: 1.995244 ms
Running benchmark for unpacking...
Unpack - Min: 3.4534 ms, Max: 18.5718 ms, Avg: 3.717805 ms
When testing this caused crashing for RedM due to how it's session manager works, I'll look into this when I have the time |
Goal of this PR
Swap JS to msgpackr to allow serializing classes & other js builtin objects (i.e.
Map
,Set
,Error
, etc) and also increase performance.How is this PR achieving the goal
Swap out the custom version of msgpack-lite to use msgpackr
This PR applies to the following area(s)
ScRT: JS
Successfully tested on
Game builds: N/A
Platforms: Windows, Linux
Checklist
Fixes issues
Supersedes PR #2931