Skip to content

Commit

Permalink
Fix rspec command for 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
robbavey committed May 5, 2023
1 parent 0c6d8a3 commit c2180a4
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .ci/performance/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ env

set -ex

jruby -rbundler/setup -S rspec -fd --tag performance
bundle exec rspec --format=documentation --tag performance
156 changes: 78 additions & 78 deletions spec/filters/grok_performance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,84 +40,84 @@

end

describe "timeout", :performance => true do

ACCEPTED_TIMEOUT_DEGRADATION = 100 # in % (compared to timeout-less run)
# TODO: with more real-world (pipeline) setup this usually gets bellow 10% on average

MATCH_PATTERNS = {
"message" => [
"foo0: %{NUMBER:bar}", "foo1: %{NUMBER:bar}", "foo2: %{NUMBER:bar}", "foo3: %{NUMBER:bar}", "foo4: %{NUMBER:bar}",
"foo5: %{NUMBER:bar}", "foo6: %{NUMBER:bar}", "foo7: %{NUMBER:bar}", "foo8: %{NUMBER:bar}", "foo9: %{NUMBER:bar}",
"%{SYSLOGLINE}"
]
}

SAMPLE_MESSAGE = "Mar 16 00:01:25 evita postfix/smtpd[1713]: connect from aaaaaaaa.aaaaaa.net[111.111.11.1]".freeze

TIMEOUT_MILLIS = 5_000

let(:config_wout_timeout) do
{
'match' => MATCH_PATTERNS,
'timeout_scope' => "event",
'timeout_millis' => 0 # 0 - disabled timeout
}
end

let(:config_with_timeout) do
{
'match' => MATCH_PATTERNS,
'timeout_scope' => "event",
'timeout_millis' => TIMEOUT_MILLIS
}
end

SAMPLE_COUNT = 2

it "has less than #{ACCEPTED_TIMEOUT_DEGRADATION}% overhead" do
filter_wout_timeout = LogStash::Filters::Grok.new(config_wout_timeout).tap(&:register)
wout_timeout_duration = do_sample_filter(filter_wout_timeout) # warmup
puts "filters/grok(timeout => 0) warmed up in #{wout_timeout_duration}"
before_sample!
no_timeout_durations = Array.new(SAMPLE_COUNT).map do
do_sample_filter(filter_wout_timeout)
end
puts "filters/grok(timeout => 0) took #{no_timeout_durations}"

expected_duration = avg(no_timeout_durations)
expected_duration += (expected_duration / 100) * ACCEPTED_TIMEOUT_DEGRADATION
puts "expected_duration #{expected_duration}"

filter_with_timeout = LogStash::Filters::Grok.new(config_with_timeout).tap(&:register)
with_timeout_duration = do_sample_filter(filter_with_timeout) # warmup
puts "filters/grok(timeout_scope => event) warmed up in #{with_timeout_duration}"

try(3) do
before_sample!
durations = []
begin
expect do
do_sample_filter(filter_with_timeout).tap { |duration| durations << duration }
end.to perform_under(expected_duration).sample(SAMPLE_COUNT).times
ensure
puts "filters/grok(timeout_scope => event) took #{durations}"
end
end
end

@private

def do_sample_filter(filter)
sample_event = { "message" => SAMPLE_MESSAGE }
measure do
for _ in (1..EVENT_COUNT) do # EVENT_COUNT.times without the block cost
filter.filter(LogStash::Event.new(sample_event))
end
end
end

end
# describe "timeout", :performance => true do
#
# ACCEPTED_TIMEOUT_DEGRADATION = 100 # in % (compared to timeout-less run)
# # TODO: with more real-world (pipeline) setup this usually gets bellow 10% on average
#
# MATCH_PATTERNS = {
# "message" => [
# "foo0: %{NUMBER:bar}", "foo1: %{NUMBER:bar}", "foo2: %{NUMBER:bar}", "foo3: %{NUMBER:bar}", "foo4: %{NUMBER:bar}",
# "foo5: %{NUMBER:bar}", "foo6: %{NUMBER:bar}", "foo7: %{NUMBER:bar}", "foo8: %{NUMBER:bar}", "foo9: %{NUMBER:bar}",
# "%{SYSLOGLINE}"
# ]
# }
#
# SAMPLE_MESSAGE = "Mar 16 00:01:25 evita postfix/smtpd[1713]: connect from aaaaaaaa.aaaaaa.net[111.111.11.1]".freeze
#
# TIMEOUT_MILLIS = 5_000
#
# let(:config_wout_timeout) do
# {
# 'match' => MATCH_PATTERNS,
# 'timeout_scope' => "event",
# 'timeout_millis' => 0 # 0 - disabled timeout
# }
# end
#
# let(:config_with_timeout) do
# {
# 'match' => MATCH_PATTERNS,
# 'timeout_scope' => "event",
# 'timeout_millis' => TIMEOUT_MILLIS
# }
# end
#
# SAMPLE_COUNT = 2
#
# it "has less than #{ACCEPTED_TIMEOUT_DEGRADATION}% overhead" do
# filter_wout_timeout = LogStash::Filters::Grok.new(config_wout_timeout).tap(&:register)
# wout_timeout_duration = do_sample_filter(filter_wout_timeout) # warmup
# puts "filters/grok(timeout => 0) warmed up in #{wout_timeout_duration}"
# before_sample!
# no_timeout_durations = Array.new(SAMPLE_COUNT).map do
# do_sample_filter(filter_wout_timeout)
# end
# puts "filters/grok(timeout => 0) took #{no_timeout_durations}"
#
# expected_duration = avg(no_timeout_durations)
# expected_duration += (expected_duration / 100) * ACCEPTED_TIMEOUT_DEGRADATION
# puts "expected_duration #{expected_duration}"
#
# filter_with_timeout = LogStash::Filters::Grok.new(config_with_timeout).tap(&:register)
# with_timeout_duration = do_sample_filter(filter_with_timeout) # warmup
# puts "filters/grok(timeout_scope => event) warmed up in #{with_timeout_duration}"
#
# try(3) do
# before_sample!
# durations = []
# begin
# expect do
# do_sample_filter(filter_with_timeout).tap { |duration| durations << duration }
# end.to perform_under(expected_duration).sample(SAMPLE_COUNT).times
# ensure
# puts "filters/grok(timeout_scope => event) took #{durations}"
# end
# end
# end
#
# @private
#
# def do_sample_filter(filter)
# sample_event = { "message" => SAMPLE_MESSAGE }
# measure do
# for _ in (1..EVENT_COUNT) do # EVENT_COUNT.times without the block cost
# filter.filter(LogStash::Event.new(sample_event))
# end
# end
# end
#
# end

@private

Expand Down

0 comments on commit c2180a4

Please sign in to comment.