-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Faster UTF-32 encoding #59232
Comments
In pair to bpo-14625 here is a patch than speed up UTF-32 encoding in several times. In addition, it fixes an unsafe check of an integer overflow. Here are the results of benchmarking. See benchmark tools in https://bitbucket.org/storchaka/cpython-stuff repository. On 32-bit Linux, AMD Athlon 64 X2 4600+ @ 2.4GHz: Py2.7 Py3.2 Py3.3 patched 541 (+1032%) 541 (+1032%) 844 (+626%) 6125 encode utf-32le 'A'*10000 541 (+880%) 543 (+876%) 844 (+528%) 5300 encode utf-32be 'A'*10000 |
On 32-bit Linux, Intel Atom N570 @ 1.66GHz: Py2.7 Py3.2 Py3.3 patched 214 (+718%) 215 (+714%) 363 (+382%) 1750 encode utf-32le 'A'*10000 214 (+556%) 214 (+556%) 363 (+287%) 1404 encode utf-32be 'A'*10000 |
Patch updated to 3.4. Is anyone interested in 7x speedup of UTF-32 encoder? |
From http://kmike.ru/python-data-structures/ under heading DATrie "Python wrapper uses utf_32_le codec internally; this codec is currently slow and it is the bottleneck for datrie. There is a ticket with a patch in the CPython bug tracker (http://bugs.python.org/issue15027) that should make this codec fast, so there is a hope datrie will become faster with future Pythons." |
Here is updated patch, synchronized with trunk. UTF-32 encoder now checks surrogates and therefore speedup is less (only up to 5 times). But this compensates regression in 3.4. On 32-bit Linux, Intel Atom N570 @ 1.66GHz: Py3.3 Py3.4 patched 531 (+245%) 489 (+274%) 1831 encode utf-32le 'A'*10000 544 (+166%) 494 (+193%) 1448 encode utf-32be 'A'*10000 |
one comment to address on the review, otherwise after addressing that I believe this is ready to go in for 3.4. |
New changeset b72c5573c5e7 by Serhiy Storchaka in branch 'default': |
Thank you Gregory for your review. |
Isn't this a new feature? |
Sorry if I have missed. Should I revert changeset b72c5573c5e7? This patch doesn't introduce new functions and doesn't change behavior. Without this patch the UTF-32 encoder is up to 2.5x slower in 3.4 than in 3.3 (due to bpo-12892). |
Would you describe it as a "bug fix" or a "security fix"? If it's neither of those things, then you need special permission to add it during beta. And given that this patch has the possibility of causing bugs, I'd prefer to not accept it for 3.4. Please revert it for now. If you think it should go in to 3.4, you may ask on python-dev that it be considered and take a poll. (Note that the poll is not binding on me; this is still solely my decision. However if there was an uproar of support for your patch, that would certainly cause me to reconsider.) |
New changeset 1e345924f7ea by Serhiy Storchaka in branch 'default': |
BreamoreBoy: why did you remove Arfrever from this issue? |
Noisy lists members are sorted by alphabetical order: since Arfrever comes just before BreamoreBoy, I assume his fingers tripped ;-) |
As this appears to be a performance improvement only can it go into 3.5 or do we wait for 3.x? |
Can I commit the patch now Larry? |
We're still in alpha, so it's fine for 3.5 right now. The cutoff for new features for 3.5 will be May 23. |
New changeset 80cf7723c4cf by Serhiy Storchaka in branch 'default': |
And that's not all... |
In Objects/stringlib/codecs.h in 2 comments U+DC800 should be changed into U+D800 (from definition of Py_UNICODE_IS_SURROGATE) or U+DC80 (from result of b"\x80".decode(errors="surrogateescape")). |
Thank you Arfrever. That was copy-pasted old typo. Fixed in 3d5bf6174c4b and bc6ed8360312. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: