Skip to content

Commit

Permalink
Merge pull request #4263 from vespa-engine/toregge/test-cache-disk-io…
Browse files Browse the repository at this point in the history
…-metrics

Test cache disk io metrics.
  • Loading branch information
geirst authored Nov 8, 2024
2 parents 8c095ac + a13c466 commit 74083c8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/app_generator/search_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SearchApp < App
:persistence_threads => :persistence_threads,
:cpu_socket_affinity => :cpu_socket_affinity,
:resource_limits => :resource_limits,
:posting_list_cache => :posting_list_cache,
:proton_resource_limits => :proton_resource_limits,
:search_io => :search_io,
:indexing_cluster => :indexing_cluster,
Expand Down
5 changes: 5 additions & 0 deletions lib/app_generator/search_cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SearchCluster
chained_setter :min_node_ratio_per_group
chained_setter :persistence_threads
chained_setter :resource_limits
chained_setter :posting_list_cache
chained_setter :proton_resource_limits
chained_setter :search_io
chained_forward :config, :config => :add
Expand Down Expand Up @@ -69,6 +70,7 @@ def initialize(name = "search")
@hwinfo_disk_shared = true
@persistence_threads = nil
@resource_limits = nil
@posting_list_cache = nil
@proton_resource_limits = nil
@search_io = nil
end
Expand Down Expand Up @@ -155,6 +157,9 @@ def proton_config(indent)
unless @search_io.nil?
proton.add('search', ConfigValue.new('io', @search_io))
end
unless @posting_list_cache.nil?
proton.add('index', ConfigValue.new('postinglist', ConfigValue.new('cache', ConfigValue.new('maxbytes', @posting_list_cache))))
end
XmlHelper.new(indent).to_xml(proton)
end

Expand Down
15 changes: 15 additions & 0 deletions lib/app_generator/test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,21 @@ def test_that_search_io_can_be_specified
assert_substring_ignore_whitespace(actual, expected_config_fragment)
end

def test_that_posting_list_cache_can_be_specified
actual = SearchApp.new.posting_list_cache(12345).services_xml

expected_config_fragment='
<index>
<postinglist>
<cache>
<maxbytes>12345</maxbytes>
</cache>
</postinglist>
</index>'

assert_substring_ignore_whitespace(actual, expected_config_fragment)
end

def test_doc_api_and_feeder_options
actual = SearchApp.new.enable_document_api(FeederOptions.new.timeout(40)).services_xml

Expand Down
24 changes: 23 additions & 1 deletion tests/search/metrics/metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_metrics
tune_searchnode({:summary => {:store => {:cache => { :maxsize => 8192,
:compression => {:type => :lz4, :level => 8}
} } } }).
search_io('DIRECTIO')))
search_io('DIRECTIO').posting_list_cache(262144)))
start

# Search handler does a warmup query which may or may not hit the backend, since 8.170. We need to account for this in some search metrics below.
Expand Down Expand Up @@ -89,6 +89,11 @@ def test_metrics
metrics = vespa.search['test'].first.get_total_metrics # Get metrics containing disk index
assert_document_db_size_on_disk(metrics)
assert_document_db_disk_io(metrics)
assert_document_db_cached_disk_io(metrics, false)
assert_hitcount("f1:c", 2)
metrics = vespa.search['test'].first.get_total_metrics # Get metrics containing disk index
assert_document_db_disk_io(metrics)
assert_document_db_cached_disk_io(metrics, true)
end

def test_metrics_imported_attributes
Expand Down Expand Up @@ -185,6 +190,18 @@ def assert_document_db_disk_io(metrics)
assert(0 < f1_disk_io["count"])
end

def assert_document_db_cached_disk_io(metrics, expect_cached)
f1_cached_disk_io = get_cached_disk_io_for_field('f1', metrics)
puts "f1_cached_disk_io = " + f1_cached_disk_io.to_s
if expect_cached
assert(1000 < f1_cached_disk_io["sum"])
assert(0 < f1_cached_disk_io["count"])
else
assert_equal(0, f1_cached_disk_io["sum"])
assert_equal(0, f1_cached_disk_io["count"])
end
end

def get_size_on_disk_for_field(field_name, metrics)
metrics.get('content.proton.documentdb.ready.index.size_on_disk',
{"documenttype" => "test", "field" => field_name})["last"]
Expand All @@ -196,6 +213,11 @@ def get_disk_io_for_field(field_name, metrics)
{"documenttype" => "test", "field" => field_name})
end

def get_cached_disk_io_for_field(field_name, metrics)
metrics.get('content.proton.documentdb.ready.index.io.search.cached_read_bytes',
{"documenttype" => "test", "field" => field_name})
end

def dump_metric_names(metrics)
metrics.json["values"].each do |metric|
name = metric["name"]
Expand Down

0 comments on commit 74083c8

Please sign in to comment.