From ff683fe12eaa94d5b9a29d7d502bf8444c8eca57 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 6 Sep 2024 17:49:21 +0200 Subject: [PATCH 1/2] Fix a leak in Lobsters benchmark Profiling the lobsters benchmark I'm seeing a fairly large time spent joining tags in TaggedLogger. That intruigued me, and by digging I noticed the requests UUIDs kept being appended but never removed. So for every single request we have one more tag, this is skewing the benchmark a bit, as we spend much more time than we should in logging. --- benchmarks/lobsters/benchmark.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmarks/lobsters/benchmark.rb b/benchmarks/lobsters/benchmark.rb index 240c50c9..3a28fe81 100644 --- a/benchmarks/lobsters/benchmark.rb +++ b/benchmarks/lobsters/benchmark.rb @@ -47,6 +47,7 @@ puts response_array.inspect raise "HTTP status is #{response_array.first} instead of 200 for req #{idx}/#{generator.routes.size}, #{path.inspect}. Is the benchmark app properly set up? See README.md." end + response_array.last.close # Response might be a Rack::BodyProxy and MUST be closed. end end From 37e6b98970c68f2fca5830fee64b97ad17126b66 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 6 Sep 2024 18:12:41 +0200 Subject: [PATCH 2/2] Also fix tag leak in railsbench --- benchmarks/railsbench/benchmark.rb | 1 + benchmarks/railsbench/popular_lines.rb | 1 + benchmarks/railsbench/popular_methods.rb | 1 + 3 files changed, 3 insertions(+) diff --git a/benchmarks/railsbench/benchmark.rb b/benchmarks/railsbench/benchmark.rb index 20a83020..89561d48 100644 --- a/benchmarks/railsbench/benchmark.rb +++ b/benchmarks/railsbench/benchmark.rb @@ -29,6 +29,7 @@ unless response_array.first == 200 raise "HTTP response is #{response_array.first} instead of 200. Is the benchmark app properly set up? See README.md." end + response_array.last.close # Response might be a Rack::BodyProxy and MUST be closed. end end diff --git a/benchmarks/railsbench/popular_lines.rb b/benchmarks/railsbench/popular_lines.rb index fdb4397e..616cda08 100644 --- a/benchmarks/railsbench/popular_lines.rb +++ b/benchmarks/railsbench/popular_lines.rb @@ -22,6 +22,7 @@ def run_bench(app, visiting_routes) p response_array raise "HTTP response is #{response_array.first} instead of 200. Is the benchmark app properly set up? See README.md." end + response_array.last.close # Response might be a Rack::BodyProxy and MUST be closed. end end diff --git a/benchmarks/railsbench/popular_methods.rb b/benchmarks/railsbench/popular_methods.rb index 25de1557..507e6a87 100644 --- a/benchmarks/railsbench/popular_methods.rb +++ b/benchmarks/railsbench/popular_methods.rb @@ -20,6 +20,7 @@ def run_bench(app, visiting_routes) p response_array raise "HTTP response is #{response_array.first} instead of 200. Is the benchmark app properly set up? See README.md." end + response_array.last.close # Response might be a Rack::BodyProxy and MUST be closed. end end