Skip to content

Commit 7935fc5

Browse files
authored
[ruby/sinatra] Add iodine to the tests (#9651)
+--------------+------+-----+-----+------+-------+---------+--------------+ | | json| db|query|update|fortune|plaintext|weighted_score| +--------------+------+-----+-----+------+-------+---------+--------------+ | master| 58048|23085|12225| 5170| 12364| 47186| 775| |sinatra/iodine|103642|41732|31679| 7853| 10708| 100518| 1461| +--------------+------+-----+-----+------+-------+---------+--------------+
1 parent d9e8d81 commit 7935fc5

File tree

6 files changed

+54
-1
lines changed

6 files changed

+54
-1
lines changed

frameworks/Ruby/sinatra/Gemfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ group :postgresql, optional: true do
1212
gem 'pg', '~> 1.5', platforms: [:ruby, :mswin]
1313
end
1414

15+
group :iodine, optional: true do
16+
gem 'iodine', '~> 0.7', platforms: [:ruby, :mswin], require: false
17+
end
18+
1519
group :passenger, optional: true do
1620
gem 'passenger', '~> 6.0', platforms: [:ruby, :mswin], require: false
1721
end
@@ -20,7 +24,7 @@ group :puma, optional: true do
2024
gem 'puma', '~> 6.4', require: false
2125
end
2226

23-
group :unicorn do
27+
group :unicorn, optional: true do
2428
gem 'unicorn', '~> 6.1', platforms: [:ruby, :mswin], require: false
2529
end
2630

frameworks/Ruby/sinatra/Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ GEM
2929
drb (2.2.1)
3030
i18n (1.14.7)
3131
concurrent-ruby (~> 1.0)
32+
iodine (0.7.58)
3233
json (2.10.1)
3334
kgio (2.11.4)
3435
logger (1.6.6)
@@ -81,6 +82,7 @@ PLATFORMS
8182
DEPENDENCIES
8283
activerecord (~> 8.0)
8384
agoo
85+
iodine (~> 0.7)
8486
json (~> 2.8)
8587
mysql2 (~> 0.5)
8688
passenger (~> 6.0)

frameworks/Ruby/sinatra/benchmark_config.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,28 @@
6666
"versus": "rack-postgres-agoo-mri",
6767
"notes": ""
6868
},
69+
"postgres-iodine-mri": {
70+
"json_url": "/json",
71+
"db_url": "/db",
72+
"query_url": "/queries?queries=",
73+
"fortune_url": "/fortunes",
74+
"update_url": "/updates?queries=",
75+
"plaintext_url": "/plaintext",
76+
"port": 8080,
77+
"approach": "Realistic",
78+
"classification": "Micro",
79+
"database": "Postgres",
80+
"framework": "sinatra",
81+
"language": "Ruby",
82+
"orm": "Full",
83+
"platform": "Rack",
84+
"webserver": "Iodine",
85+
"os": "Linux",
86+
"database_os": "Linux",
87+
"display_name": "sinatra-postgres-iodine-mri",
88+
"versus": "rack-postgres-iodine-mri",
89+
"notes": ""
90+
},
6991
"postgres-passenger-mri": {
7092
"db_url": "/db",
7193
"query_url": "/queries?queries=",

frameworks/Ruby/sinatra/boot.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
'puma'
1616
elsif defined?(Unicorn)
1717
'unicorn'
18+
elsif defined?(Iodine)
19+
'iodine'
1820
elsif defined?(Agoo)
1921
'agoo'
2022
end

frameworks/Ruby/sinatra/hello_world.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ class HelloWorld < Sinatra::Base
1010
# XSS, CSRF, IP spoofing, etc. protection are not explicitly required
1111
disable :protection
1212

13+
# disable it for all environments
14+
set :host_authorization, { permitted_hosts: [] }
15+
1316
# Only add the charset parameter to specific content types per the requirements
1417
set :add_charset, [mime_type(:html)]
1518
end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM ruby:3.4
2+
3+
ENV RUBY_YJIT_ENABLE=1
4+
5+
# Use Jemalloc
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends libjemalloc2
8+
ENV LD_PRELOAD=libjemalloc.so.2
9+
10+
ADD ./ /sinatra
11+
WORKDIR /sinatra
12+
13+
ENV BUNDLE_WITH=postgresql:iodine
14+
RUN bundle install --jobs=4 --gemfile=/sinatra/Gemfile
15+
16+
ENV DBTYPE=postgresql
17+
18+
EXPOSE 8080
19+
20+
CMD bundle exec iodine -p 8080 -w $(ruby config/auto_tune.rb | grep -Eo '[0-9]+' | head -n 1)

0 commit comments

Comments
 (0)