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

Use a more performant utf8 decoder algorithm. #3204

Merged
merged 1 commit into from Oct 26, 2019

Conversation

@kitsonk
Copy link
Contributor

kitsonk commented Oct 26, 2019

Fixes #3163

Fixes #3163

Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
Co-authored-by: Qwerasd <qwerasd205@users.noreply.github.com>
@ry
ry approved these changes Oct 26, 2019
Copy link
Collaborator

ry left a comment

LGTM -

Eagerly watching for perf changes to text_decoder on https://deno.land/benchmarks#exec-time

@ry ry merged commit c5fe657 into denoland:master Oct 26, 2019
10 checks passed
10 checks passed
test macOS-10.14
Details
test_std macOS-10.14
Details
test windows-2019
Details
test_std windows-2019
Details
test ubuntu-16.04
Details
test_debug ubuntu-16.04
Details
test_std ubuntu-16.04
Details
bench ubuntu-16.04
Details
lint ubuntu-16.04
Details
license/cla Contributor License Agreement is signed.
Details
@ry

This comment has been minimized.

Copy link
Collaborator

ry commented Oct 26, 2019

Improved execution time from 1.9s to 0.1s. Nice!

sbgvbvq9

12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
12,36,12,12,12,12,12,12,12,12,12,12
][state + type];

This comment has been minimized.

Copy link
@billouboq

billouboq Oct 27, 2019

Can't we gain even more perf by creating those long arrays outside of the function ?

This comment has been minimized.

Copy link
@qwerasd205

qwerasd205 Oct 27, 2019

Contributor

Can't we gain even more perf by creating those long arrays outside of the function ?

Seems like v8 optimizes it. I wrote this decode function, and in my testing I got more performance by inlining the arrays than by having them as consts defined outside of the function.

This comment has been minimized.

Copy link
@kitsonk

kitsonk Oct 28, 2019

Author Contributor

Yeah, V8 optimises things like this, not sure why it is more performant this way, but likely because V8 can understand 100% that there are no mutations to this arrays because they exist in a function that is 100% knowable. In another scope, they might limit the analysis of potential mutations. They aren't like strings and the string table, and where const means const.

This comment has been minimized.

Copy link
@billouboq

billouboq Oct 28, 2019

really good to know thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.