Skip to content

Commit 9659e1b

Browse files
committed
Merge branch 'master' into hmusum/use-assertions-from-rubygem
2 parents 8c58f9a + ac112ec commit 9659e1b

File tree

15 files changed

+113
-107
lines changed

15 files changed

+113
-107
lines changed

docker/include/feature-flags.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
{ "id" : "max-uncommitted-memory", "rules" : [ { "value" : 130000 } ] },
5252
{ "id" : "resource-limit-disk", "rules" : [ { "value" : 0.9 } ] },
5353
{ "id" : "write-config-server-session-data-as-blob", "rules" : [ { "value" : true } ] },
54+
{ "id" : "send-protobuf-querytree", "rules" : [ { "value" : true } ] },
5455
{ "id" : "unknown-config-definition", "rules" : [ { "value" : "fail" } ] },
5556
{ "id" : "content-layer-metadata-feature-level", "rules" : [ { "value" : 1 } ] },
5657
{ "id" : "search-core-transaction-log-replay-soft-memory-limit", "rules" : [ { "value" : -5 } ] },

lib/performance/system.rb

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,65 @@
44

55
module Perf
66

7+
# Calculate cpu util for a time period, use start() and end()
78
class System
89
attr_reader :hostname
910

1011
def initialize(node, data = {})
1112
@node = node
12-
@hostname = node.hostname
13+
@hostname = node.hostname unless node == nil
1314
@data = data
1415
@start_cpu_used = 0
1516
@start_cpu_total = 0
1617
@end_cpu_used = 0
1718
@end_cpu_total = 0
18-
@ysar_binary = propose_ysar_gather # TODO Remove dependency on internal tooling
1919
end
2020

21-
def propose_ysar_gather
22-
@ysar_binary = "#{Environment.instance.vespa_home}/sbin/ysar_gather"
23-
@ysar_binary = "/usr/sbin/ysar_gather" unless has_ysar
21+
# For unit testing
22+
def self.create_for_testing(hostname)
23+
@hostname = hostname
24+
new(nil)
2425
end
2526

26-
def has_ysar
27-
@node.file?(@ysar_binary)
27+
def cpu_usage
28+
calculate_cpu_usage(@node.execute("cat /proc/stat", :noecho => true))
2829
end
2930

30-
def ysar_gather_cmd
31-
"#{@ysar_binary} --list --delay-mode=none"
32-
end
33-
34-
def load
35-
unless has_ysar
36-
return [0, 0]
37-
end
38-
output = @node.execute(ysar_gather_cmd, :noecho => true)
39-
output.split("\n").each do |l|
40-
if l =~ /^cput=/
41-
key,value = l.split('=')
42-
values = value.split(',').collect(&:to_i)
43-
31+
def calculate_cpu_usage(stat_output)
32+
# See 'man proc_stat' for format. Basically this sums all cpu usage types and subtracts idle time to find cpu used
33+
stat_output.split("\n").each do |line|
34+
if line =~ /^cpu /
35+
values = line.split(' ').collect(&:to_i)
36+
values.delete(0) # Remove first item ('cpu')
4437
total = values.inject(:+)
45-
used = total - values[4]
38+
# Subtract idle time to find cpu usage
39+
used = total - values[3]
4640

4741
return [used, total]
4842
end
4943
end
5044

51-
return [0, 0]
45+
[0, 0]
5246
end
5347

5448
def start
55-
@start_cpu_used, @start_cpu_total = load
49+
@start_cpu_used, @start_cpu_total = cpu_usage
5650
end
5751

5852
def end
59-
@end_cpu_used, @end_cpu_total = load
60-
cpu_util = (@end_cpu_used - @start_cpu_used).to_f / (@end_cpu_total - @start_cpu_total)
53+
@end_cpu_used, @end_cpu_total = cpu_usage
54+
set_cpu_util([@start_cpu_used, @start_cpu_total], [@end_cpu_used, @end_cpu_total])
55+
end
56+
57+
def set_cpu_util(start_data, end_data)
58+
cpu_util = (end_data[0] - start_data[0]).to_f / (end_data[1] - start_data[1]).to_f
6159
@data['cpuutil'] = cpu_util.nan? ? 0.0 : cpu_util
6260
end
6361

62+
def cpu_util
63+
@data['cpuutil']
64+
end
65+
6466
def fill
6567
Proc.new do |result|
6668
result.add_metric('cpuutil', @data['cpuutil'], @hostname)

lib/test/stat_output_end.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cpu 2755034 16808 1456367 173042706 7719 2816574 108368 0 0 0
2+
cpu0 685797 3110 361564 43255672 1177 711966 29935 0 0 0
3+
cpu1 687168 5049 364759 43258167 2339 705184 26893 0 0 0
4+
cpu2 692538 3254 364614 43263697 2158 699850 25656 0 0 0
5+
cpu3 689530 5394 365430 43265168 2044 699572 25883 0 0 0
6+
intr 1445969025 0 6636264 591611701 0 0 0 23 0 0 0 844414262 0 0 0 0 0 0 0 0 0 0 0 0 0 7374 0 0 0 24 0 3 5 0 0 0 16 0 160 402398 0 0 3 0 0 5 0 1404376 0 963393 529018 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7+
ctxt 2507040035
8+
btime 1760582953
9+
processes 702537
10+
procs_running 1
11+
procs_blocked 0
12+
softirq 119678384 0 21829652 122 17066458 1308031 0 430 63152146 0 16321545

