-
Notifications
You must be signed in to change notification settings - Fork 812
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
CheckForInvalidUtf8 performance improvement; code cleanup #1582
Conversation
Thank you for the PR. I have measured the performance of the CheckForInvalidUtf8 function before and after the modification using the contents of the following file.
The modified version appears to be just a bit slower.
|
Hello, memcpy in the code for fixed small size (1, 2, 3, 4 bytes as here) doesn't really call actual function - you could just compare asm-files generated for that cpp-file before and after. But I'll run perf-testing again (I was using amd-profiler and have had at least 20% improvement)? I've verified assembly and see unexpected memcpy in one place, hold on - I'll update |
CheckForInvalidUtf8: fixed unexpected memcpy call (intrinsic not used)
I've fixed the issue. Performance comparison for that file on my PC in msecs |
Thanks for the correction. I tried it. I thought it would improve because when I looked at the .asm file, the call to memcpy disappeared from that file, but strangely enough it didn't change much. Note that this PR is faster for files containing only ASCII characters and a little slower for files containing many non-ASCII characters. Example 1. Text file containing only ASCII characters https://raw.githubusercontent.com/WinMerge/winmerge/master/Docs/Manual/EN/Command_line.xml before: 268144[us] Example 2. text file containing many non-ASCII characters https://raw.githubusercontent.com/WinMerge/winmerge/master/Docs/Manual/JP/Command_line.xml before: 344434[us]
|
I have consistent significant perf difference for any file. How do you measure the time? See my example - just update in main.cpp file-path to actual xml-file. For example1: |
As shown in the attached file, I added the code for measurement to the Guess function of codepage_detect.cpp and performed a comparison with WinMerge. Thank you for attaching the utf8_perf.zip. I tried it on my PC and got the same result as yours. When I apply the same compiler optimization as WinMerge as below, only the first result seems to be slow for some reason. I think this is what I saw. It seems to be due to compiler optimization settings. Your PR itself is good, so I'll merge it for now. As for the compiler optimization of the WinMerge project, I don't like the binary size to increase, so I'm using the current settings, but I'll reconsider later. |
Ok, got it. You can’t do any perf testing using VS run command even for release version - too significant impact from VS to metrics. You need to run it in standalone mode from any file manager like Far Manager or just from naked console.
In this particular test that compiler option doesn’t impact anything because no memcpy or other syscall used in the function.
Thanks
PS: enabling Intrinsic optimization shouldn't impact the binary size
|
No description provided.