From 4cc24461b32500a0dc4abec6172ab9fb91fd0406 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 27 Jul 2023 10:14:10 -0700 Subject: [PATCH] Add fluentd benchmark (#243) * Add fluentd benchmark * Add more variants to error messages --- benchmarks.yml | 2 ++ benchmarks/fluentd/Gemfile | 5 ++++ benchmarks/fluentd/Gemfile.lock | 46 +++++++++++++++++++++++++++++++++ benchmarks/fluentd/benchmark.rb | 30 +++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 benchmarks/fluentd/Gemfile create mode 100644 benchmarks/fluentd/Gemfile.lock create mode 100644 benchmarks/fluentd/benchmark.rb diff --git a/benchmarks.yml b/benchmarks.yml index 65237e79..0a2a7bae 100644 --- a/benchmarks.yml +++ b/benchmarks.yml @@ -49,6 +49,8 @@ etanni: desc: etanni is an older, extremely simple template-lang format that basically turns your template into an "eval" with a lot of heredocs. fannkuchredux: desc: fannkuchredux from the Computer Language Benchmarks Game. +fluentd: + desc: fluentd is a log collector, which parses logs in a server and forwards them to various destinations. ruby-json: desc: an optimized version of the json_pure gem's pure Ruby JSON parser. lee: diff --git a/benchmarks/fluentd/Gemfile b/benchmarks/fluentd/Gemfile new file mode 100644 index 00000000..3f7549a1 --- /dev/null +++ b/benchmarks/fluentd/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +gem 'fluentd' +gem 'cool.io', github: 'k0kubun/cool.io', branch: 'ruby-3-3' diff --git a/benchmarks/fluentd/Gemfile.lock b/benchmarks/fluentd/Gemfile.lock new file mode 100644 index 00000000..1dda7d59 --- /dev/null +++ b/benchmarks/fluentd/Gemfile.lock @@ -0,0 +1,46 @@ +GIT + remote: https://github.com/k0kubun/cool.io.git + revision: 61e3caf8b961fb1a4d46b367eb58ebcddb45da4a + branch: ruby-3-3 + specs: + cool.io (1.7.1) + +GEM + remote: https://rubygems.org/ + specs: + concurrent-ruby (1.2.2) + fluentd (1.16.2) + bundler + cool.io (>= 1.4.5, < 2.0.0) + http_parser.rb (>= 0.5.1, < 0.9.0) + msgpack (>= 1.3.1, < 2.0.0) + serverengine (>= 2.3.2, < 3.0.0) + sigdump (~> 0.2.5) + strptime (>= 0.2.4, < 1.0.0) + tzinfo (>= 1.0, < 3.0) + tzinfo-data (~> 1.0) + webrick (~> 1.4) + yajl-ruby (~> 1.0) + http_parser.rb (0.8.0) + msgpack (1.7.2) + serverengine (2.3.2) + sigdump (~> 0.2.2) + sigdump (0.2.5) + strptime (0.2.5) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + tzinfo-data (1.2023.3) + tzinfo (>= 1.0.0) + webrick (1.8.1) + yajl-ruby (1.4.3) + +PLATFORMS + arm64-darwin-22 + x86_64-linux + +DEPENDENCIES + cool.io! + fluentd + +BUNDLED WITH + 2.4.1 diff --git a/benchmarks/fluentd/benchmark.rb b/benchmarks/fluentd/benchmark.rb new file mode 100644 index 00000000..aee1908d --- /dev/null +++ b/benchmarks/fluentd/benchmark.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require 'harness' + +Dir.chdir(__dir__) +use_gemfile + +require 'fluent/engine' +require 'fluent/parser' + +# Prepare a fixture +time = Time.new(2023, 7, 27, 9, 00, 00) +errors = [ + "Skipping user-data validation. No user-data found.", + "Python version change detected. Purging cache", + "No instance datasource found.", + "No kernel command line url found.", + "No local datasource found", +] +ltsv = 1000.times.map { |i| "time:#{time + i} module:main.py level:DEBUG message:#{errors.sample}\n" }.join +ltsv *= 1000 + +# Prepare an LTSV parser +parser = Fluent::Plugin::LabeledTSVParser.new +parser.configure(Fluent::Config::Element.new('parse', '', {}, [])) + +# Benchmark the `@type ltsv` use case +run_benchmark(10) do + parser.parse(ltsv) {} +end