-
Notifications
You must be signed in to change notification settings - Fork 744
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
OpenMP disable for Windows #1201
Conversation
Using OpenMP on Windows makes it run around 4x slower than without OpenMP, the slowness stands out from Linux and MacOS versions, consider better to disable until the issue is handled.
I don't think this is a general problem with Windows, but only with your
specific machine. Please set the OMP_NUM_THREADS environment variable to 1
to disable it only on your machine.
|
This has also happened to all Windows machines that we tested not only mine, kindly please take a deeper look on it, it's not much reasonable to ask all customers to do additional things unless if it's necessary. |
Since we've moved away from Autotools to build Leptonica and Tesseract, see issue #1163, it should now be possible to build them with Visual Studio. Could you try to do that instead? |
Ok later I'll try with Visual Studio |
I think I understand why it doesn't perform well on Windows. It looks like it's hard coding the num_threads(), whose values are most likely not optimal for any OS, especially not Windows, so removing them should solve this issue without disabling OpenMP: https://github.com/tesseract-ocr/tesseract/search?q=num_threads @stweil What do you think? |
I don't expect that would improve the performance on Windows or any other OS unless when running on a host which does not support at least four threads. But of course you can try removing the hard coded values and test the performance of the resulting code. |
The problem on Windows is that thread scheduling isn't as efficient as on Linux or Mac, so when we start like 100 threads, everything slows down to a crawl. It's recommend to limit the number of threads to the number of available processing cores, which OpenMP does by default anyway, so we don't (usually) need to set num_threads() manually. |
@AramMu I've pushed changes to that effect to your branch. Could you give that a try? |
Ok I'll try the changes |
Hi, I compiled and tried with the change and it crashes when running, can later investigate further or wait |
Could you give me some sample code that crashes like that and that I can try to run here? |
It looks like Tesseract doesn't always work right with more than 4 threads, so I've updated it to force it to always use 4 threads. This way it doesn't crash and performance should be good enough on all platforms, including Windows which should be about as fast as Linux now. Please give it a try! |
Nope, unfortunately, it becomes slower on Windows even with just 2 threads. 🤔 |
With OpenMP, it doesn't seem to get a whole lot faster on Linux either, so we might as well disable it there and on Mac as well. |
Using OpenMP on Windows makes it run around 4x slower than without OpenMP, the slowness stands out from Linux and MacOS versions, consider better to disable until the issue is handled.