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
35
RMagick, migrate to ImageMagick 7 #RubyKaigi #RubyKaigi2019
watson
0
10k
Magick
watson
0
12k
fastlane 奮闘記
watson
0
99
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
spanner-autoscalerに学ぶ CRD設計パターン 〜自動化と緊急時対応を両立する Kubernetesコントローラーの作り方〜
tkuchiki
0
220
データ品質を壊しながらSnowflakeのAIに分析させてみた
kawanago
0
410
3人で1000GPU超を統合運用する?マルチクラウド&オンプレを跨ぐ、構築と運用のリアル!
kazukun0716
2
820
Snowflake Horizon Catalog と Apache Iceberg で作る オープンなデータ基盤
kitagawaz
0
390
MCPゲートウェイを作って運用してわかったこと — Agent時代の権限管理の現在地
mtpooh
10
2.9k
FinTech 1-2 : Overview of FinTech
ks91
PRO
0
130
「とりあえず動く」の先へ。 AI時代のチーム開発と内部設計/2026-slsdays
slsops
0
110
HolmesGPTで始めるSREエージェント入門!プラットフォームの障害調査はAIにお任せ 〜
leveragestech
PRO
0
140
[2026 Oracle Technical Deep Dive] AI時代のアプリケーションを支えるCloud NativeとJava EEモダナイゼーション (2026年9月17日開催)
oracle4engineer
PRO
0
100
Claude起点の仕様駆動開発
tanakaseiya
0
300
インバスケット試験対策アプリを 作って見えたAIエージェント構築 ナレッジ2選
shichijoyuhi
1
110
Account Factory for Terraformによる 標準化されたアカウント発行の自動化
pensuke628
0
120
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
ラッコキーワード サービス紹介資料
rakko
1
5.1M
The Limits of Empathy - UXLibs8
cassininazir
1
700
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.2k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
540
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
510
HDC tutorial
michielstock
2
940
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
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 !!!