-
Notifications
You must be signed in to change notification settings - Fork 233
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
Hunspell 1.4.1 much slower than 1.3.3? #406
Comments
|
Yes, 1.4.1 was refactored to use std::string, but std::string can be much slower, then raw char* buffer, especially if programmer don't understand what he doing. |
|
Possible to rerefactor? |
|
I just noticed that suggestions in Firefox are slower. I checked, and the 1.4 branch has landed in Firefox. One possible reason may be that many fixed length buffers were replaced with vectors and strings. Those things can do a lot of dynamic allocation. The plan from my standpoint is this:
ATM I can not start working on this, I have something else. So I'm just commenting right now :). |
|
FWIW, we've gotten a similar bug filed against Firefox now as well. I can probably get some performance profiles if it helps, but I feel we're kind of stuck in a bad place here because of the number of code quality fixes that also shipped in 1.4. |
|
Profiling indeed can help, but it is questionable how much. Can we regain the speed of 1.3? Can we go faster, or maybe a little faster but not as 1.3. If you do have time, please do them and please document the used tools and the CXXFLAGS you put on make. On the other hand, I already started writing v2.0, a complete rewrite, (see folder src/hunspell2) and I am very certain that if I finish it, it will be faster than any other previous version. |
|
On the Firefox end of things, I bisected this down to 3bb456b. I could see that being a similar problem for the use case in the first comment here. |
|
The patch #450 slightly improves the speed but still the speed is not as great as in 1.3.3. I guess I should bisected between 1.3.3 and 1.4.1 to really get to the real issue. |
|
This is the commit that introduces perfomance regression. c1377e5 is the first bad commit :040000 040000 6316699ade0cb0baf0a5e8ebb8fd71fa3ea65257 22f235493bb9272a4168e71582a331c0d2ac779b M src |
|
Ping @kaboomium see the above comment. The real performance regression is the commit above. Can be solved either with short vector optimization (should get the same behavior as fixed length buffers), or even better, moving the dynamic allocations outside the hot loops. |
|
Hi Dimitrij, The excessive calls to u8_u16() were what cachegrind blamed. With my change, a suggest test runs much faster and doesn't time-out for us any more. Perhaps head of tree is different from 1.4.1. |
|
@kaboomium: Perhaps this issue, the 500%-800% slowdown on checking a directory of HTML files, is unrelated to the Firefox one. I got that result by doing a simple |
|
It is obvious that there are various performance regressions in 1.4. The ones in @Fjan can you tell me steps to reproduce and to measure your results? |
|
@dimztimz I tried creating an easy to reproduce case for this comment but I discovered that the specific way my script works (by piping the files into hunspell one by one) has a large effect on the outcome. Only 70% slower, not the 500% I see in my script. So next I tried piping one by one: About 97% slower, but still nowhere near the slowdown I see in my script and hunspell startup times contaminate the result. So this is the relevant excerpt from the Ruby script I used. It opens a separate thread and invokes hunspell once and pipes the files into it one by one. About 11 times slower... Im pretty confident that the difference is not in the ruby lines I removed from this script as those do not touch hunspell. Perhaps there is some kind of buffering issue related to pipes as it seems to "stutter" every dozen files or so? |
|
I just fixed The problem is that the code is littered with bad use of dynamic allocations, especially with the Fixing the whole codebase is useless, the time taken would be the almost as the rewrite v2. My proposal is to fix only such hot methods (e.g. with lot of loops, quadratic algorithms) that give a noticeable performance drop. And the fixes should be done only by request, I won't start looking into the codebase and fix everything, don't have the time. So far, I'm done with performance patches unless someone points to the exact commit that introduced a regression or points the method that makes trouble in a performance sense. |
kcachegrind reports 1,066,887,723 -> 894,015,631 on echo Hollo | valgrind --tool=callgrind ./src/tools/.libs/hunspell -d nl_NL
|
I guess this is fixed good enough in 1.6.1. Suggestions in 1.6.1 should even be a little faster than in 1.3.3. Detections maybe are slower bot no time to fix this in favor to v2. |
|
I recently tested it again with 1.6.1, it's still 70%+ slower than 1.3.3 for regular spell checking without suggestions. (The large 500% slowdown seen in the script above were mainly due to the slower hunspell filling up the pipe buffer which caused it to stall momentarily.) Not sure if that's considered good enough. |
I just upgraded to the latest hunspell version (through brew) and noticed a slowdown of about 500%-800%, measured on several large directories with HTML pages. The slow down is consistent across different languages. Downgrading fixed the problem. Is there something wrong with the latest version as supplied through brew? How do I go about finding the cause of this?
The text was updated successfully, but these errors were encountered: