Skip to content

Commit aa7f5d2

Browse files
committed
Update commands to use new Dockerhub organization and repository.
1 parent 74ac778 commit aa7f5d2

File tree

4 files changed

+101
-28
lines changed

4 files changed

+101
-28
lines changed

app/jobs/remote_server_job.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def perform(initiator_key, benchmark, options = {})
1717

1818
private
1919

20-
def ruby_bench(ssh, commit_hash, options)
20+
def ruby_trunk(ssh, commit_hash, options)
2121
options.reverse_merge!({ ruby_benchmarks: true, ruby_memory_benchmarks: true })
2222

2323
include_patterns =
@@ -29,15 +29,15 @@ def ruby_bench(ssh, commit_hash, options)
2929

3030
execute_ssh_commands(ssh,
3131
[
32-
"docker pull tgxworld/ruby_bench",
32+
"docker pull rubybench/ruby_trunk",
3333
"docker run --rm
3434
-e \"RUBY_BENCHMARKS=#{options[:ruby_benchmarks]}\"
3535
-e \"RUBY_MEMORY_BENCHMARKS=#{options[:ruby_memory_benchmarks]}\"
3636
-e \"RUBY_COMMIT_HASH=#{commit_hash}\"
3737
-e \"API_NAME=#{Rails.application.secrets.api_name}\"
3838
-e \"API_PASSWORD=#{Rails.application.secrets.api_password}\"
3939
#{include_patterns}
40-
tgxworld/ruby_bench".squish
40+
rubybench/ruby_trunk".squish
4141
]
4242
)
4343
end
@@ -54,23 +54,23 @@ def ruby_releases(ssh, ruby_version, options)
5454

5555
execute_ssh_commands(ssh,
5656
[
57-
"docker pull tgxworld/ruby_releases",
57+
"docker pull rubybench/ruby_releases",
5858
"docker run --rm
5959
-e \"RUBY_BENCHMARKS=#{options[:ruby_benchmarks]}\"
6060
-e \"RUBY_MEMORY_BENCHMARKS=#{options[:ruby_memory_benchmarks]}\"
6161
-e \"RUBY_VERSION=#{ruby_version}\"
6262
-e \"API_NAME=#{Rails.application.secrets.api_name}\"
6363
-e \"API_PASSWORD=#{Rails.application.secrets.api_password}\"
6464
#{include_patterns}
65-
tgxworld/ruby_releases".squish
65+
rubybench/ruby_releases".squish
6666
]
6767
)
6868
end
6969

