Class: Distem::Algorithm::CPU::Hogs

Inherits:
Distem::Algorithm show all
Defined in:
lib/distem/algorithm/cpu/hogs.rb

Overview

Algorithm based on CPU burning methods. A process is launched in background and consume 100-wished_% percent of the core calculation resources i.e. if the cpu have to be set at 80% of this performancy, the algorithm will consume 20% permanently

Instance Method Summary (collapse)

Constructor Details

- (Hogs) initialize

Create a new Hogs object



9
10
11
12
# File 'lib/distem/algorithm/cpu/hogs.rb', line 9

def initialize()
  super()
  @ext = nil
end

Instance Method Details

- (Object) apply(vnode)

Apply the algorithm on a resource (virtual node)

Attributes

  • vnode The VNode object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/distem/algorithm/cpu/hogs.rb', line 18

def apply(vnode)
  super(vnode)
  coresdesc = {}

  if vnode.vcpu and vnode.vcpu.vcores
    vnode.vcpu.vcores.each_value do |vcore|
      coresdesc[vcore.pcore.physicalid.to_i] = 
        vcore.frequency.to_f / vcore.pcore.frequency.to_f if \
        vcore.frequency < vcore.pcore.frequency
    end
  end

  unless coresdesc.empty?
    @ext = CPUExtension::CPUHogs.new
    @ext.run(coresdesc)
  end
end

- (Object) undo(vnode)

Undo the algorithm on a resource (virtual node)

Attributes

  • vnode The VNode object



40
41
42
43
44
45
46
# File 'lib/distem/algorithm/cpu/hogs.rb', line 40

def undo(vnode)
  super(vnode)
  if @ext
    @ext.stop
    @ext = nil
  end
end