Skip to content

Commit 762bf7f

Browse files
Add string malloc pressure benchmark
This benchmark allocates a large amount of malloc backed strings and keeps them alive in the heap. It is intended to exercise GC's triggered by malloc pressure.
1 parent 26bef91 commit 762bf7f

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎benchmarks.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ sudoku:
136136
splay:
137137
desc: Splay tree operations (insert, find, remove) to stress GC.
138138
single_file: true
139+
string_malloc_pressure:
140+
desc: Allocates and retains many empty Strings with large reserved capacity to exercise GC under malloc-backed String buffer pressure.
141+
category: gc
142+
single_file: true
143+
default_harness: harness-gc
139144
tinygql:
140145
desc: TinyGQL gem parsing a large file in pure Ruby
141146

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require_relative '../harness/loader'
2+
3+
def build_string_malloc_pressure
4+
live = []
5+
500.times do
6+
live << Array.new(200) { String.new(capacity: 64 * 1024) }
7+
end
8+
end
9+
10+
run_benchmark(10) do
11+
build_string_malloc_pressure
12+
end

0 commit comments

Comments
 (0)