mcollina / msgpack5

A msgpack v5 implementation for node.js, with extension points / msgpack.org[Node]
MIT License
492 stars 76 forks source link

Move most functions out of closure #101

Closed thephoenixofthevoid closed 3 years ago

thephoenixofthevoid commented 3 years ago

Recreated pull request I didn't figure out the problem, just nuked everything and built again

These changes improved performance. According to bench:

$ git checkout master
$ node benchmarks/encodedecode.js 
time 432
decode/s 231481.4814814815

$ git checkout upstream/master 
$ node benchmarks/encodedecode.js 
time 486
decode/s 205761.316872428

That is 10% improvement.

mcollina commented 3 years ago

awesome work! Is this good to land?

thephoenixofthevoid commented 3 years ago

Second test:

$ git checkout upstream/master
$ node benchmarks/parseshortmap.js
time 1914
decode/s 522466.039707419

$ git checkout decoder-refactoring-2021
$ node benchmarks/parseshortmap.js
time 1813
decode/s 551571.9801434088

I am thinking about more changes, but we may land this one, because it's self-contained. For example, we may use options as a context (by assigning decodingTypes and decode on it), and pass options object to each function.

thephoenixofthevoid commented 3 years ago

It looks like tests do not cover very well decoding arrays. It missed the bug with object inside of array (that this commit introduced due to trivial mistake). Now will be fix.

mcollina commented 3 years ago

It looks like tests do not cover very well decoding arrays. It missed the bug with object inside of array (that this commit introduced due to trivial mistake). Now will be fix.

Can you add a test for this regression?

mcollina commented 3 years ago

Is it good to go?

thephoenixofthevoid commented 3 years ago

It's ready to merge, I double-checked everything today, nothing should go wrong (the regression was trivial and quite surprising to see all tests green).

PS: looks like we need to invest some time into tests to make it more reliable --- maybe, structurize them a bit?

mcollina commented 3 years ago

I don't have much time to spend on this lib, but it you want to invest some time to improve it I'll be happy to add you to the repo.