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

Android: BOINC doesn't use all cores, and doesn't use the right cores #2594

Closed
davidpanderson opened this issue Jul 11, 2018 · 6 comments
Closed

Comments

@davidpanderson
Copy link
Contributor

From Jacob:

I think it boils down to this, for me, on my Pixel 2:

If BOINC starts via "Autostart": The process and tasks start running as "bg" (limited to 2 little cores)
If BOINC starts via user launching BOINC: The process and tasks start running as "fg" (limited to all 4 little cores and 2 of the 4 big cores)
If BOINC is ever suspended while the UI is dismissed, then the BOINC process transitions to "bg" (limited to 2 little cores), and the tasks will later start running as "bg"... and the only way to get it all back to "fg" is to use Settings > Apps > BOINC > "Force Stop" and restart BOINC.

Does that accurately describe the behavior of the program right now?
Furthermore, does that accurately describe the behavior that we want? :)

Personally, based on ability to use CPUs, I think we'd want to use "fg" (while keeping 'nice'). I know I'm going to go out of my way to do that, at least, but BOINC should do that by default in my opinion.

Useful commands to watch the behavior:
top -o PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,PCY,CPU,CMDLINE
top -o PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,PCY,CPU,NAME


... but then when BOINC is suspended and the BOINC app is closed, later when BOINC is opened, the tasks get created as background again. Hmm, I'm still missing understanding something I think.

This has something to do with ... the parent BOINC process running as "fg" versus "bg", and I think it relates to it being spawned from the UI or UI being closed when it is spawned. I'm still missing something.


BAD / SLOW / RESTRICTING:
When BOINC has "Autostart" turned ON, and the phone is restarted

  • The child threads run using "bg" (Background) scheduling policy
  • This places them all on CPUs 0 and 1
  • This leaves CPUs 2-7 all idle.
  • This leaves my "BIG" CPU cores idle.
    walleye:/ $ ps -A -o PID,TTY,TIME,CMD,CPU,PCY,PPID -P 5928
    PID TTY TIME CMD CPU PCY PPID
    6732 ? 00:00:46 rosetta_android 0 bg 5928
    6996 ? 00:00:40 rosetta_android 1 bg 5928
    7037 ? 00:00:45 rosetta_android 1 bg 5928
    7253 ? 00:00:44 rosetta_android 0 bg 5928
    7379 ? 00:00:39 rosetta_android 1 bg 5928
    7380 ? 00:00:04 data_collect_v5 1 bg 5928
    7480 ? 00:00:38 rosetta_android 0 bg 5928
    7485 ? 00:00:38 rosetta_android 0 bg 5928
    7514 ? 00:00:38 rosetta_android 1 bg 5928

GOOD / USING ALL CPUS:
When BOINC has "Autostart" turned OFF, and the phone is restarted, and the user manually starts BOINC:

  • The child threads run using "fg" (Foreground) scheduling policy
  • This places them originally across ALL CPU CORES, with sometimes having them double-up.
  • This keeps my "BIG" CPU Cores at full frequency, and mostly loaded.
    127|walleye:/ $ ps -A -o PID,TTY,TIME,CMD,CPU,PCY,PPID -P 3975
    PID TTY TIME CMD CPU PCY PPID
    4724 ? 00:00:11 rosetta_android 2 fg 3975
    5191 ? 00:00:10 rosetta_android 7 fg 3975
    5384 ? 00:00:13 rosetta_android 1 fg 3975
    5561 ? 00:00:07 rosetta_android 7 fg 3975
    5730 ? 00:00:07 rosetta_android 6 fg 3975
    5731 ? 00:00:00 data_collect_v5 6 fg 3975
    5893 ? 00:00:11 rosetta_android 3 fg 3975
    6128 ? 00:00:09 rosetta_android 0 fg 3975
    6341 ? 00:00:06 rosetta_android 6 fg 3975

Instructions:

Window 1:
top
Window 2 (replace the BOINC_PARENT_PROCESS_ID with the BOINC parent process ID):
ps -A -o PID,TTY,TIME,CMD,CPU,PCY,PPID -P [BOINC_PARENT_PROCESS_ID]


I made a little progress, I think. Basically, I'm able to connect to the device from windows, using adb (Android Desktop Bridge), and then do a "top" or "top -H" to see some stuff. Instructions at bottom. What I found, though, I did not like.

Basically, look at the "nice" values below, and also the "%CPU" values for the tasks.
They make it look like, the BOINC threads are ACTUALLY limited to just 2 of my 8 CPUs - not even 4! Regardless of being set to 2, 4, or 8.

This leads me to believe that I should set BOINC to 2 on this phone, as that's all the OS will end up using. Do you agree?

Here's what my Pixel 2 looks like, when running:

8 BOINC tasks:
800%cpu 17%user 194%nice 13%sys 565%idle 4%iow 5%irq 2%sirq 0%host
�[7m PID USER PR NI VIRT RES SHR S[%CPU] %MEM TIME+ ARGS �[0m
18541 u0_a163 39 19 347M 185M 5.7M R 24.3 5.0 0:32.64 rosetta_android_4.10_arm-android-linux-gnu...
18245 u0_a163 39 19 379M 221M 3.0M R 24.3 6.0 1:07.79 rosetta_android_4.10_arm-android-linux-gnu...
18232 u0_a163 39 19 373M 187M 6.0M R 24.3 5.1 1:06.30 rosetta_android_4.10_arm-android-linux-gnu...
17999 u0_a163 39 19 244M 86M 1.2M R 24.3 2.3 1:32.07 rosetta_android_4.10_arm-android-linux-gnu...
17995 u0_a163 39 19 244M 86M 1.3M R 24.3 2.3 1:33.66 rosetta_android_4.10_arm-android-linux-gnu...
17986 u0_a163 39 19 244M 83M 1.6M R 24.3 2.2 1:25.48 rosetta_android_4.10_arm-android-linux-gnu...
18882 u0_a163 39 19 157M 32M 20M R 24.0 0.8 0:02.55 rosetta_android_4.10_arm-android-linux-gnu...
17988 u0_a163 39 19 244M 86M 1.3M R 24.0 2.3 1:24.47 rosetta_android_4.10_arm-android-linux-gnu...

4 BOINC tasks:
800%cpu 13%user 188%nice 24%sys 565%idle 2%iow 4%irq 4%sirq 0%host
�[7m PID USER PR NI VIRT RES SHR S[%CPU] %MEM TIME+ ARGS �[0m
19642 u0_a163 39 19 157M 32M 20M R 65.0 0.8 0:04.72 rosetta_android_4.10_arm-android-linux-gnu...
19567 u0_a163 39 19 194M 68M 22M R 55.6 1.8 0:23.21 rosetta_android_4.10_arm-android-linux-gnu...
19636 u0_a163 39 19 160M 37M 21M R 37.0 1.0 0:06.40 rosetta_android_4.10_arm-android-linux-gnu...
19639 u0_a163 39 19 160M 37M 21M R 36.0 1.0 0:06.38 rosetta_android_4.10_arm-android-linux-gnu...

2 BOINC tasks:
800%cpu 23%user 195%nice 16%sys 558%idle 2%iow 5%irq 2%sirq 0%host
�[7m PID USER PR NI VIRT RES SHR S[%CPU] %MEM TIME+ ARGS �[0m
19639 u0_a163 39 19 377M 229M 10M R 96.0 6.2 0:55.71 rosetta_android_4.10_arm-android-linux-gnu...
19636 u0_a163 39 19 380M 231M 9.2M R 94.6 6.3 0:55.49 rosetta_android_4.10_arm-android-linux-gnu...

1 BOINC task:
800%cpu 51%user 121%nice 37%sys 582%idle 3%iow 5%irq 1%sirq 0%host
�[7m PID USER PR NI VIRT RES SHR S[%CPU] %MEM TIME+ ARGS �[0m
19639 u0_a163 39 19 385M 235M 10M R 100 6.4 1:21.36 rosetta_android_4.10_arm-android-linux-gnu...

Instructions:
I personally used this link, which a software "SystemPanel2" recommended to use to get its app able to read additional info on Nougat and Oreo.
http://sp.nextapp.com/
Then I used this link to learn a little about top:
http://adbshell.com/commands/adb-shell-top
...
So I:

  • Downloaded that zip and extracted it
  • Connected my phone
  • Opened Command Prompt (Admin) on Windows 10, and used "cd" to change directory to the folder of the extracted contents
  • Ran "adb shell"
  • Ran "top"
  • Used Ctrl+C to exit top
  • Ran "exit" to exit the shell
@Ageless93
Copy link
Contributor

We had a whole discussion about this on the BOINC forums, where I for the moment last posted: "I still feel that this is done by design, because you have very powerful CPUs in a small package with nowhere for the heat to go when they do their thing. To make sure Google/Android/the device maker isn't liable to pay for damages due to the device having burst into flames, I'm pretty sure they've built something in that prevents this from being utilized as you want to. With the thought behind it being that if you want that, you best buy an actively cooled laptop."

@JacobWKlein
Copy link

JacobWKlein commented Jul 11, 2018

Right, and I don't buy that logic. At the very least, we need to figure out what's going on, and what we have control over. And, since it appears that there is a way to use more of the CPUs, we should have the option to do so.

Setting a slider to 8, and having it still only use 2, when it could use 6, is not really acceptable.

We need to get a handle of this "fg" "bg" stuff, if we don't already.

@Ageless93
Copy link
Contributor

One other thing that I am still researching is the floating point unit (FPU) on these CPUs. It's possible that all cores per CPU cluster have only got access to one shared FPU.

@JuhaSointusalo
Copy link
Contributor

JuhaSointusalo commented Jul 11, 2018

Duplicate of #2549

@JuhaSointusalo JuhaSointusalo marked this as a duplicate of #2549 Jul 11, 2018
@JuhaSointusalo
Copy link
Contributor

@JacobWKlein Please summarise your findings in #2549 (or copy your emails there).

(Sorry duplicate comment, Github's duplicate issue thingy doesn't allow anything other than the magic words in comment.)

@JacobWKlein
Copy link

I have summarized my findings in #2549 per your request.

@AenBleidd AenBleidd added this to the Android Release 7.16.16 milestone Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants