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

bin_buffer perf improvement? #69

Closed
omarstreak opened this issue Apr 21, 2017 · 1 comment
Closed

bin_buffer perf improvement? #69

omarstreak opened this issue Apr 21, 2017 · 1 comment

Comments

@omarstreak
Copy link

Can you explain the reason for the Bufferish.from call and what it is doing?

We recently started using msgpack-lite in our project and in doing some performance profiling found that a large amount of time is spent read-format.js:bin_buffer. More investigation shows that on line 95 buf is a Uint8Array, and the result of Bufferish.from(buf) returns a Uint8array with the exact same data. What is the reason for the call to Buffer.from(buf)?

Given a Uint8Array Bufferish.from ends up calling its own slice. So what ends up happening is you get a redundant slice called and for lots of data that is expensive.

I made a quick hack and in our project just returned buf without doing Bufferish.from and everything worked fine. However, I think tried to modify the msgpack-lite library myself and that caused tests to fail. That obviously meant I was missing something.

My guess is that for a large number of cases the Bufferis.from call does not need to be called and would save a lot of processing time.

@omarstreak
Copy link
Author

never mind. I read the documentation better and found the binarraybuffer code option. Works great now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant