How to Control CPU Core Usage on Linux?

Moderators: Site Moderators, FAHC Science Team

Post Reply
Andrew
Posts: 8
Joined: Thu Nov 19, 2020 3:42 am

How to Control CPU Core Usage on Linux?

Post by Andrew »

Hi folks,

I am looking to see if anyone is aware of how we can control the core usage using the fahclient on Linux? For example, if I want to explicitly run fahclient on 1 core, 4 cores, etc. Historically, I have performed this by editing the /etc/fahclient/config.xml file and adding a slot id on a basis of 1:1 for how many cores I would like fahclient to run on. Interestingly, this no longer seems to work on both CentOS and Ubuntu. For example, when specifying only 1 slot/1 core to run, fahclient consumes 2 cores.

Any thoughts or knowledge would be very appreciated.

Thanks
Joe_H
Site Admin
Posts: 7937
Joined: Tue Apr 21, 2009 4:41 pm
Hardware configuration: Mac Pro 2.8 quad 12 GB smp4
MacBook Pro 2.9 i7 8 GB smp2
Location: W. MA

Re: How to Control CPU Core Usage on Linux?

Post by Joe_H »

Welcome to the folding support forum.

From your post it is not clear what you are trying to accomplish or what exactly you are observing. So first some observations about configuring CPU folding slots. In general you are encouraged to have just one folding slot for CPU processing using as many CPU threads as you want to give towards folding. The only exception would be if you had a large workstation or server class machine with more CPUs providing more than 30 threads for processing. Creating and running one slot per core is strongly discouraged.

As for seeing more than one thread, it will depend of which process you are looking at. FAHClient only handles downloading and uploading WUs, maintaining the log file, and spawning off separate processes to work on the WUs. The actual processing is done in processes named FAHCore_nn, where "nn" is the particular folding core used. Currently for CPU process that will be either A7 or A8. Even then, depending on how you get a report on the number of threads used, that will also include inactive threads from the main code of the core, the active threads will match how many were set for the WU when it started.

The number of inactive threads indicated will depend a bit on the OS and the exact implementation of the libraries used in the core. For example, on my MacBook Pro I have a WU processing with 2 CPU threads set. Using the OS X Activity Monitor and checking for total threads used by FAHCore_A8, it shows 4. But only 2 are actively using CPU time.

Finally, a WU downloaded with a specific number of CPU threads in the request will use that many or less. You can not get the WU to use more than set at the time of download. If the thread count is increased, the next WU will be requested to use that many, and in most cases you will get a WU that can use as many as set.
Image

iMac 2.8 i7 12 GB smp8, Mac Pro 2.8 quad 12 GB smp6
MacBook Pro 2.9 i7 8 GB smp3
bruce
Posts: 20824
Joined: Thu Nov 29, 2007 10:13 pm
Location: So. Cal.

Re: How to Control CPU Core Usage on Linux?

Post by bruce »

That entry in Config.xml can be adjusted with FAHControl + Configure + (pick a CPU slot) + (adjust the number of threads)

FAHClient's use of a CPU has nothing to do with the number of CPUs allocated to the FAHCore. FAHClient is responsible for managing I/O and consumes very little processor time. The heavy work is done by FAHCore* which normally splits up portions of the calculation across N threads based on that setting. FAHClient's processor load will not be big enough to be noticed if it steals a little from any thread.
Andrew
Posts: 8
Joined: Thu Nov 19, 2020 3:42 am

Re: How to Control CPU Core Usage on Linux?

Post by Andrew »

Hi folks,

Thanks for the replies. I will try to elaborate on what I am attempting to do. I am looking to control exactly how many cores folding@home leverages on my server. For example, running nmon (system monitoring utility) currently returns that FAH is using 2 cores. Here is also output from top, another system utility, showing core usage of the program:

358498 fahclie+ 39 19 329608 134828 12652 R 200.0 0.8 24:50.31 /var/lib/fahclient/cores/cores.foldingathome.org/lin/64bit-avx-256/a7-0.0.19/Core_a7.fah/FahCore_+

If this is even possible with the latest client version, I suspect that I would need to edit my config.xml file. However, I am unsure what this syntax would look like. I attempted to configure remote access/administration using a Windows-based FAHControl installation, however was ultimately unable to connect to the server via the software, even after verifying the port was open. I believe I needed to configure a remote access password, but was also unsure how to do so in a headless server environment.

Thanks!
ajm
Posts: 750
Joined: Sat Mar 21, 2020 5:22 am
Location: Lucerne, Switzerland

Re: How to Control CPU Core Usage on Linux?

Post by ajm »

You should be able to configure the config.xml file, and you don't need a password, but then you have to specify it in some way. And from the kit with a complete installation, that is, with FAHControl, you can easily edit the remote kits. For example, for my system (all win10), in a remote FAH installation, I have the following (with a CPU folding on 12 threads (total 20)):

Code: Select all

<config>
  <!-- Folding Slot Configuration -->
  <max-packet-size v='big'/>

  <!-- HTTP Server -->
  <allow v='127.0.0.1 192.168.1.127'/>

  <!-- Network -->
  <proxy v=':8080'/>

  <!-- Remote Command Server -->
  <command-allow-no-pass v='127.0.0.1 192.168.1.127'/>

  <!-- Slot Control -->
  <power v='full'/>

  <!-- User Information -->
  <passkey v='edited'/>
  <team v='182116'/>
  <user v='ajm'/>

  <!-- Folding Slots -->
  <slot id='0' type='CPU'>
    <cpus v='12'/>
    <paused v='true'/>
  </slot>
  <slot id='1' type='GPU'>
    <pci-bus v='23'/>
    <pci-slot v='0'/>
  </slot>
  <slot id='2' type='GPU'>
    <pci-bus v='101'/>
    <pci-slot v='0'/>
  </slot>
</config>
The essentials for the remote function are

Code: Select all

<!-- HTTP Server -->
  <allow v='127.0.0.1 192.168.1.127'/>
and

Code: Select all

  <!-- Remote Command Server -->
  <command-allow-no-pass v='127.0.0.1 192.168.1.127'/>
where 192.168.1.127 is the IP of the machine from where I monitor this remote kit.
Andrew
Posts: 8
Joined: Thu Nov 19, 2020 3:42 am

Re: How to Control CPU Core Usage on Linux?

Post by Andrew »

Thanks so much! I think that is exactly what I needed. I added the cpus v='1' line to my config.xml file and now fahclient is only using 1 core. I will look into the remote access configuration as well as time permits, but it appears the stanza needs to read:

<!-- Folding Slots -->
<slot id='0' type='CPU'>
<cpus v='1'/>
</slot>
ajm
Posts: 750
Joined: Sat Mar 21, 2020 5:22 am
Location: Lucerne, Switzerland

Re: How to Control CPU Core Usage on Linux?

Post by ajm »

Great! :D
Post Reply