Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[testbed] Include CPU and memory limits to benchmark results file #36753

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ed16cba
add cpu and memory limits to benchmark results
bacherfl Dec 9, 2024
926d355
disable the new values by default
bacherfl Dec 10, 2024
6985348
rename property to better reflect its use
bacherfl Dec 10, 2024
2382447
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Dec 10, 2024
22cfc0d
add changelog entry
bacherfl Dec 10, 2024
4d6b4b4
Merge remote-tracking branch 'bacherfl/feat/testbed-results-include-l…
bacherfl Dec 10, 2024
099f071
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Dec 12, 2024
487fe89
add table headers
bacherfl Dec 12, 2024
5aaad19
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Dec 16, 2024
caf0c86
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Dec 19, 2024
2f020ee
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Jan 7, 2025
b0120c0
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Jan 13, 2025
81a6de5
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Jan 14, 2025
8a9ccc5
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Jan 15, 2025
6b4e163
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Jan 16, 2025
04407be
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Jan 20, 2025
945bd4e
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Jan 21, 2025
9777fad
Merge branch 'main' into feat/testbed-results-include-limits
bacherfl Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/testbed-add-resource-limits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: testbed

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Include the specified resource limits for CPU and memory in the benchmark results

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36720]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
5 changes: 4 additions & 1 deletion testbed/testbed/child_process_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,10 @@ func (cp *childProcessCollector) GetResourceConsumption() string {

// GetTotalConsumption returns total resource consumption since start of process
func (cp *childProcessCollector) GetTotalConsumption() *ResourceConsumption {
rc := &ResourceConsumption{}
rc := &ResourceConsumption{
CPUPercentLimit: float64(cp.resourceSpec.ExpectedMaxCPU),
RAMMiBLimit: cp.resourceSpec.ExpectedMaxRAM,
}

if cp.processMon != nil {
// Get total elapsed time since process start
Expand Down
10 changes: 6 additions & 4 deletions testbed/testbed/in_process_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ func (ipp *inProcessCollector) GetProcessMon() *process.Process {

func (ipp *inProcessCollector) GetTotalConsumption() *ResourceConsumption {
return &ResourceConsumption{
CPUPercentAvg: 0,
CPUPercentMax: 0,
RAMMiBAvg: 0,
RAMMiBMax: 0,
CPUPercentAvg: 0,
CPUPercentMax: 0,
CPUPercentLimit: 0,
RAMMiBAvg: 0,
RAMMiBMax: 0,
RAMMiBLimit: 0,
}
}

Expand Down
10 changes: 6 additions & 4 deletions testbed/testbed/otelcol_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ type StartParams struct {
}

type ResourceConsumption struct {
CPUPercentAvg float64
CPUPercentMax float64
RAMMiBAvg uint32
RAMMiBMax uint32
CPUPercentAvg float64
CPUPercentMax float64
CPUPercentLimit float64
RAMMiBAvg uint32
RAMMiBMax uint32
RAMMiBLimit uint32
}

// OtelcolRunner defines the interface for configuring, starting and stopping one or more instances of
Expand Down
46 changes: 33 additions & 13 deletions testbed/testbed/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ type PerformanceResults struct {

// PerformanceTestResult reports the results of a single performance test.
type PerformanceTestResult struct {
testName string
result string
duration time.Duration
cpuPercentageAvg float64
cpuPercentageMax float64
ramMibAvg uint32
ramMibMax uint32
sentSpanCount uint64
receivedSpanCount uint64
errorCause string
testName string
result string
duration time.Duration
cpuPercentageAvg float64
cpuPercentageMax float64
cpuPercentageLimit float64
ramMibAvg uint32
ramMibMax uint32
ramMibLimit uint32
sentSpanCount uint64
receivedSpanCount uint64
errorCause string
}

func (r *PerformanceResults) Init(resultsDir string) {
Expand All @@ -83,8 +85,8 @@ func (r *PerformanceResults) Init(resultsDir string) {
_, _ = io.WriteString(r.resultsFile,
"# Test PerformanceResults\n"+
fmt.Sprintf("Started: %s\n\n", time.Now().Format(time.RFC1123Z))+
"Test |Result|Duration|CPU Avg%|CPU Max%|RAM Avg MiB|RAM Max MiB|Sent Items|Received Items|\n"+
"----------------------------------------|------|-------:|-------:|-------:|----------:|----------:|---------:|-------------:|\n")
"Test |Result|Duration|CPU Avg%|CPU Max%|CPU Limit|RAM Avg MiB|RAM Max MiB|RAM Limit MiB|Sent Items|Received Items|\n"+
"----------------------------------------|------|-------:|-------:|-------:|--------:|----------:|----------:|------------:|---------:|-------------:|\n")
}

// Save the total results and close the file.
Expand All @@ -103,14 +105,16 @@ func (r *PerformanceResults) Add(_ string, result any) {
}

_, _ = io.WriteString(r.resultsFile,
fmt.Sprintf("%-40s|%-6s|%7.0fs|%8.1f|%8.1f|%11d|%11d|%10d|%14d|%s\n",
fmt.Sprintf("%-40s|%-6s|%7.0fs|%8.1f|%8.1f|%8.1f|%11d|%11d|%11d|%10d|%14d|%s\n",
testResult.testName,
testResult.result,
testResult.duration.Seconds(),
testResult.cpuPercentageAvg,
testResult.cpuPercentageMax,
testResult.cpuPercentageLimit,
testResult.ramMibAvg,
testResult.ramMibMax,
testResult.ramMibLimit,
testResult.sentSpanCount,
testResult.receivedSpanCount,
testResult.errorCause,
Expand All @@ -135,6 +139,14 @@ func (r *PerformanceResults) Add(_ string, result any) {
Unit: "%",
Extra: cpuChartName,
})
if testResult.cpuPercentageLimit > 0 {
r.benchmarkResults = append(r.benchmarkResults, &benchmarkResult{
Name: "cpu_percentage_limit",
Value: testResult.cpuPercentageLimit,
Unit: "%",
Extra: cpuChartName,
})
}
r.benchmarkResults = append(r.benchmarkResults, &benchmarkResult{
Name: "ram_mib_avg",
Value: float64(testResult.ramMibAvg),
Expand All @@ -147,6 +159,14 @@ func (r *PerformanceResults) Add(_ string, result any) {
Unit: "MiB",
Extra: memoryChartName,
})
if testResult.ramMibLimit > 0 {
r.benchmarkResults = append(r.benchmarkResults, &benchmarkResult{
Name: "ram_mib_limit",
Value: float64(testResult.ramMibLimit),
Unit: "MiB",
Extra: memoryChartName,
})
}
r.benchmarkResults = append(r.benchmarkResults, &benchmarkResult{
Name: "dropped_span_count",
Value: float64(testResult.sentSpanCount - testResult.receivedSpanCount),
Expand Down
16 changes: 13 additions & 3 deletions testbed/testbed/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ func (v *LogPresentValidator) RecordResults(tc *TestCase) {
}

// PerfTestValidator implements TestCaseValidator for test suites using PerformanceResults for summarizing results.
type PerfTestValidator struct{}
type PerfTestValidator struct {
// IncludeLimitsInReport determines whether the summary generated by PerformanceResults should include the specified resource limits
IncludeLimitsInReport bool
ChrsMark marked this conversation as resolved.
Show resolved Hide resolved
}

func (v *PerfTestValidator) Validate(tc *TestCase) {
if assert.EqualValues(tc.t,
Expand All @@ -90,7 +93,7 @@ func (v *PerfTestValidator) RecordResults(tc *TestCase) {
// Remove "Test" prefix from test name.
testName := tc.t.Name()[4:]

tc.resultsSummary.Add(tc.t.Name(), &PerformanceTestResult{
performanceResults := &PerformanceTestResult{
testName: testName,
result: result,
receivedSpanCount: tc.MockBackend.DataItemsReceived(),
Expand All @@ -101,7 +104,14 @@ func (v *PerfTestValidator) RecordResults(tc *TestCase) {
ramMibAvg: rc.RAMMiBAvg,
ramMibMax: rc.RAMMiBMax,
errorCause: tc.errorCause,
})
}

if v.IncludeLimitsInReport {
performanceResults.cpuPercentageLimit = rc.CPUPercentLimit
performanceResults.ramMibLimit = rc.RAMMiBLimit
}

tc.resultsSummary.Add(tc.t.Name(), performanceResults)
}

// CorrectnessTestValidator implements TestCaseValidator for test suites using CorrectnessResults for summarizing results.
Expand Down
Loading