Skip to content

Commit

Permalink
Experiments to test heap profiling serialization impact
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoanjo committed Nov 8, 2024
1 parent 4789122 commit 9667ee6
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions benchmarks/profiler_memory_sample_serialize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,37 @@ def setup
timeline_enabled: false,
)
}
@recorder = @recorder_factory.call
@retained_objs = create_objects
end

def create_objects
samples_per_second = 100
simulate_seconds = 60
retained_objs = []

(samples_per_second * simulate_seconds).times do |i|
obj = sample_object(@recorder, i % 400)
retained_objs << obj if (i % @retain_every).zero?
end

GC.start unless @skip_end_gc

retained_objs
end

def run_benchmark
Benchmark.ips do |x|
benchmark_time = VALIDATE_BENCHMARK_MODE ? { time: 0.01, warmup: 0 } : { time: 30, warmup: 2 }
benchmark_time = VALIDATE_BENCHMARK_MODE ? { time: 0.01, warmup: 0 } : { time: 10, warmup: 2 }
x.config(
**benchmark_time,
)

x.report("sample+serialize #{ENV['CONFIG']} retain_every=#{@retain_every} heap_samples=#{@heap_samples_enabled} heap_size=#{@heap_size_enabled} heap_sample_every=#{@heap_sample_every} skip_end_gc=#{@skip_end_gc}") do
recorder = @recorder_factory.call
samples_per_second = 100
simulate_seconds = 60
retained_objs = []

(samples_per_second * simulate_seconds).times do |i|
obj = sample_object(recorder, i % 400)
retained_objs << obj if (i % @retain_every).zero?
end

GC.start unless @skip_end_gc

recorder.serialize
x.report("heap serialize #{ENV['CONFIG']} retain_every=#{@retain_every} heap_samples=#{@heap_samples_enabled} heap_size=#{@heap_size_enabled} heap_sample_every=#{@heap_sample_every} skip_end_gc=#{@skip_end_gc}") do
@recorder.serialize
end

x.save! "#{File.basename(__FILE__)}-results.json" unless VALIDATE_BENCHMARK_MODE
x.save! "#{File.basename(__FILE__)}-heap-results.json" unless VALIDATE_BENCHMARK_MODE
x.compare!
end
end
Expand Down

0 comments on commit 9667ee6

Please sign in to comment.