Replacing msgpack with msgpack-light?
stanleyxu2005 opened this issue · 1 comments
stanleyxu2005 commented
According to the benchmark sheet, the pure js implementation is even faster than node-gyp built version.
Futhermore, it would be great to specify the message encoding protocol by user choice. If the RPC is only on the same machine, performance difference of JSON or msgpack might not be huge. I read some notes that Nodejs has pretty much improved the performance of encoding JSON.
Benchmarks
A benchmark tool lib/benchmark.js
is available to compare encoding/decoding speed
(operation per second) with other MessagePack modules.
It counts operations of 1KB JSON document in 10 seconds.
$ npm install msgpack msgpack-js msgpack-js-v5 msgpack-unpack msgpack5 notepack
$ npm run benchmark 10
operation | op | ms | op/s |
---|---|---|---|
buf = Buffer(JSON.stringify(obj)); | 1055200 | 10000 | 105520 |
obj = JSON.parse(buf); | 863800 | 10000 | 86380 |
buf = require("msgpack-lite").encode(obj); | 969100 | 10000 | 96910 |
obj = require("msgpack-lite").decode(buf); | 600300 | 10000 | 60030 |
buf = require("msgpack").pack(obj); | 503500 | 10001 | 50344 |
obj = require("msgpack").unpack(buf); | 560200 | 10001 | 56014 |
bombela commented
nice work, I will find some time this week to read all the details and look at your PR.