lib/test/stat_output_start.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cpu 2745670 16808 1449026 172238106 7687 2803796 107300 0 0 0
2+
cpu0 683460 3110 359716 43054709 1170 708656 29642 0 0 0
3+
cpu1 684784 5049 362895 43057120 2330 701954 26628 0 0 0
4+
cpu2 690206 3254 362803 43062430 2150 696701 25398 0 0 0
5+
cpu3 687219 5394 363611 43063845 2034 696483 25631 0 0 0
6+
intr 1442433360 0 6624196 590984852 0 0 0 23 0 0 0 841531182 0 0 0 0 0 0 0 0 0 0 0 0 0 7340 0 0 0 24 0 3 5 0 0 0 16 0 156 391687 0 0 3 0 0 5 0 1402901 0 962570 528397 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7+
ctxt 2501296161
8+
btime 1760582953
9+
processes 694100
10+
procs_running 2
11+
procs_blocked 0
12+
softirq 118835475 0 21603679 122 17063113 1306592 0 422 62703317 0 16158230

lib/test/test_result_model.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,6 @@ def parameter(name)
2525

2626
class ResultModelTest < Test::Unit::TestCase
2727

28-
def notest_readwrite
29-
begin
30-
f = Tempfile.new('result.xml')
31-
path = f.path
32-
f.close
33-
r = Perf::Result.new('5.0')
34-
35-
r.fbench = { 'runtime' => 555, '99p' => '5.5', '95p' => '1.5', 'successfulrequests' => 5 }
36-
host = flexmock(Perf::System.new('localhost'))
37-
host.should_receive(:data).and_return({ 'cpu_util' => 99.98 })
38-
r.add_host host
39-
40-
r.write(path)
41-
42-
r2 = Perf::Result.read(path)
43-
44-
assert_equal(r.vespa_version, r2.vespa_version)
45-
assert_equal(r.fbench['successfulrequests'], r2.fbench['successfulrequests'])
46-
assert_equal(r.hosts.size, r2.hosts.size)
47-
assert_equal(r.host('localhost').data['cpu_util'], r2.host('localhost').data['cpu_util'])
48-
ensure
49-
File.unlink(path)
50-
end
51-
end
52-
5328
def test_custom_producer_parsing
5429
# Float
5530
m1 = MockModel.new("1.5")

lib/test/test_system.rb

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,18 @@
11
# Copyright Vespa.ai. All rights reserved.
2-
require 'flexmock/test_unit'
3-
require 'rubygems'
4-
require 'test/unit'
52

63
require 'performance/system'
4+
require 'test/unit'
75

86
class SystemTest < Test::Unit::TestCase
9-
class MockResult
10-
attr_reader :metrics
11-
def initialize
12-
@metrics = {}
13-
end
14-
15-
def add_metric(name, value, tag)
16-
@metrics[name + ':' + tag] = value
17-
end
18-
end
197

208
def test_cpuutil
21-
node = flexmock('node')
22-
node.should_receive(:file?).and_return(true)
23-
node.should_receive(:execute).times(2).
24-
and_return(IO.read(File.join(File.dirname(__FILE__), "ysar_gather_output.txt")),
25-
IO.read(File.join(File.dirname(__FILE__), "ysar_gather_output2.txt")))
26-
node.should_receive(:hostname).
27-
and_return('localhost')
28-
system = flexmock(Perf::System.new(node, {}))
29-
system.start
30-
system.end
31-
filler = system.fill
32-
result = MockResult.new
33-
filler.call(result)
34-
assert_in_delta(0.999900049975012,
35-
result.metrics['cpuutil:localhost'],
9+
system = Perf::System.create_for_testing('localhost')
10+
start_cpu_used, start_cpu_total = system.calculate_cpu_usage(IO.read(File.join(File.dirname(__FILE__), "stat_output_start.txt")))
11+
end_cpu_used, end_cpu_total = system.calculate_cpu_usage(IO.read(File.join(File.dirname(__FILE__), "stat_output_end.txt")))
12+
system.set_cpu_util([start_cpu_used, start_cpu_total], [end_cpu_used, end_cpu_total])
13+
14+
assert_in_delta(0.03661832197254973,
15+
system.cpu_util,
3616
0.00000001)
3717
end
3818

lib/test/ysar_gather_output.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/test/ysar_gather_output2.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/container/zk_reconfig/zookeeper_test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</parent>
1515

1616
<properties>
17-
<zookeeper.version>3.9.3</zookeeper.version>
17+
<zookeeper.version>3.9.4</zookeeper.version>
1818
</properties>
1919

2020
<dependencies>

tests/performance/bert/bert.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def setup
99
set_owner("glebashnik")
1010
@valgrind = false
1111
@node = @vespa.nodeproxies.first[1]
12-
override_environment_setting(@node, "VESPA_CONFIGSERVER_JVMARGS", "-Xms8g -Xmx8g")
12+
override_environment_setting(@node, "VESPA_CONFIGSERVER_JVMARGS", "-Xms12g -Xmx12g")
1313
end
1414

1515
def test_single_evaluation_bert_performance

0 commit comments

Comments
 (0)