Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
今すぐできる、ユーザーとチームのためのiOS速度改善 / Gunosy Kaizen Nigh...
Search
Seiji Takahashi
August 10, 2017
Programming
1
5.2k
今すぐできる、ユーザーとチームのためのiOS速度改善 / Gunosy Kaizen Night iOS development optimization
Gunosy カイゼン Night #1の発表資料です。
Seiji Takahashi
August 10, 2017
Tweet
Share
More Decks by Seiji Takahashi
See All by Seiji Takahashi
Go Backends for frontends with GraphQL and gRPC
timakin
6
3.7k
Design Pattern for Image and Text Composition in Go
timakin
5
6.5k
Golang API Testing the HARD way
timakin
13
6.4k
Head First Golang Image Package
timakin
2
9.9k
React Native Beyond Prototype
timakin
2
1.6k
Performance Optimization on Google AppEngine
timakin
5
6.1k
testcache.pdf
timakin
1
120
How Go cache
timakin
1
63
How Go cache tests
timakin
1
2.9k
Other Decks in Programming
See All in Programming
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
110
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Contemporary Test Cases
maaretp
0
140
役立つログに取り組もう
irof
28
9.6k
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
初めてDefinitelyTypedにPRを出した話
syumai
0
410
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Jakarta EE meets AI
ivargrimstad
0
170
C++でシェーダを書く
fadis
6
4.1k
Ethereum_.pdf
nekomatu
0
460
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Automating Front-end Workflow
addyosmani
1366
200k
Bash Introduction
62gerente
608
210k
Fireside Chat
paigeccino
34
3k
The Invisible Side of Design
smashingmag
298
50k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Transcript
ࠓ͙͢Ͱ͖Δɺ ϢʔβʔͱνʔϜͷͨΊͷ iOSվળ @__timakin__ / Gunosy ΧΠθϯ Night #1
ࣗݾհ • Github: timakin / Twitter: @__timakin__ • Contributor of
Go / golang.tokyo / roppongi-golunch • Gunosy ৽نࣄۀ։ൃࣨ ॴଐ • Go / Swift • Recently Contributed / Created • giginet/xcprofiler • mercari/gaurun • timakin/gopli • timakin/ssm2env • timakin/md2mid • timakin/autocompl
߹ΘͤͯಡΈ͍ͨ https://speakerdeck.com/timakin/maikurotimudefalsegao-su-naxin-gui-kai-fa-wozhi-erukai-fa-fen-xi-ji-pan
ࠓ͢͜ͱ • iOS(Swift)։ൃͷΧΠθϯ • ϢʔβʔͷͨΊͷΧΠθϯ • νʔϜͷͨΊͷΧΠθϯ
Goͷɺ ͠·ͤΜʂ
Swift(iOSΞϓϦ)ྺ 3ϲ݄
ؒҧͬͯΔ͋Δ͔Ͱ͕͢ɺ ΑΖ͓͘͠ئ͍͠·͢ʂ
ͦͦͳΜͰ վળ͕ඞཁ͔ʁ
͍ͱԿ͕ى͜Δʁ
͍ͱى͜Δ͜ͱɿΞϓϦମݧฤ • ਓੜແବײ͋ͬͯΞϓϦΘͳ͘ͳΔ
͍ͱى͜Δ͜ͱɿΞϓϦମݧฤ • ਓੜແବײ͋ͬͯΞϓϦΘͳ͘ͳΔ • ࡶΞϓϦײ͋ͬͯ։ൃνʔϜͷαϙʔτ͕ෆ҆
• ਓੜແବײ͋ͬͯΞϓϦΘͳ͘ͳΔ • ࡶΞϓϦײ͋ͬͯ։ൃνʔϜͷαϙʔτ͕ෆ҆ • ใ͕ܽམͯ͠Πϥͭ͘ ͍ͱى͜Δ͜ͱɿΞϓϦମݧฤ
• ਓੜແବײ͋ͬͯΞϓϦΘͳ͘ͳΔ • ࡶΞϓϦײ͋ͬͯ։ൃνʔϜͷαϙʔτ͕ෆ҆ • ใ͕ܽམͯ͠Πϥͭ͘ • ͬͯΔؒʹbackground -> ଞͷΞϓϦʹભҠ͠
ͯΔͷΕΔ ͍ͱى͜Δ͜ͱɿΞϓϦମݧฤ
• ਓੜແବײ͋ͬͯΞϓϦΘͳ͘ͳΔ • ࡶΞϓϦײ͋ͬͯ։ൃνʔϜͷαϙʔτ͕ෆ҆ • ใ͕ܽམͯ͠Πϥͭ͘ • ͬͯΔؒʹbackground -> ଞͷΞϓϦʹભҠ͠
ͯΔͷΕΔ • ڝ߹ΞϓϦͱѱ͍ΛൺΒΕΔධՁϦεΫ ͍ͱى͜Δ͜ͱɿΞϓϦମݧฤ
• ਓੜແବײ͋ͬͯΞϓϦΘͳ͘ͳΔ • ࡶΞϓϦײ͋ͬͯ։ൃνʔϜͷαϙʔτ͕ෆ҆ • ใ͕ܽམͯ͠Πϥͭ͘ • ͬͯΔؒʹbackground -> ଞͷΞϓϦʹભҠ͠
ͯΔͷΕΔ • ڝ߹ΞϓϦͱѱ͍ΛൺΒΕΔධՁϦεΫ • αʔϏεͷࢮ ͍ͱى͜Δ͜ͱɿΞϓϦମݧฤ
• ແҙࣝʹ࿘අ͞ΕΔ࣌ؒ ͍ͱى͜Δ͜ͱɿ։ൃฤ
• ແҙࣝʹ࿘අ͞ΕΔ࣌ؒ • ΟϯυҠͬͯɺ͕ͯूத్͕ΕΔ ͍ͱى͜Δ͜ͱɿ։ൃฤ
• ແҙࣝʹ࿘අ͞ΕΔ࣌ؒ • ΟϯυҠͬͯɺ͕ͯूத్͕ΕΔ • ͖ͬͯͯ࡞ۀΛࢥ͍ग़͢ͷʹίϯςΩετεΠο νͷίετ͕͔͔Δ ͍ͱى͜Δ͜ͱɿ։ൃฤ
• ແҙࣝʹ࿘අ͞ΕΔ࣌ؒ • ΟϯυҠͬͯɺ͕ͯूத్͕ΕΔ • ͖ͬͯͯ࡞ۀΛࢥ͍ग़͢ͷʹίϯςΩετεΠο νͷίετ͕͔͔Δ • ݕূʹऔΕΔ͕࣌ؒݮΔ ͍ͱى͜Δ͜ͱɿ։ൃฤ
• ແҙࣝʹ࿘අ͞ΕΔ࣌ؒ • ΟϯυҠͬͯɺ͕ͯूத్͕ΕΔ • ͖ͬͯͯ࡞ۀΛࢥ͍ग़͢ͷʹίϯςΩετεΠο νͷίετ͕͔͔Δ • ݕূʹऔΕΔ͕࣌ؒݮΔ •
ϦϦʔε͕ΕΔ ͍ͱى͜Δ͜ͱɿ։ൃฤ
• ແҙࣝʹ࿘අ͞ΕΔ࣌ؒ • ΟϯυҠͬͯɺ͕ͯूத్͕ΕΔ • ͖ͬͯͯ࡞ۀΛࢥ͍ग़͢ͷʹίϯςΩετεΠο νͷίετ͕͔͔Δ • ݕূʹऔΕΔ͕࣌ؒݮΔ •
ϦϦʔε͕ΕΔ • Πέͯͳ͍։ൃνʔϜʹͳͬͯਓݺͳ͍ ͍ͱى͜Δ͜ͱɿ։ൃฤ
• ແҙࣝʹ࿘අ͞ΕΔ࣌ؒ • ΟϯυҠͬͯɺ͕ͯूத్͕ΕΔ • ͖ͬͯͯ࡞ۀΛࢥ͍ग़͢ͷʹίϯςΩετεΠο νͷίετ͕͔͔Δ • ݕূʹऔΕΔ͕࣌ؒݮΔ •
ϦϦʔε͕ΕΔ • Πέͯͳ͍։ൃνʔϜʹͳͬͯਓݺͳ͍ • αʔϏεͷࢮ ͍ͱى͜Δ͜ͱɿ։ൃฤ
• ͱʹ͔͘ࢮ͵ ͍ͱى͜Δ͜ͱɿ·ͱΊ
୭ͷͨΊʹ͘͢Δ͔
1. Ϣʔβʔ
2. νʔϜ
ϢʔβʔͷͨΊͷվળ • ىಈվળͷ͠·͢
https://developer.apple.com/videos/play/ wwdc2016/406/
https://developer.apple.com/videos/play/ wwdc2017/413/
ϢʔβʔͷͨΊͷվળ • ىಈ͕͘ͳΔݪҼ • ىಈΛܭଌ͢Δํ๏ • վળํ๏
ىಈ͕͘ͳΔݪҼ • Too many dylibs
ىಈ͕͘ͳΔݪҼ • Too many dylibs • Too many class/method declarations
• Too many dylibs • Too many class/method declarations •
Too many initializers ىಈ͕͘ͳΔݪҼ
• Too many dylibs • Too many class/method declarations •
Too many initializers • SDK ىಈ͕͘ͳΔݪҼ
• Too many dylibs • Too many class/method declarations •
Too many initializers • SDK • API Call ىಈ͕͘ͳΔݪҼ
• Too many dylibs • Too many class/method declarations •
Too many initializers • SDK • API Call • Middleware ىಈ͕͘ͳΔݪҼ
• ࣌ؒͷ͔͔ΔॲཧdaemonͰ Dyld3
• ࣌ؒͷ͔͔ΔॲཧdaemonͰ • ෳࡶͳॲཧ(Mach-O parse/compile) શ෦ͦͬͪʹدͤΔ Dyld3
• ࣌ؒͷ͔͔ΔॲཧdaemonͰ • ෳࡶͳॲཧ(Mach-O parse/compile) શ෦ͦͬͪʹدͤΔ • launch closure caching
Dyld3
ىಈܭଌ • Instruments • Time Profiler
ىಈܭଌ • Instruments • Time Profiler • Static Initializer Calls
(iOS11 / Mac OS High Sierra)
ىಈܭଌ • Instruments • Time Profiler • Static Initializer Calls
(iOS11 / Mac OS High Sierra) • DYLD_PRINT_STATISTICS
DYLD_PRINT_STATISTICS Total pre-main time: 2.5 seconds (100.0%) dylib loading time:
1.3 seconds (54.0%) rebase/binding time: 111.49 milliseconds (4.3%) ObjC setup time: 432.17 milliseconds (16.9%) initializer time: 631.54 milliseconds (24.7%) slowest intializers : libSystem.B.dylib : 22.83 milliseconds (0.8%) xxx-ios : 500.72 milliseconds (19.5%)
վળํ๏ • Fewer dylibs • ༻සͷ͍UIϥΠϒϥϦͳͲΛͻͨ͢ Βআڈ
վળํ๏ • Fewer initializers • initͰඞཁͳ͍ॲཧۃྗআ֎
վળํ๏ • Fewer initializers • initͰඞཁͳ͍ॲཧۃྗআ֎ • Debug༻ͷϥΠϒϥϦͷinitͳͲΛຊ൪Ͱআ֎
վળํ๏ • Fewer initializers • initͰඞཁͳ͍ॲཧۃྗআ֎ • Debug༻ͷϥΠϒϥϦͷinitͳͲΛຊ൪Ͱআ֎ • RxSwiftͰແҙࣝʹͬͯͨॏෳAPI
Callͷআڈ
վળํ๏ • Fewer initializers • initͰඞཁͳ͍ॲཧۃྗআ֎ • Debug༻ͷϥΠϒϥϦͷinitͳͲΛຊ൪Ͱআ֎ • RxSwiftͰແҙࣝʹͬͯͨॏෳAPI
Callͷআڈ • SDKͷฒྻsetup
վળํ๏ • Fewer classes/methods • structͰએݴͰ͖Δͷۃྗஔ͖͑
վળํ๏ • Fewer classes/methods • structͰએݴͰ͖Δͷۃྗஔ͖͑ • ͬͯͳ͍Ϋϥεɺ༻සͷ͍Ϋϥεͷআ ڈ
Ҏ্ɺϢʔβʔͷͨΊʹ ىಈΛ͘͢Δɻ
νʔϜͷͨΊͷվળ • Ϗϧυ࣌ؒͷΛ͠·͢ɻ
νʔϜͷͨΊͷվળ • Ϗϧυ͕͘ͳΔݪҼ • Ϗϧυ࣌ؒΛܭଌ͢Δํ๏ • վળํ๏
Ϗϧυ͕͘ͳΔݪҼ • ཁ͢ΔʹίϯύΠϥϥΠϒϥϦͷϚούʔ ʹࣄͤ͗͢͞
Ϗϧυ࣌ؒΛܭଌ͢Δํ๏ • -Xfrontend -debug-time-function-bodies
Ϗϧυ࣌ؒΛܭଌ͢Δํ๏ • -Xfrontend -debug-time-function-bodies • ؔ͝ͱͷϏϧυ࣌ؒܭଌ(Swift)
Ϗϧυ࣌ؒΛܭଌ͢Δํ๏ • giginet/xcprofiler
Ϗϧυ࣌ؒΛܭଌ͢Δํ๏ • giginet/xcprofiler
Ϗϧυ࣌ؒΛܭଌ͢Δํ๏ • giginet/xcprofiler • Rubygemύοέʔδ
Ϗϧυ࣌ؒΛܭଌ͢Δํ๏ • giginet/xcprofiler • Rubygemύοέʔδ • ϝιου୯ҐͰܭଌ࣌ؒ(ms)Λιʔτͯ͠ ςʔϒϧग़ྗ
Ϗϧυ࣌ؒΛܭଌ͢Δํ๏ • giginet/xcprofiler • Rubygemύοέʔδ • ϝιου୯ҐͰܭଌ࣌ؒ(ms)Λιʔτͯ͠ ςʔϒϧग़ྗ • giginet/danger-xcprofilerͱซ༻͍͍ͯ͠
͔
վળํ๏ • ͱΓ͋͑ͣ50~60msͷϥΠϯΛ͑ͨΒɺ ؾ͍ͮͨλΠϛϯάͰؔຖϏϧυ࣌ؒΛ ݮΒ͢
վળํ๏ • ܕਪආ͚Δ ʢClosureΓ, Variableએݴʣ
վળํ๏ • ܕਪආ͚Δ ʢClosureΓ, Variableએݴʣ • ϝιουνΣΠϯආ͚ΔʢҰ࣌มʹ֨ೲʣ
վળํ๏ • ܕਪආ͚Δ ʢClosureΓ, Variableએݴʣ • ϝιουνΣΠϯආ͚ΔʢҰ࣌มʹ֨ೲʣ • ྻ݁߹(don’t +,
append)
վળํ๏ • ܕਪආ͚Δ ʢClosureΓ, Variableએݴʣ • ϝιουνΣΠϯආ͚ΔʢҰ࣌มʹ֨ೲʣ • ྻ݁߹(don’t +,
append) • `??` ࡾ߲ԋࢉࢠΘͳ͍
վળํ๏ • ܕਪආ͚Δ ʢClosureΓ, Variableએݴʣ • ϝιουνΣΠϯආ͚ΔʢҰ࣌มʹ֨ೲʣ • ྻ݁߹(don’t +,
append) • `??` ࡾ߲ԋࢉࢠΘͳ͍ • lazy propertiesͷϓϥΠϕʔτϝιουԽ
վળํ๏ • ܕਪආ͚Δ ʢClosureΓ, Variableએݴʣ • ϝιουνΣΠϯආ͚ΔʢҰ࣌มʹ֨ೲʣ • ྻ݁߹(don’t +,
append) • `??` ࡾ߲ԋࢉࢠΘͳ͍ • lazy propertiesͷϓϥΠϕʔτϝιουԽ • ObjectMapperۃྗΘͳ͍
վળํ๏ • ܕਪආ͚Δ ʢClosureΓ, Variableએݴʣ • ϝιουνΣΠϯආ͚ΔʢҰ࣌มʹ֨ೲʣ • ྻ݁߹(don’t +,
append) • `??` ࡾ߲ԋࢉࢠΘͳ͍ • lazy propertiesͷϓϥΠϕʔτϝιουԽ • ObjectMapperۃྗΘͳ͍ • CocoaPodsΛv1.3.0Ҏ্ʹΞοϓάϨʔυ͢Δ
վળํ๏ • ܕਪආ͚Δ ʢClosureΓ, Variableએݴʣ • ϝιουνΣΠϯආ͚ΔʢҰ࣌มʹ֨ೲʣ • ྻ݁߹(don’t +,
append) • `??` ࡾ߲ԋࢉࢠΘͳ͍ • lazy propertiesͷϓϥΠϕʔτϝιουԽ • ObjectMapperۃྗΘͳ͍ • CocoaPodsΛv1.3.0Ҏ্ʹΞοϓάϨʔυ͢Δ
CocoaPods >= v1.3.0
CocoaPods >= v1.3.0 • Dynamic FrameworkͷpathΩϟογϡͷόά͕ मਖ਼͞ΕͨͬΆ͍ʁ
CocoaPods >= v1.3.0 • Dynamic FrameworkͷpathΩϟογϡͷόά͕ मਖ਼͞ΕͨͬΆ͍ʁ • ͍͘Β͍͘ͳΔɻ LUCRAॳظϏϧυ͡Όͳ͚Ε2ඵ͘Β͍ʹͳͬͨɻ
Ҏ্ɺνʔϜͷͨΊʹ ϏϧυΛ͘͢Δɻ
• αʔϏεͷࢮʹͭͳ͕ΔͷͰվળ͔ͬ͠Γɻ • ϢʔβʔͷͨΊͷվળ • XCodeඋ͚͑ͷػೳͰىಈ࣌ؒܭଌɻ • ίϯύΠϥɾϦϯΧʹ༏͍͠ίʔυɾߏΛɻ • νʔϜͷͨΊͷվળ
• पลπʔϧ͍ͭͭϏϧυ࣌ؒܭଌɻ • γϯλοΫεɺpodsͳͲಓʹվળɻ ·ͱΊ
Thank you!