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

-threads command line parameter is accepted but has no effect #227

Open
dreamlayers opened this issue Jan 15, 2022 · 2 comments
Open

-threads command line parameter is accepted but has no effect #227

dreamlayers opened this issue Jan 15, 2022 · 2 comments

Comments

@dreamlayers
Copy link
Contributor

Describe the bug
If I run xaos -threads 4, there is no error message, but only a single CPU core is used for calculation

To Reproduce
I'm running Ubuntu 21.10 on x86_64 with a quad core CPU. The same behaviour happens with the xaos 4.2.1-2 package distributed with Ubuntu and https://github.com/xaos-project/XaoS/releases/download/release-4.2.1/xaos_4.2.1-Ubuntu-20.04_amd64.deb. (The download doesn't successfully install due to depending on libicu66 (>= 66.1) but is still usable.)

With no other tasks using a lot of CPU time, run xaos -threads 4, maximize the window, zoom in deeply with iteration limit set to 5000, and monitor CPU usage. Only one CPU core will be fully utilized, with only sporadic little bits of activity on other cores. Clearly only one core is used for calculation.

Expected behavior
When using multiple cores, deep zooms should result in usage of all cores. An old win32 build of XaoS 3.5 which I made with Pthreads-w32 does that, up to around 82% usage in Windows 10. Performance is obviously much better this way when zoomed in deeply.

If usage of multiple cores is not supported by a build of XaoS, there should be some error message to tell the user about that.

Desktop (please complete the following information):
Ubuntu 21.10 with Xorg, Xfce and compton compositor.

Additional context
I know I can probably build XaoS from source with functional multi threading, and will try that later. I know that some things break when using multiple threads.

@dreamlayers
Copy link
Contributor Author

dreamlayers commented Jan 15, 2022

The same behaviour happens in Windows 10 21H2 with https://github.com/xaos-project/XaoS/releases/download/release-4.2.1/xaos-4.2.1.zip

I was thinking XaoS was simply built without thread support and I only need to enable it. But looking at the source code it seems thread support should be present. I also see it depends on a pthread library in Ubuntu, and is distributed with libwinpthread-1.dll in Windows.

Comparing my XaoS 3.5 build with xaos-4.2.1.zip in process explorer, it's clear that 3.5 uses 4 threads for calculation and 4.2.1 only uses 1, even though both were run with -threads 4:xaos_4 2 1_threads_comparison

@dreamlayers
Copy link
Contributor Author

dreamlayers commented Jan 16, 2022

The problem was that command line parameters were being parsed after thread initialization. In pull request #228 I move thread initialization after command line argument parsing.

As a workaround, without making any changes to code, it is possible to use multiple threads by editing the configuration file. In the MainWindow section, add a line like threadCount=4. In Linux the configuration file is located at ~/.config/XaoS Project/XaoS.conf.

The value provided to the -threads argument is supposed to override this configuration file and is also written to the configuration file. Failure to write the supplied value to the configuration file is another symptom of this bug, and it is very easy to observe immediately.

Edit: In Windows thread count is stored in the registry at HKEY_CURRENT_USER\SOFTWARE\XaoS Project\XaoS\MainWindow in DWORD value threadCount. But you don't need to edit that. Simply go into the Calculation menu and select Threads. Changing this will quit XaoS, saying it will restart but not restarting. But next time you start XaoS, it will be using the specified number of threads.

kovzol added a commit that referenced this issue Jan 20, 2022
Move thread initialization after parameter parsing, fixing #227
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant