summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAleksei Lipniagov <alipniagov@gitlab.com>2019-06-13 18:14:06 +0300
committerAleksei Lipniagov <alipniagov@gitlab.com>2019-06-19 12:16:44 +0300
commitc3b40ae13184c4e6a1ff3420fb5b4631f7f9a660 (patch)
tree44de5eb2534c48cc82d8b52c9c91004c8ee31199 /scripts
parent8716eb0cef94dbbaab5821aa693a9d92fa9f37e8 (diff)
downloadgitlab-ce-c3b40ae13184c4e6a1ff3420fb5b4631f7f9a660.tar.gz
Run static benchmarks from 'derailed_benchmarks'62722-include-derailed-benchmarks-data-to-ci-report
Two static memory benchmarks will be included in our CI pipeline. It will load gems from the Gemfile and check the amount of RAM consumed as well as the number of objects allocated and retained. Aggregated values will be included as 'metrics' into MRs while full reports will be downloadable as job artifacts.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/memory-static20
-rwxr-xr-xscripts/memory-static-objects27
2 files changed, 47 insertions, 0 deletions
diff --git a/scripts/memory-static b/scripts/memory-static
new file mode 100755
index 00000000000..54f147a7a91
--- /dev/null
+++ b/scripts/memory-static
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+
+require_relative '../lib/gitlab/popen'
+
+full_report_filename, metrics_filename = ARGV
+abort 'usage: memory-static <full_report_filename> <metrics_filename>' unless full_report_filename && metrics_filename
+
+full_report, status = Gitlab::Popen.popen(%w(bundle exec derailed bundle:mem))
+abort 'failed to execute the benchmark' unless status.zero?
+
+File.open(full_report_filename, 'w') do |f|
+ f.write(full_report)
+end
+
+stats = /TOP: (?<total_mibs_str>.*) MiB/.match(full_report.lines.first)
+abort 'failed to process the benchmark output' unless stats
+
+File.open(metrics_filename, 'a') do |f|
+ f.puts "memory_static_total_mb #{stats[:total_mibs_str].to_f.round(1)}"
+end
diff --git a/scripts/memory-static-objects b/scripts/memory-static-objects
new file mode 100755
index 00000000000..2ad38d9717c
--- /dev/null
+++ b/scripts/memory-static-objects
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+
+require_relative '../lib/gitlab/popen'
+
+full_report_filename, metrics_filename = ARGV
+abort 'usage: memory-static-objects <full_report_filename> <metrics_filename>' unless full_report_filename && metrics_filename
+
+full_report, status = Gitlab::Popen.popen(%w(bundle exec derailed bundle:objects))
+abort 'failed to execute the benchmark' unless status.zero?
+
+File.open(full_report_filename, 'w') do |f|
+ f.write(full_report)
+end
+
+allocated_str = full_report.lines[1]
+retained_str = full_report.lines[2]
+allocated_stats = /Total allocated: (?<bytes>.*) bytes \((?<objects>.*) objects\)/.match(allocated_str)
+retained_stats = /Total retained: (?<bytes>.*) bytes \((?<objects>.*) objects\)/.match(retained_str)
+
+abort 'failed to process the benchmark output' unless allocated_stats && retained_stats
+
+File.open(metrics_filename, 'a') do |f|
+ f.puts "memory_static_objects_allocated_mb #{(allocated_stats[:bytes].to_f / (1024 * 1024)).round(1)}"
+ f.puts "memory_static_objects_retained_mb #{(retained_stats[:bytes].to_f / (104 * 1024)).round(1)}"
+ f.puts "memory_static_objects_allocated_items #{allocated_stats[:objects]}"
+ f.puts "memory_static_objects_retained_items #{retained_stats[:objects]}"
+end