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

perf(ext/ffi): Revert UTF-8 validity check from getCString #17741

Merged
merged 1 commit into from
Feb 12, 2023

Conversation

aapoalas
Copy link
Collaborator

@aapoalas aapoalas commented Feb 11, 2023

I previously added a UTF-8 validity check to the getCString FFI API thinking that it was essentially a fluke or at least poorly thought out to pass in possibly invalid UTF-8 into the NewFromUtf8 V8 String API.

It seems this is not the case. I've added tests to rusty_v8 (denoland/rusty_v8#1190) to check that the API handles invalid UTF-8 sequences and also added similar or equal tests to FFI tests here locally. The local tests verify that not only does the API work, it also produces the equivalent result as using TextDecoder would.

The performance difference in our bench case is about 5-15 nanoseconds out of roughly 150ns. 2 ** 28 byte string shows a similar difference, going from 115 ms to 104 ms.

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

LGTM!

@aapoalas aapoalas merged commit 5a83af4 into denoland:main Feb 12, 2023
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.

None yet

2 participants