-
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
Use Array.join to build up strings in readPostScriptTable(). #5074
Use Array.join to build up strings in readPostScriptTable(). #5074
Conversation
i wonder if you could just put the bytes into the array and then invoke bytesToString(buf) ? |
I haven't looked at this particular case, but in general we may need to be careful when using that kind of pattern. (See the recent regression fixed by PR #5069.) |
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/2849d2e44f5e4c5/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/0c287cf78c4bfa6/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/2849d2e44f5e4c5/output.txt Total script time: 21.21 mins
|
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/0c287cf78c4bfa6/output.txt Total script time: 23.46 mins
Image differences available at: http://107.21.233.14:8877/0c287cf78c4bfa6/reftest-analyzer.html#web=eq.log |
The test failure appears to be due to a miniscule difference. Not sure why that happens; this should be functionally identical to the old code.
You mean, do |
This was (likely) caused by the recent Firefox update, since the exact same test failure can be observed in #3891 (comment). I've generated new reference images for Linux, so just to make absolutely sure I'll re-trigger the test here once that completes. |
/botio-linux test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/c55e45fa44d7622/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/c55e45fa44d7622/output.txt Total script time: 23.19 mins
|
@nnethercote I think Fabian might be thinking of collecting the byte codes of
At least in the case of #5069, bytesToString did not cause the regression, see my comment there. |
In Firefox, single-byte ASCII strings are statically provided (and thus shareable) and so don't take up any additional memory.
That's probably true. I'll update the patch accordingly. |
I just realized that using bytesToString() is wrong here -- it assumes the input is a typed array, not a vanilla array! The difference only manifests if the length is greater than 8192, whereupon it calls subarray(). I'll repost the original patch that uses fromCharCode+join. Also, I did some microbenchmarking. On short arrays, bytesToString() is about 20% slower than fromCharCode+join. They are about the same for arrays of length 20, and once the length gets to 100s or 1000s bytesToString() is about 2x faster. So the potential win isn't clear-cut. |
This avoids about 5 MiB of string allocations on one test case.
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/232a48198b72f57/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/1d07354d42a3364/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/1d07354d42a3364/output.txt Total script time: 21.38 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/232a48198b72f57/output.txt Total script time: 23.29 mins
|
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/f5bf540bd157a58/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/f5bf540bd157a58/output.txt Total script time: 0.74 mins Published
|
Use Array.join to build up strings in readPostScriptTable().
Nice work, thanks! |
@nnethercote I can confirm your test, it is slower indeed. Sorry for the extra work. |
This avoids about 5 MiB of string allocations on one test case.