Author Topic: Algorithm for 'CPU efficiency'  (Read 3149 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard Haselgrove

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Algorithm for 'CPU efficiency'
« on: August 19, 2015, 04:55:47 pm »
Fred, please could you post (or email me) the algorithm you use for calculating the CPU efficiency of an individual running BOINC task?

It would be useful for the CERN projects which run their own tasks inside a virtual machine: a script monitoring CPU efficiency could tell whether the CERN server was keeping the VM supplied with tasks, and trigger a tweak to <max_ncpus_pct> (by swapping global_prefs_override.xml files) to allow another BOINC project to use the VM core when idle.

Offline fred

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3696
  • eFMer
    • View Profile
    • Trails
Re: Algorithm for 'CPU efficiency'
« Reply #1 on: August 19, 2015, 05:30:52 pm »
Fred, please could you post (or email me) the algorithm you use for calculating the CPU efficiency of an individual running BOINC task?
You mean the column CPU %?


Offline Richard Haselgrove

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Algorithm for 'CPU efficiency'
« Reply #2 on: August 20, 2015, 08:07:24 am »
You mean the column CPU %?
Yes, that would be the one.

Offline fred

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3696
  • eFMer
    • View Profile
    • Trails
Re: Algorithm for 'CPU efficiency'
« Reply #3 on: August 20, 2015, 10:14:39 am »
Yes, that would be the one.
What you have to do is sample the elapsed time of that task.
Start a timer and after a certain amount of time sample again.
But that depends how the task time progresses. If it progresses badly your results will be vary inaccurate.
A longer sampling time may be needed.
Basically you have the percentage right away.
Don't know it will work as you have to know how the virtual machine uses resources.

What probably works more accurate is monitoring the virtual machine itself, see how much of the CPU it's using.


Offline Richard Haselgrove

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Algorithm for 'CPU efficiency'
« Reply #4 on: August 20, 2015, 10:40:55 am »
Yes, I thought that might be the case. I think your predecessor - BoincView - averages the last ten sample points: I have the sample interval set at 30 seconds, and it can take 5 minutes for a new task to settle.

I can't find a scriptable way of monitoring a single process in Windows. Somebody on the CMS-dev board suggested

Code: [Select]
wmic cpu get loadpercentage
but that just gets the total machine loading - not even 'per core'. I got as far as

Code: [Select]
wmic process where name="vboxheadless.exe" get UserModeTime
(no loadpercentage available) - but then we're back to interval timing, so we may as well do it using the BOINC tools. boinccmd's --get_simple_gui_info output:

Quote
======== Tasks ========
1) -----------
   name: CMS_4352_1427806758.445768_0
   WU name: CMS_4352_1427806758.445768
   project URL: http://boincai05.cern.ch/CMS-dev/
   report deadline: Wed Aug 26 09:28:07 2015
   ready to report: no
   got server ack: no
   final CPU time: 0.000000
   state: downloaded
   scheduler state: scheduled
   exit_status: 0
   signal: 0
   suspended via GUI: no
   active_task_state: EXECUTING
   app version num: 4617
   checkpoint CPU time: 18508.660000
   current CPU time: 18557.180000
   fraction done: 0.233817
   swap size: 117 MB
   working set size: 477 MB
   estimated CPU time remaining: 52081.563976

is probably good enough for now.

But hang on - where's elapsed time? Don't tell me that David has recycled a label again?

Edit - no, panic over. CPU time is CPU time - the one I'm looking for. Elapsed time is simply missing.
« Last Edit: August 20, 2015, 10:50:27 am by Richard Haselgrove »

Offline fred

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3696
  • eFMer
    • View Profile
    • Trails
Re: Algorithm for 'CPU efficiency'
« Reply #5 on: August 20, 2015, 10:56:33 am »
But hang on - where's elapsed time? Don't tell me that David has recycled a label again?
Got 2 doubles only valid on a running task:
elapsed_time
current_cpu_time

Ratio = delta current_cpu_time / delta elapsed_time

Offline Richard Haselgrove

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Algorithm for 'CPU efficiency'
« Reply #6 on: August 20, 2015, 11:07:32 am »
But hang on - where's elapsed time? Don't tell me that David has recycled a label again?
Got 2 doubles only valid on a running task:
elapsed_time
current_cpu_time

Ratio = delta current_cpu_time / delta elapsed_time

Perhaps they added elapsed_time to the GUI RPC output, but didn't retro-fit it to boinccmd? I picked "--get_simple_gui_info", because that *only* outputs running tasks ("active_task_state: EXECUTING") - but elapsed time is missing for the --tasks output too. I'll do some more digging around.