-
Notifications
You must be signed in to change notification settings - Fork 173
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
TextDecoding pretty slow #447
Comments
I think you might be right. Maybe running some WPT tests would help clarify if there are any missing corner cases. |
I remember we discussed that here #316 and didn't go for it, but I'm happy to revisit. |
Ah, I misread that as only being about the changing of the JS polyfill. |
I think we could have a JS polyfill that uses the native functions to do the heavy lifting and use JS to implement |
I copied (and adjusted) the TextDecoder tests from wpt. |
I will look into this tomorrow, trying to make a C implementation. |
Unfortunately it isn't as straight foward as I expected. There are the following options to implement it:
I've implemented Option 3 in JS. And have some WIP work in Option 1. |
Thanks for being so thorough! As for Option 1, we do already use a fork, quickjs-ng, so we can discuss exposing what's necessary there. |
At this point it looks like having some tjs.encodeUTF8 / decodeUTF8 might the simplest way to go. Would that work for you? This would also simplify some of the internals I think, doing |
I agree, but I don't think I would be quite happy about that solution, since some JS libs just use TextDecoder internally. The qjs internals could just be copied into the Decoder module. And then
|
Fair enough.
Without a copy? IIRC some normalization might be applied, so I'm not sure we'd be able to expose that... I can try.
This sounds reasonable.
Let's leave this as a last resort. If you can propose patches we can discuss them in quickjs-ng, of which I am a member. |
Hello, late to the discussion... Where does the byte stream come from? There is a use case in the engine for this: function source code. We should keep the source code as raw 8-bit data and implement a getter for |
@chqrlie The current implementation of So to be useful such an implementation would need to be:
Correct? I guess I could look into it and create a PR for QuickJS-ng? |
Sorry, I got carried away... The use case for the source code is not pertinent, as we could use I am not familiar with the issue you mention regarding Efficient conversions between raw byte strings and |
I recently wondered why TextDecoding was so slow. Several seconds for 50-100 Kbytes (I am running on a low power embedded system with single core performance comparable to RPI 1).
I saw it currently uses a JS only implementation. I am wondering why, the
JS_NewStringLen
of quickjs already handles utf8 doesn't it?As a workaround I am currently using
Which also just does a
JS_NewString
.The opposite case of Encoding isn't quite as slow, but it seems
JS_ToCString
would also handle this case.Though maybe I am missing something, e.g. some feature TextEncoder/TextDecoder which would not be happening/handled in the quickjs functions.
The text was updated successfully, but these errors were encountered: