Skip to content

Commit efef796

Browse files
authored
[ruby/rack] Use regular json serializer (#9394)
The regular json serializer should be about as fast as OJ, after some recent performance improvements: https://github.com/ruby/json/blob/master/CHANGES.md
1 parent 7b79969 commit efef796

11 files changed

+71
-63
lines changed

frameworks/Ruby/rack-sequel/Gemfile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
source 'https://rubygems.org'
22

3-
gem 'base64' # required by passenger on Ruby 3.4
4-
gem 'json', '~> 2.0'
5-
gem 'oj', '~> 3.14', platforms: %i[ruby mswin]
6-
gem 'passenger', '~> 6.0', platforms: [:ruby, :mswin], require: false
7-
gem 'puma', '~> 6.4', require: false
3+
gem 'json', '~> 2.8'
84
gem 'sequel', '~> 5.0'
95
gem 'rack', '~> 3.0'
10-
gem 'unicorn', '~> 6.1', platforms: [:ruby, :mswin], require: false
116

127
group :mysql do
138
gem 'jdbc-mysql', '~> 5.1', platforms: :jruby, require: 'jdbc/mysql'
@@ -19,3 +14,16 @@ group :postgresql do
1914
gem 'pg', '~> 1.5', platforms: [:ruby, :mswin]
2015
gem 'sequel_pg', '~> 1.6', platforms: :ruby, require: false
2116
end
17+
18+
group :passenger do
19+
gem 'base64' # required by passenger on Ruby 3.4
20+
gem 'passenger', '~> 6.0', platforms: [:ruby, :mswin], require: false
21+
end
22+
23+
group :puma do
24+
gem 'puma', '~> 6.4', require: false
25+
end
26+
27+
group :unicorn do
28+
gem 'unicorn', '~> 6.1', platforms: [:ruby, :mswin], require: false
29+
end

frameworks/Ruby/rack-sequel/hello_world.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'oj'
4-
Oj.mimic_JSON
5-
63
# Our Rack application to be executed by rackup
74
class HelloWorld
85
DEFAULT_HEADERS = {}.tap do |h|

frameworks/Ruby/rack-sequel/rack-sequel-passenger-mri.dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN apt-get update && \
1111
apt-get install -y --no-install-recommends libjemalloc2
1212
ENV LD_PRELOAD=libjemalloc.so.2
1313

14+
RUN bundle config set without 'postgresql puma unicorn'
1415
RUN bundle install --jobs=4 --gemfile=/rack-sequel/Gemfile
1516

1617
# TODO: https://github.com/phusion/passenger/issues/1916

frameworks/Ruby/rack-sequel/rack-sequel-postgres-passenger-mri.dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN apt-get update && \
1111
apt-get install -y --no-install-recommends libjemalloc2
1212
ENV LD_PRELOAD=libjemalloc.so.2
1313

14+
RUN bundle config set without 'mysql puma unicorn'
1415
RUN bundle install --jobs=4 --gemfile=/rack-sequel/Gemfile
1516

1617
# TODO: https://github.com/phusion/passenger/issues/1916

frameworks/Ruby/rack-sequel/rack-sequel-postgres-unicorn-mri.dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN apt-get update && \
1111
apt-get install -y --no-install-recommends libjemalloc2
1212
ENV LD_PRELOAD=libjemalloc.so.2
1313

14+
RUN bundle config set without 'mysql passenger puma'
1415
RUN bundle install --jobs=4 --gemfile=/rack-sequel/Gemfile
1516

1617
ENV DBTYPE=postgresql

frameworks/Ruby/rack-sequel/rack-sequel-postgres.dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN apt-get update && \
1111
apt-get install -y --no-install-recommends libjemalloc2
1212
ENV LD_PRELOAD=libjemalloc.so.2
1313

14+
RUN bundle config set without 'mysql passenger unicorn'
1415
RUN bundle install --jobs=4 --gemfile=/rack-sequel/Gemfile
1516

1617
ENV DBTYPE=postgresql

frameworks/Ruby/rack-sequel/rack-sequel-unicorn-mri.dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN apt-get update && \
1111
apt-get install -y --no-install-recommends libjemalloc2
1212
ENV LD_PRELOAD=libjemalloc.so.2
1313

14+
RUN bundle config set without 'postgresql passenger puma'
1415
RUN bundle install --jobs=4 --gemfile=/rack-sequel/Gemfile
1516

1617
ENV DBTYPE=mysql

frameworks/Ruby/rack-sequel/rack-sequel.dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN apt-get update && \
1111
apt-get install -y --no-install-recommends libjemalloc2
1212
ENV LD_PRELOAD=libjemalloc.so.2
1313

14+
RUN bundle config set without 'postgresql passenger unicorn'
1415
RUN bundle install --jobs=4 --gemfile=/rack-sequel/Gemfile
1516

1617
ENV DBTYPE=mysql

frameworks/Ruby/rack/Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ source 'https://rubygems.org'
55
gem 'rack', '~> 3.0'
66
gem 'connection_pool', '~> 2.4'
77
gem 'jdbc-postgres', '~> 42.2', platforms: :jruby, require: 'jdbc/postgres'
8-
gem 'json', '~> 2.6', platforms: :jruby
9-
gem 'oj', '~> 3.14', platforms: %i[ruby mswin]
8+
gem 'json', '~> 2.8'
109
gem 'pg', '~> 1.5', platforms: %i[ruby mswin]
1110
gem 'sequel'
1211
gem 'sequel_pg', platforms: %i[ruby mswin]

frameworks/Ruby/rack/Gemfile.lock

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,119 +2,120 @@ GEM
22
remote: https://rubygems.org/
33
specs:
44
ast (2.4.2)
5-
async (2.12.1)
6-
console (~> 1.25, >= 1.25.2)
5+
async (2.20.0)
6+
console (~> 1.29)
77
fiber-annotation
88
io-event (~> 1.6, >= 1.6.5)
9-
async-container (0.18.2)
9+
async-container (0.18.3)
1010
async (~> 2.10)
11-
async-http (0.69.0)
11+
async-http (0.83.1)
1212
async (>= 2.10.2)
13-
async-pool (~> 0.7)
14-
io-endpoint (~> 0.11)
15-
io-stream (~> 0.4)
16-
protocol-http (~> 0.26)
17-
protocol-http1 (~> 0.19)
18-
protocol-http2 (~> 0.18)
19-
traces (>= 0.10)
20-
async-http-cache (0.4.3)
13+
async-pool (~> 0.9)
14+
io-endpoint (~> 0.14)
15+
io-stream (~> 0.6)
16+
metrics (~> 0.12)
17+
protocol-http (~> 0.43)
18+
protocol-http1 (>= 0.28.1)
19+
protocol-http2 (~> 0.19)
20+
traces (~> 0.10)
21+
async-http-cache (0.4.4)
2122
async-http (~> 0.56)
22-
async-pool (0.7.0)
23+
async-pool (0.10.1)
2324
async (>= 1.25)
25+
traces
2426
async-service (0.12.0)
2527
async
2628
async-container (~> 0.16)
2729
bigdecimal (3.1.8)
28-
concurrent-ruby (1.3.3)
30+
concurrent-ruby (1.3.4)
2931
connection_pool (2.4.1)
30-
console (1.25.2)
32+
console (1.29.0)
3133
fiber-annotation
3234
fiber-local (~> 1.1)
3335
json
34-
falcon (0.47.7)
36+
falcon (0.48.3)
3537
async
3638
async-container (~> 0.18)
37-
async-http (~> 0.66, >= 0.66.3)
38-
async-http-cache (~> 0.4.0)
39+
async-http (~> 0.75)
40+
async-http-cache (~> 0.4)
3941
async-service (~> 0.10)
4042
bundler
4143
localhost (~> 1.1)
4244
openssl (~> 3.0)
43-
process-metrics (~> 0.2.0)
44-
protocol-rack (~> 0.5)
45+
process-metrics (~> 0.2)
46+
protocol-http (~> 0.31)
47+
protocol-rack (~> 0.7)
4548
samovar (~> 2.3)
4649
fiber-annotation (0.2.0)
4750
fiber-local (1.1.0)
4851
fiber-storage
49-
fiber-storage (0.1.2)
50-
io-endpoint (0.11.0)
51-
io-event (1.6.5)
52-
io-stream (0.4.0)
52+
fiber-storage (1.0.0)
53+
io-endpoint (0.14.0)
54+
io-event (1.7.3)
55+
io-stream (0.6.1)
5356
json (2.8.2)
5457
kgio (2.11.4)
5558
language_server-protocol (3.17.0.3)
5659
localhost (1.3.1)
5760
mapping (1.1.1)
61+
metrics (0.12.1)
5862
nio4r (2.7.4)
59-
oj (3.16.4)
60-
bigdecimal (>= 3.0)
6163
openssl (3.2.0)
62-
parallel (1.25.1)
63-
parser (3.3.3.0)
64+
parallel (1.26.3)
65+
parser (3.3.6.0)
6466
ast (~> 2.4.1)
6567
racc
66-
pg (1.5.6)
67-
process-metrics (0.2.1)
68+
pg (1.5.9)
69+
process-metrics (0.3.0)
6870
console (~> 1.8)
71+
json (~> 2)
6972
samovar (~> 2.1)
70-
protocol-hpack (1.4.3)
71-
protocol-http (0.26.6)
72-
protocol-http1 (0.19.1)
73+
protocol-hpack (1.5.1)
74+
protocol-http (0.43.0)
75+
protocol-http1 (0.28.1)
7376
protocol-http (~> 0.22)
74-
protocol-http2 (0.18.0)
77+
protocol-http2 (0.20.0)
7578
protocol-hpack (~> 1.4)
7679
protocol-http (~> 0.18)
77-
protocol-rack (0.6.0)
78-
protocol-http (~> 0.23)
80+
protocol-rack (0.11.0)
81+
protocol-http (~> 0.43)
7982
rack (>= 1.0)
8083
puma (6.5.0)
8184
nio4r (~> 2.0)
82-
racc (1.8.0)
83-
rack (3.1.6)
85+
racc (1.8.1)
86+
rack (3.1.8)
8487
rack-test (2.1.0)
8588
rack (>= 1.3)
8689
rainbow (3.1.1)
8790
raindrops (0.20.1)
8891
regexp_parser (2.9.2)
89-
rexml (3.3.9)
90-
rubocop (1.64.1)
92+
rubocop (1.68.0)
9193
json (~> 2.3)
9294
language_server-protocol (>= 3.17.0)
9395
parallel (~> 1.10)
9496
parser (>= 3.3.0.2)
9597
rainbow (>= 2.2.2, < 4.0)
96-
regexp_parser (>= 1.8, < 3.0)
97-
rexml (>= 3.2.5, < 4.0)
98-
rubocop-ast (>= 1.31.1, < 2.0)
98+
regexp_parser (>= 2.4, < 3.0)
99+
rubocop-ast (>= 1.32.2, < 2.0)
99100
ruby-progressbar (~> 1.7)
100101
unicode-display_width (>= 2.4.0, < 3.0)
101-
rubocop-ast (1.31.3)
102+
rubocop-ast (1.35.0)
102103
parser (>= 3.3.1.0)
103104
ruby-progressbar (1.13.0)
104105
samovar (2.3.0)
105106
console (~> 1.0)
106107
mapping (~> 1.0)
107-
sequel (5.82.0)
108+
sequel (5.86.0)
108109
bigdecimal
109110
sequel_pg (1.17.1)
110111
pg (>= 0.18.0, != 1.2.0)
111112
sequel (>= 4.38.0)
112-
traces (0.11.1)
113+
traces (0.14.1)
113114
tzinfo (2.0.6)
114115
concurrent-ruby (~> 1.0)
115116
tzinfo-data (1.2023.3)
116117
tzinfo (>= 1.0.0)
117-
unicode-display_width (2.5.0)
118+
unicode-display_width (2.6.0)
118119
unicorn (6.1.0)
119120
kgio (~> 2.6)
120121
raindrops (~> 0.7)
@@ -127,8 +128,7 @@ DEPENDENCIES
127128
connection_pool (~> 2.4)
128129
falcon (~> 0.47)
129130
jdbc-postgres (~> 42.2)
130-
json (~> 2.6)
131-
oj (~> 3.14)
131+
json (~> 2.8)
132132
pg (~> 1.5)
133133
puma (~> 6.4)
134134
rack (~> 3.0)

0 commit comments

Comments
 (0)