Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AvarianKnight
Copy link
Contributor

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

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

Supersedes PR #2931

@github-actions github-actions bot added ScRT: JS Issues/PRs related to the JavaScript scripting runtime triage Needs a preliminary assessment to determine the urgency and required action labels Dec 19, 2024
Comment on lines +846 to +847
throw new Error('Unknown extension type ' + type)
Copy link
Contributor

@thelindat thelindat Dec 19, 2024

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).

Copy link
Contributor Author

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.

Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ScRT: JS Issues/PRs related to the JavaScript scripting runtime triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants