Thanks to visit codestin.com
Credit goes to github.com

Skip to content

compiler/natives/src/strconv: Use js string conversion utilities to improve performance #1101

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

Merged
merged 4 commits into from
Jan 4, 2022

Conversation

flimzy
Copy link
Member

@flimzy flimzy commented Jan 3, 2022

Rebase of #786

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@flimzy flimzy requested a review from nevkontakte January 3, 2022 15:54
@flimzy
Copy link
Member Author

flimzy commented Jan 3, 2022

It occurs to me that once #798 is merged, this functionality can probably be extended to the ParseInt function, as well, to use the JS parser when appropriate, then fall back to the Go version for other bitsizes.

Copy link
Member

@nevkontakte nevkontakte left a comment

Choose a reason for hiding this comment

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

I would be curious to see a before/after benchmark. Intuitively, I expect this will be faster, but I'm curious by how much.

@flimzy
Copy link
Member Author

flimzy commented Jan 4, 2022

I would be curious to see a before/after benchmark. Intuitively, I expect this will be faster, but I'm curious by how much.

They exist in the original issue (#786 (comment)) but I haven't re-run them on the latest version of GopherJS before and after this patch. I'll see if I have time to do that.

@flimzy
Copy link
Member Author

flimzy commented Jan 4, 2022

Before:

goos: linux
goarch: js
BenchmarkAtoi/Pos/7bit           7361962               153.6 ns/op
BenchmarkAtoi/Pos/26bit          7100590               168.3 ns/op
BenchmarkAtoi/Pos/31bit          1951214               617.6 ns/op
BenchmarkAtoi/Neg/7bit           5607476               210.1 ns/op
BenchmarkAtoi/Neg/26bit          5286343               226.2 ns/op
BenchmarkAtoi/Neg/31bit          1646088               719.9 ns/op
PASS
ok      strconv 8.920s

After:

goos: linux
goarch: js
BenchmarkAtoi/Pos/7bit          17040207                69.95 ns/op
BenchmarkAtoi/Pos/26bit          8163265               145.9 ns/op
BenchmarkAtoi/Pos/31bit          7741934               156.0 ns/op
BenchmarkAtoi/Neg/7bit          11881188               106.3 ns/op
BenchmarkAtoi/Neg/26bit          7894736               148.5 ns/op
BenchmarkAtoi/Neg/31bit          6557376               182.2 ns/op
PASS
ok      strconv 9.373s

🎉

@github-actions

This comment has been minimized.

@github-actions
Copy link

github-actions bot commented Jan 4, 2022

Reference app: jQuery TodoMVC (acf500a6c32a83d8c4582d967b09a65febf0e120)

BRANCH ORIGINAL MINIFIED COMPRESSED (GZIP)
Pull request (native_strconv) 3,199,787 bytes 2,080,050 bytes 394,052 bytes
Target branch (master) 0.01% decrease (-239 bytes) 0.00% increase (86 bytes) 0.02% increase (88 bytes)

#outputSize

@flimzy flimzy merged commit 15ed2e8 into master Jan 4, 2022
@flimzy flimzy deleted the native_strconv branch January 4, 2022 16:39
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.

3 participants