Skip to content

Commit d1de9ef

Browse files
authored
Merge pull request #89 from DataDog/ivoanjo/prof-13510-ruby4-heap-profiling
[PROF-13510] Add Ruby 4 heap profiling test variants
2 parents 7af99b8 + ee345fb commit d1de9ef

File tree

7 files changed

+419
-2
lines changed

7 files changed

+419
-2
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
- name: Update perf_event_paranoid settings
2424
run: sudo sysctl kernel.perf_event_paranoid=1
2525
- name: Run Docker scenarios
26-
run: go test -v -run TestScenarios
27-
env:
26+
run: go test -timeout 20m -v -run TestScenarios
27+
env:
2828
TEST_SCENARIOS: ${{ inputs.test_scenarios }}
2929
- name: Create unique artifact name
3030
id: artifact_name
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM ruby:4.0.1
2+
3+
ENV DD_PROFILING_ALLOCATION_ENABLED true
4+
ENV DD_PROFILING_EXPERIMENTAL_HEAP_ENABLED true
5+
ENV DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED true
6+
ENV DD_TRACE_DEBUG true
7+
ENV DD_PROFILING_PPROF_PREFIX="/app/data/profiles_"
8+
9+
# Copy the Ruby program into the container
10+
COPY ./scenarios/ruby_heap/gems.rb ./scenarios/ruby_heap/main.rb /app/
11+
RUN chmod 644 /app/*
12+
13+
# Set the working directory to the location of the program
14+
WORKDIR /app
15+
16+
RUN bundle install
17+
18+
# By disabling reshuffles, we will always do allocations in the same order
19+
# and thus (theoretically) increase the effect of bias from interval sampling.
20+
ENV DISABLE_RESHUFFLE="true"
21+
22+
# Run the program when the container starts
23+
CMD bundle exec ddprofrb exec ruby main.rb
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"test_name": "ruby_heap_bias",
3+
"stacks": [
4+
{
5+
"profile-type": "heap-live-samples",
6+
"stack-content": [
7+
{
8+
"regular_expression": "^<main>;each;<main>;times;<main>;a;\\*$",
9+
"percent": 10,
10+
"labels": [
11+
{
12+
"key": "allocation class",
13+
"values": [
14+
"String"
15+
],
16+
"values_regex": ""
17+
}
18+
]
19+
},
20+
{
21+
"regular_expression": "^<main>;each;<main>;times;<main>;b;new$",
22+
"percent": 20,
23+
"labels": [
24+
{
25+
"key": "allocation class",
26+
"values": [
27+
"Array"
28+
]
29+
}
30+
]
31+
},
32+
{
33+
"regular_expression": "^<main>;each;<main>;times;<main>;c$",
34+
"percent": 50,
35+
"labels": [
36+
{
37+
"key": "allocation class",
38+
"values": [
39+
"ObjectWithShape"
40+
]
41+
}
42+
]
43+
},
44+
{
45+
"regular_expression": "^<main>;each;<main>;times;<main>;d$",
46+
"percent": 20,
47+
"labels": [
48+
{
49+
"key": "allocation class",
50+
"values": [
51+
"TooComplexObject"
52+
]
53+
}
54+
]
55+
}
56+
],
57+
"error-margin": 15,
58+
"value-matching-sum": 500
59+
},
60+
{
61+
"profile-type": "heap-live-size",
62+
"stack-content": [
63+
{
64+
"regular_expression": "^<main>;each;<main>;times;<main>;a;\\*$",
65+
"percent": 22,
66+
"labels": [
67+
{
68+
"key": "allocation class",
69+
"values": [
70+
"String"
71+
],
72+
"values_regex": ""
73+
}
74+
]
75+
},
76+
{
77+
"regular_expression": "^<main>;each;<main>;times;<main>;b;new$",
78+
"percent": 36,
79+
"labels": [
80+
{
81+
"key": "allocation class",
82+
"values": [
83+
"Array"
84+
]
85+
}
86+
]
87+
},
88+
{
89+
"regular_expression": "^<main>;each;<main>;times;<main>;c$",
90+
"percent": 17,
91+
"labels": [
92+
{
93+
"key": "allocation class",
94+
"values": [
95+
"ObjectWithShape"
96+
]
97+
}
98+
]
99+
},
100+
{
101+
"regular_expression": "^<main>;each;<main>;times;<main>;d$",
102+
"percent": 25,
103+
"labels": [
104+
{
105+
"key": "allocation class",
106+
"values": [
107+
"TooComplexObject"
108+
]
109+
}
110+
]
111+
}
112+
],
113+
"error-margin": 15,
114+
"value-matching-sum": 236050
115+
}
116+
],
117+
"scale_by_duration": true
118+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM ruby:4.0.1
2+
3+
ENV DD_PROFILING_ALLOCATION_ENABLED true
4+
ENV DD_PROFILING_EXPERIMENTAL_HEAP_ENABLED true
5+
ENV DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED true
6+
ENV DD_TRACE_DEBUG true
7+
ENV DD_PROFILING_PPROF_PREFIX="/app/data/profiles_"
8+
9+
# Copy the Ruby program into the container
10+
COPY ./scenarios/ruby_heap/gems.rb ./scenarios/ruby_heap/main.rb /app/
11+
RUN chmod 644 /app/*
12+
13+
# Set the working directory to the location of the program
14+
WORKDIR /app
15+
16+
RUN bundle install
17+
18+
ENV LOOPS_PER_SEC=500
19+
20+
# Run the program when the container starts
21+
CMD bundle exec ddprofrb exec ruby main.rb
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"test_name": "ruby_heap_highload",
3+
"stacks": [
4+
{
5+
"profile-type": "heap-live-samples",
6+
"stack-content": [
7+
{
8+
"regular_expression": "^<main>;each;<main>;times;<main>;a;\\*$",
9+
"percent": 10,
10+
"labels": [
11+
{
12+
"key": "allocation class",
13+
"values": [
14+
"String"
15+
],
16+
"values_regex": ""
17+
}
18+
]
19+
},
20+
{
21+
"regular_expression": "^<main>;each;<main>;times;<main>;b;new$",
22+
"percent": 20,
23+
"labels": [
24+
{
25+
"key": "allocation class",
26+
"values": [
27+
"Array"
28+
]
29+
}
30+
]
31+
},
32+
{
33+
"regular_expression": "^<main>;each;<main>;times;<main>;c$",
34+
"percent": 50,
35+
"labels": [
36+
{
37+
"key": "allocation class",
38+
"values": [
39+
"ObjectWithShape"
40+
]
41+
}
42+
]
43+
},
44+
{
45+
"regular_expression": "^<main>;each;<main>;times;<main>;d$",
46+
"percent": 20,
47+
"labels": [
48+
{
49+
"key": "allocation class",
50+
"values": [
51+
"TooComplexObject"
52+
]
53+
}
54+
]
55+
}
56+
],
57+
"error-margin": 10,
58+
"value-matching-sum": 5000
59+
},
60+
{
61+
"profile-type": "heap-live-size",
62+
"stack-content": [
63+
{
64+
"regular_expression": "^<main>;each;<main>;times;<main>;a;\\*$",
65+
"percent": 22,
66+
"labels": [
67+
{
68+
"key": "allocation class",
69+
"values": [
70+
"String"
71+
],
72+
"values_regex": ""
73+
}
74+
]
75+
},
76+
{
77+
"regular_expression": "^<main>;each;<main>;times;<main>;b;new$",
78+
"percent": 36,
79+
"labels": [
80+
{
81+
"key": "allocation class",
82+
"values": [
83+
"Array"
84+
]
85+
}
86+
]
87+
},
88+
{
89+
"regular_expression": "^<main>;each;<main>;times;<main>;c$",
90+
"percent": 17,
91+
"labels": [
92+
{
93+
"key": "allocation class",
94+
"values": [
95+
"ObjectWithShape"
96+
]
97+
}
98+
]
99+
},
100+
{
101+
"regular_expression": "^<main>;each;<main>;times;<main>;d$",
102+
"percent": 25,
103+
"labels": [
104+
{
105+
"key": "allocation class",
106+
"values": [
107+
"TooComplexObject"
108+
]
109+
}
110+
]
111+
}
112+
],
113+
"error-margin": 10,
114+
"value-matching-sum": 2360500
115+
}
116+
],
117+
"scale_by_duration": true
118+
}

scenarios/ruby_heap_r4/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM ruby:4.0.1
2+
3+
ENV DD_PROFILING_ALLOCATION_ENABLED true
4+
ENV DD_PROFILING_EXPERIMENTAL_HEAP_ENABLED true
5+
ENV DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED true
6+
ENV DD_TRACE_DEBUG true
7+
ENV DD_PROFILING_PPROF_PREFIX="/app/data/profiles_"
8+
9+
# Copy the Ruby program into the container
10+
COPY ./scenarios/ruby_heap/gems.rb ./scenarios/ruby_heap/main.rb /app/
11+
RUN chmod 644 /app/*
12+
13+
# Set the working directory to the location of the program
14+
WORKDIR /app
15+
16+
RUN bundle install
17+
18+
# Run the program when the container starts
19+
CMD bundle exec ddprofrb exec ruby main.rb

0 commit comments

Comments
 (0)