Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Improve JSON Performance
Search
Watson
May 31, 2018
Technology
1.1k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Improve JSON Performance
Watson
May 31, 2018
More Decks by Watson
See All by Watson
クラウドネイティブ時代に 進化し続けるFluentd
watson
0
41
RMagick, migrate to ImageMagick 7 #RubyKaigi #RubyKaigi2019
watson
0
10k
Magick
watson
0
12k
fastlane 奮闘記
watson
0
100
How to optimize Ruby internal.
watson
3
3.1k
iOS、AndroidアプリをRubyで
watson
1
520
RubyMotion 2.0
watson
6
2.9k
Differences CRuby/MacRuby/RubyMotion
watson
5
5.8k
Other Decks in Technology
See All in Technology
自律的なチームを作るためにTechPMがやらないこと
ny7760
0
340
Devin プロモコードの受け取りと適用(2026.10.27)
kinopeee
1
770
AI AgentによるEmbedded SREの取り組み
tgidgd
1
300
Flutter Widget Previewerで始めるUIプレビューとVRTの自動化
sakusaku3939
0
190
LLMの知識とAIエージェント
happysamurai294
0
140
ビジネス部門からPOを迎えての半年間の進歩と課題
zozotech
PRO
0
170
Obsidian Vault Architectures
x5gtrn
PRO
0
220
なぜ東京にいる私が、新潟の技術コミュニティを運営するのか by 八雲慎之助
yakumo
0
210
Claude Codeから見る、エンジニアの世界の変容とその先
oikon48
8
5k
GitHub、使う?使わない?
happysamurai294
0
130
データマネジメント × 法務で作りあげる、 freeeの新しいデータガバナンスへの軌跡
freee
PRO
3
590
素人でもできた!AIを使った短編小説創作入門
delhi09
PRO
0
270
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Thoughts on Productivity
jonyablonski
76
5.4k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
290
Faster Mobile Websites
deanohume
310
32k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
2
970
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
310
Paper Plane
katiecoart
PRO
5
54k
Product Roadmaps are Hard
iamctodd
55
13k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
640
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
460
Site-Speed That Sticks
csswizardry
13
1.6k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.7k
Transcript
*NQSPWF+40/ 1FSGPSNBODF Shizuo Fujita
Self @watson1978 Ubiregi Inc. Ruby committer
JSON.parse()
None
Parsed Hash object require 'json' json =<<'END' { "id": 1,
"uuid": "ede84c89-3e5a-4025-a8d4-8c66cfed1820", "created_at": "2018-05-27 22:54:55 +0900" } END JSON.parse(json) # => {"id"=>1, # "uuid"=>"ede84c89-3e5a-4025-a8d4-8c66cfed1820", # "created_at"=>"2018-05-27 22:54:55 +0900"} Hash object has String keys.
Hash freezes string key Duplicate and freeze the string if
it isn’t frozen…
Remove redundant duplication Hash#[]= with frozen string key, you can
remove redundant duplication of string in internally
Benchmark obj = [] 1000.times do |i| obj << {
"id": i, "uuid": SecureRandom.uuid, "created_at": Time.now } end json = obj.to_json Benchmark.ips do |x| x.report("json") { JSON.parse(json) } x.report("yajl") { Yajl::Parser.parse(json) } x.report("oj") { Oj.load(json) } end
KTPO CFGPSF ZBKM KTPO BGUFS
PK VQ Before After
JSON.generate() (i.e. Object#to_json)
None
1. Remove redundant converting array = hash.keys array.each do |key|
value = hash[key] ... end hash.each do |key, value| ... end Before After Here is pseudo code…
2. Add shortcut for converting to String for Hash key
Before it always convert Object to String using #to_s via rb_funcall(). After It convert with appropriate CRuby-API if necessary.
3. Call CRuby-API instead of rb_funcall rb_funcall() is slightly heavy
to call the Ruby method. It is better performance to use rb_str_encode() API instead.
4. Convert encoding only when needed If String object has
only ASCII characters, it might not need to convert encoding.
Benchmark obj = [] 1000.times do |i| obj << {
"id" => i, :age => 42, :name => "Foo Bar Baz" } end Benchmark.ips do |x| x.report("json") { JSON.generate(obj) } x.report("yajl") { Yajl::Encoder.encode(obj, nil) } x.report("oj") { Oj.dump(obj) } end
KTPO CFGPSF ZBKM KTPO BGUFS
PK YVQ Before After
⚠
Not merged, No reaction Can you help me? https://github.com/flori/json/pull/345 https://github.com/flori/json/pull/346
Thank you !!!