Skip to content

Optimize loader string encoding routine #1913

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

Closed
wants to merge 1 commit into from
Closed

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Jun 17, 2021

For some reason, using an Uint8Array when encoding a string is up to 5x faster. Speedup depends on the browser a bit, but seems to be universal across major engines.

  • I've read the contributing guidelines

@dcodeIO
Copy link
Member Author

dcodeIO commented Jun 17, 2021

Hmm, checked with a larger string now, and it's not anymore. The inconsistency in between browsers is already amazing, but that is strange.


const U16 = new Uint16Array(memory.buffer);
const buf = new Uint8Array(memory.buffer, ptr, size);
Copy link
Member

Choose a reason for hiding this comment

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

Is it really faster with ptr and size in constructor? When I last time checked it was less efficient than original approach

@dcodeIO
Copy link
Member Author

dcodeIO commented Sep 4, 2021

There is quite a bit of uncertainty around how and when this is faster. Would probably be best if browsers would just deal with JS strings better. Closing.

@dcodeIO dcodeIO closed this Sep 4, 2021
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

Successfully merging this pull request may close these issues.

2 participants