Skip to content
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

On Windows the "Number of threads" setting doesn't seem to work correctly #13

Closed
flozz opened this issue Sep 23, 2021 · 7 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@flozz
Copy link
Owner

flozz commented Sep 23, 2021

On Windows 1.1.0 doesn't seem to use that Setting correctly the whole time

Eg. For each file a thread is created on "Optimize" start, not when it actually processes the actual file. Making the machine behave oddly under the load, since if you have 1000 files to optimize it will create 1000 threads each using memory and resources, and each using 100% of one core for setting up. The system will starve at one point making even input erroneous (trying to write letters will input ljk!@@21';s/.//, so the letters and random punctuation signs). After the threads are created THEN it will start to use only X CPU threads as setup, if the machine still works that is :(

/LE: reworded for clarity

Originally posted by @licaon-kter in #11 (comment)

@flozz flozz added the bug Something isn't working label Sep 23, 2021
@flozz
Copy link
Owner Author

flozz commented Sep 23, 2021

I will try to reproduce this as soon as I can, thank you for the report :)

@licaon-kter
Copy link

Windows 10 21H1

Also, now I see that the threads are not killed after processing is done, but only on app close.

@flozz
Copy link
Owner Author

flozz commented Sep 27, 2021

Ok, I was able to reproduce on my Windows VM:

Capture d’écran de 2021-09-27 12-49-49

I do not saw the problem before because I often tested with only one image on Windows to check that the optimization works...

I will first try to build a Linux version using Nuitka to see if I can also reproduce it here. I need to know if the problem is caused by Windows, by Nuitka or by a combination of both Windows + Nuitka

@flozz
Copy link
Owner Author

flozz commented Sep 27, 2021

I was able to reproduce on Linux:

Capture d’écran de 2021-09-27 13-37-56

But the main difference is that the spawn of the processes consume no CPU so there is no "OS freeze".

Anyway, nice catch, I will work on that this week 👍

@flozz flozz self-assigned this Sep 27, 2021
@flozz
Copy link
Owner Author

flozz commented Sep 28, 2021

I found why there were so much processes. The created process are:

  • The main process
  • Optimization processes (× "Number of thread" setting), cleaned after optimization
  • Manager processes (× number of images), never cleaned

I was misusing the multiprocessing.Manager() so one process is created to monitor each tasks and nothing was cleaned at the end.

I am fixing this so we will have:

  • The main process
  • Optimization process (× "Number of thread" setting), cleaned after optimization
  • 1 manager process, cleaned after optimization

I still do not know why it is so heavy to create processes on Windows but it should reduce the issues. I am building a test version to check it works on my VM :)

@flozz
Copy link
Owner Author

flozz commented Sep 28, 2021

Ok it seems to work fine for me. If you want to try, the build is available here:

I still have a CPU peak at process creation but it is way better than before.

@flozz flozz closed this as completed in 8fe70b6 Sep 28, 2021
@flozz
Copy link
Owner Author

flozz commented Sep 28, 2021

Fixed in 8fe70b6

It will be released soon. Thank you again for the report! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants