-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Clean up duplicate string conversion functions #4512
Clean up duplicate string conversion functions #4512
Conversation
Another question: I kept
|
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/624613df320321e/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/fc679b2539ad6f8/output.txt |
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/624613df320321e/output.txt Total script time: 24.81 mins
Image differences available at: http://107.21.233.14:8877/624613df320321e/reftest-analyzer.html#web=eq.log |
Something seems to be really wrong with Chrome on the Linux bot, let's investigate if this was caused by a Chrome update. |
I'm afraid its my bad. Let me check this. |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/fc679b2539ad6f8/output.txt Total script time: 35.98 mins
|
Google Chrome throws "maximum call stack size exceeded" warnings, but only in the worker thread. In my tests with Chrome, the maximum byte array length in Which brings us again to the question that I posed in the initial comment: what is the maximum safe size of the argument array? |
Make it 8192 |
} | ||
var strBuf = []; | ||
for (var i = 0; i < length; ++i) { | ||
strBuf.push(String.fromCharCode(bytes[i])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for typed arrays you can do it in blocks by MAX_ARGUMENT_COUNT items. How many bytesToString calls are made with Array as argument (excluding simulated typed arrays)?
grep shows 9 lines of variable size arrays, but its hard to tell the characteristics of the input array from lines like font_loader.jsL294 Because the whole patch did not affect overall performance, I refrained from doing any optimizations (e.g. chunking) which would complicate things. |
Not sure if it will complicate things though. However it shall stop arrays from from growing to the huge sizes -- it is already above MAX_ARGUMENT_COUNT as typed array and we are adding non-typed array of strings. |
No, it did not, once I assured that only typed arrays are passed to bytesToString. |
@fkaelberer Could you rebase this? |
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/d2aa3fdf9bdcc81/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.21.233.14:8877/b6ce9360c1e8647/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/d2aa3fdf9bdcc81/output.txt Total script time: 2.45 mins
Image differences available at: http://107.22.172.223:8877/d2aa3fdf9bdcc81/reftest-analyzer.html#web=eq.log |
/botio-windows test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/1b02b3da7627630/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/b6ce9360c1e8647/output.txt Total script time: 25.84 mins
|
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/1b02b3da7627630/output.txt Total script time: 22.29 mins
|
Clean up duplicate string conversion functions
Thank you for the patch |
This PR does the following:
fonts.js->Font.string32
andfonts_loader.js->FontLoader.string32
toUtils.js->string32
fonts.js->Font.stringToArray
andfonts.js->CFFCompiler.stringToArray
toUtils.js->stringToArray
fonts.js->Font.arrayToString
and useUtils.js->bytesToString
insteadString.fromCharCode(a, b)
instead ofString.fromCharCode(a) + String.fromCharCode(b)
Utils.js->bytesToString
, useString.fromCharCode.apply(null, bytes)
instead of pushing chars to an array if "possible" (because its >10x faster for longer arrays).If the bytes array is too long, a "too many arguments" warning will appear. Question: What is the maximum number of function arguments that is accepted by all browsers? FF/chrome/ie7 accept 500000/120000/120000 arguments, so I felt that a maximum of 65000 should be safe.