-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Right-size the map
array in PartialEvaluator_readToUnicode
#6476
Right-size the map
array in PartialEvaluator_readToUnicode
#6476
Conversation
We can avoid a lot of intermediate resizings, by directly allocating the required number of elements for the `map` array.
/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/2a689655046a25f/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/0d7a59a03a7d9e4/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/2a689655046a25f/output.txt Total script time: 19.15 mins
|
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/0d7a59a03a7d9e4/output.txt Total script time: 19.50 mins
|
Looks good to me (took me however a moment to realize 0x10000 is 0xffff +1 so the array can hold the 0 - 0xffff elements :-)) |
@brendandahl Could you review/merge this one? |
It's been awhile since I looked at the state of things in spider monkey, but it use to not matter if you passed in the array length, a dictionary would still be created, which performs the same as []. To make it faster you have to fill in all slots to make it a dense array. There are trade offs though, it takes time to make it dense, so its really only worth it if the array accessed a lot. |
I know that @nnethercote has done something similar previously, see e.g. PRs #5096 and #5191 which served as inspiration for this patch, since it should reduce the amount of memory allocations required. Although in both those cases all the |
Yeah, so it looks like the length is used now if you follow the creation from https://dxr.mozilla.org/mozilla-central/source/js/src/jsarray.cpp?from=js%3A%3AArrayConstructor#3182-3226 One thing I'm not sure about though is if it's worth it, the pdf.js code has a comment about the cmap possibly being sparse so the map would also be sparse. Any idea if they usually are sparse? |
When debugging/fixing font issues, I recall having seen |
…icode-cmap-length Right-size the `map` array in PartialEvaluator_readToUnicode
We can avoid a lot of intermediate resizings, by directly allocating the required number of elements for the
map
array.