7070
def ruby_releases_discourse(ssh, ruby_version, options)
7171
execute_ssh_commands(ssh,
7272
[
73-
"docker pull tgxworld/ruby_releases_discourse",
73+
"docker pull rubybench/ruby_releases_discourse",
7474
"docker run --name discourse_redis -d redis:2.8.19",
7575
"docker run --name discourse_postgres -d postgres:9.3.5",
7676
"docker run --rm
@@ -79,7 +79,7 @@ def ruby_releases_discourse(ssh, ruby_version, options)
7979
-e \"RUBY_VERSION=#{ruby_version}\"
8080
-e \"API_NAME=#{Rails.application.secrets.api_name}\"
8181
-e \"API_PASSWORD=#{Rails.application.secrets.api_password}\"
82-
tgxworld/ruby_releases_discourse".squish,
82+
rubybench/ruby_releases_discourse".squish,
8383
"docker stop discourse_postgres discourse_redis",
8484
"docker rm discourse_postgres discourse_redis"
8585
]
@@ -89,31 +89,31 @@ def ruby_releases_discourse(ssh, ruby_version, options)
8989
def discourse_rails_head_bench(ssh, commit_hash, options)
9090
execute_ssh_commands(ssh,
9191
[
92-
"docker pull tgxworld/discourse_rails_head_bench",
92+
"docker pull rubybench/discourse_rails_head_bench",
9393
"docker run --name discourse_redis -d redis:2.8.19",
9494
"docker run --name discourse_postgres -d postgres:9.3.5",
9595
"docker run --rm --link discourse_postgres:postgres
9696
--link discourse_redis:redis -e \"RAILS_COMMIT_HASH=#{commit_hash}\"
9797
-e \"API_NAME=#{Rails.application.secrets.api_name}\"
9898
-e \"API_PASSWORD=#{Rails.application.secrets.api_password}\"
99-
tgxworld/discourse_rails_head_bench".squish,
99+
rubybench/discourse_rails_head_bench".squish,
100100
"docker stop discourse_postgres discourse_redis",
101101
"docker rm discourse_postgres discourse_redis"
102102
]
103103
)
104104
end
105105

106-
def ruby_bench_discourse(ssh, commit_hash, options)
106+
def ruby_trunk_discourse(ssh, commit_hash, options)
107107
execute_ssh_commands(ssh,
108108
[
109-
"docker pull tgxworld/ruby_bench_discourse",
109+
"docker pull rubybench/ruby_trunk_discourse",
110110
"docker run --name discourse_redis -d redis:2.8.19",
111111
"docker run --name discourse_postgres -d postgres:9.3.5",
112112
"docker run --rm --link discourse_postgres:postgres
113113
--link discourse_redis:redis -e \"RUBY_COMMIT_HASH=#{commit_hash}\"
114114
-e \"API_NAME=#{Rails.application.secrets.api_name}\"
115115
-e \"API_PASSWORD=#{Rails.application.secrets.api_password}\"
116-
tgxworld/ruby_bench_discourse".squish,
116+
rubybench/ruby_trunk_discourse".squish,
117117
"docker stop discourse_postgres discourse_redis",
118118
"docker rm discourse_postgres discourse_redis"
119119
]

config/initializers/github_event_subscribers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ActiveSupport::Notifications.subscribe('ruby') do |name, start, finish, id, payload|
2-
RemoteServerJob.perform_later(payload[:commit_sha1], 'ruby_bench')
3-
RemoteServerJob.perform_later(payload[:commit_sha1], 'ruby_bench_discourse')
2+
RemoteServerJob.perform_later(payload[:commit_sha1], 'ruby_trunk')
3+
RemoteServerJob.perform_later(payload[:commit_sha1], 'ruby_trunk_discourse')
44
end
55

66
ActiveSupport::Notifications.subscribe('rails') do |name, start, finish, id, payload|

rails_memory_bench.rb

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
require "net/http"
2+
3+
def start_server
4+
# Remove the X to enable the parameters for tuning.
5+
# These are the default values as of Ruby 2.2.0.
6+
@child = spawn(<<-EOC.split.join(" "))
7+
RUBY_GC_HEAP_FREE_SLOTS=4096
8+
RUBY_GC_HEAP_INIT_SLOTS=10000
9+
RUBY_GC_HEAP_GROWTH_FACTOR=1.8
10+
RUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
11+
RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=2.0
12+
RUBY_GC_MALLOC_LIMIT=16777216
13+
RUBY_GC_MALLOC_LIMIT_MAX=33554432
14+
RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.4
15+
RUBY_GC_OLDMALLOC_LIMIT=16777216
16+
RUBY_GC_OLDMALLOC_LIMIT_MAX=134217728
17+
RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR=1.2
18+
rails server > /dev/null
19+
EOC
20+
sleep 5
21+
end
22+
23+
def alive?
24+
system("curl localhost:3000 &> /dev/null")
25+
end
26+
27+
def stop_server
28+
Process.kill "HUP", server_pid
29+
Process.wait @child
30+
end
31+
32+
def server_pid
33+
`cat tmp/pids/server.pid`.to_i
34+
end
35+
36+
def memory_size_mb
37+
(`ps -o rss= -p #{server_pid}`.to_i * 1024).to_f / 2**20
38+
end
39+
40+
def do_request
41+
uri = URI("http://localhost:3000/ruby/ruby/commits?result_type=discourse_categories&display_count=1000")
42+
req = Net::HTTP::Get.new(uri)
43+
44+
Net::HTTP.start("localhost", uri.port) do |http|
45+
http.read_timeout = 60
46+
http.request(req)
47+
end
48+
end
49+
50+
results = []
51+
52+
# You can’t just measure once: memory usage has some variance.
53+
# We will take the mean of 7 runs.
54+
1.times do
55+
start_server
56+
57+
used_mb = nil
58+
(1..50).map do |n|
59+
print "Request #{n}..."
60+
do_request
61+
used_mb = memory_size_mb
62+
puts "#{used_mb} MB"
63+
end
64+
65+
final_mb = used_mb
66+
results << final_mb
67+
puts "Final Memory: #{final_mb} MB"
68+
69+
stop_server
70+
end
71+
72+
# mean_final_mb = results.reduce(:+) / results.size
73+
# puts "Mean Final Memory: #{mean_final_mb} MB"

test/jobs/remote_server_job_test.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ class RemoteServerJobTest < ActiveJob::TestCase
66
Net::SSH.stubs(:start).yields(@ssh)
77
end
88

9-
test "#perform ruby_bench" do
9+
test "#perform ruby_trunk" do
1010
[
11-
'tsp docker pull tgxworld/ruby_bench',
11+
'tsp docker pull rubybench/ruby_trunk',
1212
"tsp docker run --rm
1313
-e \"RUBY_BENCHMARKS=true\"
1414
-e \"RUBY_MEMORY_BENCHMARKS=false\"
1515
-e \"RUBY_COMMIT_HASH=commit_hash\"
1616
-e \"API_NAME=#{Rails.application.secrets.api_name}\"
1717
-e \"API_PASSWORD=#{Rails.application.secrets.api_password}\"
1818
-e \"INCLUDE_PATTERNS=bm_app_answer,bm_abc\"
19-
tgxworld/ruby_bench".squish
19+
rubybench/ruby_trunk".squish
2020
].each do |command|
2121

2222
@ssh.expects(:exec!).with(command)
2323
end
2424

2525
RemoteServerJob.new.perform(
26-
'commit_hash', 'ruby_bench',
26+
'commit_hash', 'ruby_trunk',
2727
{
2828
ruby_benchmarks: true, ruby_memory_benchmarks: false,
2929
include_patterns: 'bm_app_answer,bm_abc'
@@ -33,15 +33,15 @@ class RemoteServerJobTest < ActiveJob::TestCase
3333

3434
test "#perform ruby_releases" do
3535
[
36-
'tsp docker pull tgxworld/ruby_releases',
36+
'tsp docker pull rubybench/ruby_releases',
3737
"tsp docker run --rm
3838
-e \"RUBY_BENCHMARKS=true\"
3939
-e \"RUBY_MEMORY_BENCHMARKS=false\"
4040
-e \"RUBY_VERSION=2.2.0\"
4141
-e \"API_NAME=#{Rails.application.secrets.api_name}\"
4242
-e \"API_PASSWORD=#{Rails.application.secrets.api_password}\"
4343
-e \"INCLUDE_PATTERNS=bm_app_answer,bm_abc\"
44-
tgxworld/ruby_releases".squish
44+
rubybench/ruby_releases".squish
4545
].each do |command|
4646

4747
@ssh.expects(:exec!).with(command)
@@ -58,7 +58,7 @@ class RemoteServerJobTest < ActiveJob::TestCase
5858

5959
test "#perform ruby_releases_discourse" do
6060
[
61-
"tsp docker pull tgxworld/ruby_releases_discourse",
61+
"tsp docker pull rubybench/ruby_releases_discourse",
6262
"tsp docker run --name discourse_redis -d redis:2.8.19",
6363
"tsp docker run --name discourse_postgres -d postgres:9.3.5",
6464
"tsp docker run --rm
@@ -67,7 +67,7 @@ class RemoteServerJobTest < ActiveJob::TestCase
6767
-e \"RUBY_VERSION=2.2.0\"
6868
-e \"API_NAME=#{Rails.application.secrets.api_name}\"
6969
-e \"API_PASSWORD=#{Rails.application.secrets.api_password}\"
70-
tgxworld/ruby_releases_discourse".squish,
70+
rubybench/ruby_releases_discourse".squish,
7171
"tsp docker stop discourse_postgres discourse_redis",
7272
"tsp docker rm discourse_postgres discourse_redis"
7373
].each do |command|
@@ -80,14 +80,14 @@ class RemoteServerJobTest < ActiveJob::TestCase
8080

8181
test "#perform discourse_rails_head_bench" do
8282
[
83-
"tsp docker pull tgxworld/discourse_rails_head_bench",
83+
"tsp docker pull rubybench/discourse_rails_head_bench",
8484
"tsp docker run --name discourse_redis -d redis:2.8.19",
8585
"tsp docker run --name discourse_postgres -d postgres:9.3.5",
8686
"tsp docker run --rm --link discourse_postgres:postgres
8787
--link discourse_redis:redis -e \"RAILS_COMMIT_HASH=commit_hash\"
8888
-e \"API_NAME=#{Rails.application.secrets.api_name}\"
8989
-e \"API_PASSWORD=#{Rails.application.secrets.api_password}\"
90-
tgxworld/discourse_rails_head_bench".squish,
90+
rubybench/discourse_rails_head_bench".squish,
9191
"tsp docker stop discourse_postgres discourse_redis",
9292
"tsp docker rm discourse_postgres discourse_redis"
9393
].each do |command|
@@ -98,23 +98,23 @@ class RemoteServerJobTest < ActiveJob::TestCase
9898
RemoteServerJob.new.perform('commit_hash', 'discourse_rails_head_bench')
9999
end
100100

101-
test "#perform ruby_bench_discourse" do
101+
test "#perform ruby_trunk_discourse" do
102102
[
103-
"tsp docker pull tgxworld/ruby_bench_discourse",
103+
"tsp docker pull rubybench/ruby_trunk_discourse",
104104
"tsp docker run --name discourse_redis -d redis:2.8.19",
105105
"tsp docker run --name discourse_postgres -d postgres:9.3.5",
106106
"tsp docker run --rm --link discourse_postgres:postgres
107107
--link discourse_redis:redis -e \"RUBY_COMMIT_HASH=commit_hash\"
108108
-e \"API_NAME=#{Rails.application.secrets.api_name}\"
109109
-e \"API_PASSWORD=#{Rails.application.secrets.api_password}\"
110-
tgxworld/ruby_bench_discourse".squish,
110+
rubybench/ruby_trunk_discourse".squish,
111111
"tsp docker stop discourse_postgres discourse_redis",
112112
"tsp docker rm discourse_postgres discourse_redis"
113113
].each do |command|
114114

115115
@ssh.expects(:exec!).with(command)
116116
end
117117

118-
RemoteServerJob.new.perform('commit_hash', 'ruby_bench_discourse')
118+
RemoteServerJob.new.perform('commit_hash', 'ruby_trunk_discourse')
119119
end
120120
end

0 commit comments

Comments
 (0)