Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

fix: slow buffer serialization in firefox #35

Merged
merged 2 commits into from
Sep 17, 2018

Conversation

alanshaw
Copy link
Contributor

@alanshaw alanshaw commented Sep 17, 2018

It turns out Array.from(buffer) is way slower than JSON.stringify(buffer).

EDIT: Possibly not true, perhaps it's sending a large array over postMessage is way slower than sending a large string. Anyway, something like that. Either way this PR makes it fast in both Firefox and Chrome which is what we want!

I'm seeing numbers like 905ms in Firefox and 455ms in Chrome for the test case from ipfs/ipfs-companion#485

Alan Shaw added 2 commits September 17, 2018 21:54
It turns out `Array.from(buffer)` is way slower than `JSON.stringify(buffer)`.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
Copy link
Contributor

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that does the trick. I got < 500ms with this fix.

@alanshaw alanshaw merged commit d893e31 into master Sep 17, 2018
@alanshaw alanshaw deleted the fix/slow-buffer-serialization branch September 17, 2018 21:24
lidel added a commit to ipfs/ipfs-companion that referenced this pull request Sep 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants