$30 off During Our Annual Pro Sale. View Details »

Apple silicon導入のウラガワ/ Introducing Apple silicon and its behind the scenes

Satoshi Komatsu
May 16, 2022
730

Apple silicon導入のウラガワ/ Introducing Apple silicon and its behind the scenes

Satoshi Komatsu

May 16, 2022
Tweet

Transcript

  1. Apple siliconಋೖͷ΢ϥΨϫ ςοΫϒϩάʹ੝ΓࠐΊͳ͔ͬͨ࿩ɺެ։͠·͢ גࣜձࣾZOZO ZOZOTOWN։ൃຊ෦ ZOZOTOWNΞϓϦ෦ iOSϒϩοΫ খদ ޛ Copyright

    © ZOZO, Inc.
  2. © ZOZO, Inc. খদ ޛ(@tosh_3) 2020೥ZOZOςΫϊϩδʔζ(ݱZOZO)ʹ৽ଔೖࣾɻ ZOZOTOWNͷiOSΞϓϦͷ։ൃʹैࣄɻ झຯ͸εϙʔπ؍ઓɻ 2 גࣜձࣾZOZO

    ZOZOTOWN։ൃຊ෦ ZOZOTOWNΞϓϦ෦ iOSϒϩοΫ
  3. © ZOZO, Inc. 3 ςοΫϒϩά ZOZOTOWN iOSνʔϜɺApple siliconಋೖ͠·ͨ͠ https://techblog.zozo.com/entry/zozotown-ios-apple-silicon

  4. © ZOZO, Inc. 4 ςοΫϒϩάͷ಺༰·ͱΊ  © ZOZO, Inc.

  5. © ZOZO, Inc. 5 ςοΫϒϩά಺༰·ͱΊ  "QQMFTJMJDPOಋೖ͠·ͨ͠ ɾiOSνʔϜશһͷ୺຤ɺIntel Mac͔ΒM1 Pro΁ͱҠߦ͠·ͨ͠

    ɾM1 MacBook AirΛݕূػͱͨ͜͠ͱͰɺೋ೔ؒͰͷҠߦΛՄೳʹ ɾZOZOTOWN iOS͸RosettaΛ࢖༻͢Δ͜ͱʹ͠·ͨ͠ ɾM1 MaxͰ͸ͳ͘M1 Proʹ͠·ͨ͠ ɾϏϧυ଎౓͕൒෼ʹͳΓ·ͨ͠
  6. © ZOZO, Inc. 6 ςοΫϒϩά಺༰·ͱΊ  *OUFM.BD͔Β"QQMFTJMJDPO΁ͷҠߦλΠϜϥΠϯ   

    ݄ 88%$ʹͯ "QQMFTJMJDPOൃදɻ ։ൃऀ޲͚ʹ%5,഑෍ɻ ݄ ݕূػͱͯ͠ɺ ..BD#PPL"JSΛߪೖ ݄ ݄ ݄ .1SP.BYൃද .1SPߪೖ .1SP౸ண "QQMFTJMJDPOҠߦ
  7. © ZOZO, Inc. 7 ςοΫϒϩά಺༰·ͱΊ  ݕূػಋೖͷഎܠ ɾM1ͷൃදͷλΠϛϯάͰ͸࣌ظঘૣ ɾࠓޙग़ΔϓϩϞσϧʹඋ͑ͨ४උ

  8. © ZOZO, Inc. 8 ςοΫϒϩά಺༰·ͱΊ  ࠓճಋೖͨ͠୺຤ͷεϖοΫ ɾ10ίΞCPU M1 Pro

    ɾ32GBϢχϑΝΠυϝϞϦ ɾ1TB SSD →ෳ਺ͷXcodeΛ؅ཧ͢Δ͜ͱ͕͋ΔͷͰগ͠༨༟Λ
  9. © ZOZO, Inc. 9 ςοΫϒϩά಺༰·ͱΊ  .1SPΛબ୒ͨ͠ཧ༝ ɾ10ίΞCPUͷProͱMaxͷେ͖ͳҧ͍͸GPUίΞ ɾࠓ·Ͱͷ։ൃͰϝϞϦෆ଍Λײ͡Δ͜ͱ͕ͳ͔ͬͨ ɹݕূػ(16GB)Ͱ΋໰୊ͳ͠

    V.S. →࣮ࡍʹӡ༻͍ͯ͠ΔதͰ΋ɺշదʹ։ൃ͕Ͱ͖͍ͯΔ
  10. © ZOZO, Inc. 10 ςοΫϒϩά಺༰·ͱΊ  Ϗϧυ଎౓ͷมԽ ɾZOZOTOWNϦϦʔεϏϧυͷϏϧυ࣌ؒͰൺֱ ɾxcode-build-times-renderingΛ࢖༻ͯ͠ܭଌ ɾIntel

    Mac(Core i9)ͱApple silicon Mac(M1 Pro)Ͱൺֱ
  11. © ZOZO, Inc. 11 ςοΫϒϩά಺༰·ͱΊ  Ϗϧυ଎౓ͷมԽ ϦϦʔεϏϧυ Intel Core

    i9: 6෼25ඵ M1 Pro: 3෼12ඵ →Ϗϧυ͕࣌ؒ൒෼ʹʂ     ෼    
  12. © ZOZO, Inc. 12 ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔  © ZOZO, Inc.

  13. © ZOZO, Inc. 13 ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔  3PTFUUBͱ͸Կ͔ʁ Rosettaͱ͸ARM64Ͱಈ͍͍ͯΔApple siliconԼʹ͓͍ͯɺx86_64༻ͷόΠ φϦΛಈ͔͢͜ͱͷͰ͖Δ຋༁ϓϩηε

  14. © ZOZO, Inc. 14  ͳͥ3PTFUUBΛ࢖༻͢Δ͜ͱʹͨ͠ͷ͔ ֎ͨ͠ঢ়ଶͰϏϧυʹ͍࣋ͬͯ͘͜ͱ͕೉͔ͬͨ͠ɻ →Carthageܦ༝ͰೖΕ͍ͯΔϥΠϒϥϦΛ.frameworkܗ͔ࣜΒ.xcframework ܗࣜ΁ͱมߋ͠ͳ͍ͱ͍͚ͳ͍ ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔

  15. © ZOZO, Inc. 15  9$'SBNFXPSLͱ͸ Framework 📦 Universal Binary

    →ෳ਺ͷΞʔΩςΫνϟ༻ͷόΠφϦϑΝΠϧΛ·ͱΊͨ΋ͷɻ ͨͩ͠ɺಉҰͷΞʔΩςΫνϟΛෳ਺อ࣋Ͱ͖ͳ͍ iPhone༻ͷόΠφϦ(ARM64)ͱSimulator༻ͷόΠφϦ(x86_64) Λ·ͱΊΔ ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔ ⭕
  16. © ZOZO, Inc. 16  9$'SBNFXPSLͱ͸ Framework 📦 Universal Binary

    →ෳ਺ͷΞʔΩςΫνϟ༻ͷόΠφϦϑΝΠϧΛ·ͱΊͨ΋ͷɻ ͨͩ͠ɺಉҰͷΞʔΩςΫνϟΛෳ਺อ࣋Ͱ͖ͳ͍ ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔ iPhone༻ͷόΠφϦ(ARM64)ͱSimulator༻ͷόΠφϦ(ARM64) Λ·ͱΊΔ ❌
  17. © ZOZO, Inc. 17  9$'SBNFXPSLͱ͸ XCFramework ಉҰͷΞʔΩςΫνϟʹରͯ͠΋ෳ਺ͷόΠφϦΛ࣋ͭ͜ͱ͕Ͱ ͖Δܗࣜ ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔

    iPhone༻ͷόΠφϦ(ARM64)ͱSimulator༻ͷόΠφϦ(ARM64) Λ·ͱΊΔ ⭕
  18. © ZOZO, Inc. 18  ;0;0508/ͷϏϧυߏ੒ ZOZOTOWN Carthage CocoaPods ͦͷଞ

    ϥΠϒϥϦ ZOZOSUIT ZOZOMAT ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔
  19. © ZOZO, Inc. 19  ;0;0508/ͷϏϧυߏ੒ Carthage CocoaPods ͦͷଞ ϥΠϒϥϦ

    ZOZOSUIT ZOZOMAT ZOZOTOWN ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔ XCFramework
  20. © ZOZO, Inc. 20  ;0;0508/ͷϏϧυߏ੒ Carthage CocoaPods ͦͷଞ ϥΠϒϥϦ

    ZOZOSUIT ZOZOMAT XCFramework ❌ ❌ ZOZOTOWN ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔
  21. © ZOZO, Inc. 21  ;0;046*5Λ9$'SBNFXPSLԽ͢Δͷ͕೉͍͠ཧ༝ ɾOpenCVͷXCFrameworkαϙʔτঢ়گ ɾΫϩεϓϥοτϑΥʔϜͷίΞΞϧΰϦζϜͷϏϧυ ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔

  22. © ZOZO, Inc. 22  0QFO$7ͷ9$'SBNFXPSLαϙʔτঢ়گ ɾZOZOSUITͰ࢖༻͞Ε͍ͯΔOpenCVͷόʔδϣϯ͕3ܥ ɾOpenCVͰXCFrameworkରԠ͕͞Εͨͷ͸ɺ4.5.1Ҏ߱ ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔

  23. © ZOZO, Inc. 23  →3ܥͷόʔδϣϯͰ͋ͬͯ΋ɺࣗ෼ͰbuildઃఆΛௐ੔͢Δ͜ͱͰ XCFrameworkΛ࡞Δ͜ͱ͸Մೳ ɾZOZOSUITͰ࢖༻͞Ε͍ͯΔOpenCVͷόʔδϣϯ͕3ܥ ɾOpenCVͰXCFrameworkରԠ͕͞Εͨͷ͸ɺ4.5.1Ҏ߱ 0QFO$7ͷ9$'SBNFXPSLαϙʔτঢ়گ

    ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔
  24. © ZOZO, Inc. 24  ΫϩεϓϥοτϑΥʔϜͷίΞΞϧΰϦζϜͷϏϧυ ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔ XcodeͰ͸ͳ͘ɺϏϧυεΫϦϓτʹΑͬͯɺiOS΍AndroidͷͦΕͧΕͷ ΞʔΩςΫνϟ༻ͷ੩తϥΠϒϥϦΛੜ੒͍ͯ͠Δ

  25. © ZOZO, Inc. 25  ΫϩεϓϥοτϑΥʔϜͷίΞΞϧΰϦζϜͷϏϧυ ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔ XcodeͰ͸ͳ͘ɺϏϧυεΫϦϓτʹΑͬͯɺiOS΍AndroidͷͦΕͧΕͷ ΞʔΩςΫνϟ༻ͷ੩తϥΠϒϥϦΛੜ੒͍ͯ͠Δ XCFrameworkͷཁٻΛͨͩຬͨ͢ͷͰ͋Ε͹ɺiOS

    SimulatorΛ1ͭͷϓϥο τϑΥʔϜͱͯ͠෼ذΛ଍ͤ͹ྑ͍ ҰํͰɺ΍Γ͍ͨ͜ͱʹରͯ͠Өڹൣғ͕େ͖͗͢Δ͔΋͠Εͳ͍
  26. © ZOZO, Inc. 26  ΫϩεϓϥοτϑΥʔϜͷίΞΞϧΰϦζϜͷϏϧυ ɾࣗ෼ୡͷνʔϜ಺Ͱ׬݁͢Δ΄Ͳখ͞ͳ໰୊Ͱ͸ͳ͔ͬͨ ɾXCFrameworkͷͨΊͷվमΛখखઌͰ΍ΔΑΓ΋ɺํ๏Λݕ౼͢Δ࣌ؒΛ ͱͬͨ΄͏͕ɺಘࡦ →ࠓճͷλΠϛϯάͰ͸ɺRosettaΛ࢖༻ͯ͠ͷҠߦ

    Rosetta͋ΓͰ͋ͬͯ΋ɺApple siliconಋೖʹΑͬͯ ಘΒΕΔޮՌେʂ ͳͥ3PTFUUBΛ֎ͤͳ͔ͬͨͷ͔
  27. © ZOZO, Inc. 27 3PTFUUBͱͷ޲͖߹͍ํ  © ZOZO, Inc.

  28. © ZOZO, Inc. 28 3PTFUUBͱͷ޲͖߹͍ํ  3PTFUUBͱͷ޲͖߹͍ํ ɾRosettaΛ֎͢͜ͱͰϏϧυ଎౓Λ΋ͬͱ଎͘Ͱ͖Δ ɾPlayground͕࢖༻Ͱ͖ͳ͘ͳΔ ɾSimulatorͰεΫϩʔϧͷ׳ੑ͕ޮ͔ͳ͘ͳΔ

    ɾΞϓϦέʔγϣϯ͝ͱͷRosettaͷ࢖༻༗ແΛܾΊΔ
  29. © ZOZO, Inc. 29 3PTFUUBΛ֎͢͜ͱͰϏϧυ଎౓Λ΋ͬͱ଎͘Ͱ͖Δ ɾ࣮ػ(ARM64)ʹରͯ͠σόοάϏϧυΛߦ͏ ɾRosettaͰىಈͨ͠΋ͷͱRosettaͳ͠Ͱىಈͨ͠΋ͷͰϏϧυ࣌ؒΛൺֱ  3PTFUUBͱͷ޲͖߹͍ํ

  30. © ZOZO, Inc. 30 Rosetta͋Γ: 2෼35ඵ Rosettaͳ͠: 1෼28ඵ ZOZOTOWNͷσόοάϏϧυͷ༷ࢠ 3PTFUUBΛ֎͢͜ͱͰϏϧυ଎౓Λ΋ͬͱ଎͘Ͱ͖Δ

         ෼ Intel Core i7: 3෼48ඵ  3PTFUUBͱͷ޲͖߹͍ํ
  31. © ZOZO, Inc. 31 1MBZHSPVOE͕࢖༻Ͱ͖ͳ͘ͳΔ໰୊ ɾXcodeΛRosettaͰىಈ͍ͯ͠Δ৔߹ʹૺ۰ ɾRosettaͳ͠Ͱىಈ͢Ε͹໰୊ͳ͘ಈ͔͢͜ͱ͕Ͱ͖Δ  3PTFUUBͱͷ޲͖߹͍ํ

  32. © ZOZO, Inc. 32 4JNVMBUPSͷ׳ੑ͕ޮ͔ͳ͘ͳΔ RosettaͰϏϧυͨ͠ZOZOTOWNΞϓϦ RosettaͰىಈͨ͠Simulator Rosettaͳ͠Ͱىಈͨ͠Simulator  3PTFUUBͱͷ޲͖߹͍ํ

  33. © ZOZO, Inc. 33 RosettaͰϏϧυ͞Ε͍ͯͳ͍Ͱ͋Ζ͏MapΞϓϦ RosettaͰىಈͨ͠Simulator Rosettaͳ͠Ͱىಈͨ͠Simulator  4JNVMBUPSͷ׳ੑ͕ޮ͔ͳ͘ͳΔ 3PTFUUBͱͷ޲͖߹͍ํ

  34. © ZOZO, Inc. 34 9DPEF 
 3PTFUUBͳ͠ 9DPEF 3PTFUUB͋Γ 4JNVMBUPS

    3PTFUUBͳ͠ εΫϩʔϧͷ׳ੑ⭕ εΫϩʔϧͷ׳ੑ❌ 4JNVMBUPS 3PTFUUB͋Γ εΫϩʔϧͷ׳ੑ❌ εΫϩʔϧͷ׳ੑ⭕ *XcodeͱSimulatorͷRosettaͷΦϯΦϑ͸ࣗಈͰಉظ͞Εͳ͍  4JNVMBUPSͷ׳ੑ͕ޮ͔ͳ͘ͳΔ https://developer.apple.com/forums/thread/668488 3PTFUUBͱͷ޲͖߹͍ํ
  35. © ZOZO, Inc. 35 3PTFUUBΛ࢖༻͢Δ؀ڥͱ࢖༻͠ͳ͍؀ڥ ɾRosetta͋ΓͰӡ༻͍ͯ͠ΔΞϓϦ - Xcode - Simulator

    - Bundler(CocoaPods) ɾRosettaͳ͠Ͱӡ༻͍ͯ͠ΔΞϓϦ - Terminal - AppStore޲͚Ϗϧυͷ࡞੒  3PTFUUBͱͷ޲͖߹͍ํ
  36. © ZOZO, Inc. 36 $PDPB1PETʹ͍ͭͯ ɾGemͰೖΕͨCocoaPods͸FFIपΓͷΤϥʔͷͨΊɺApple siliconԼͰͷ ࣮ߦ͕೉͍͠ →arch -x86_64Λ಄ʹ͚ͭͯӡ༻

    ɾHomebrewܦ༝ͰೖΕΔͱApple siliconԼͰ΋໰୊ͳ͘ಈ͘ →BundlerʹΑͬͯCocoaPodsͷόʔδϣϯΛݻఆ͍ͨ͠ͷͰɺ࢖༻͠ͳ͍ ɾͦ΋ͦ΋ZOZOTOWNͰ͸PodsϑΝΠϧ͸git؅ཧ͞Ε͍ͯΔͨΊɺinstall ΍update͞ΕΔ͜ͱ͕গͳ͍  3PTFUUBͱͷ޲͖߹͍ํ
  37. © ZOZO, Inc. 37 9DPEFͰͷṖڍಈ  © ZOZO, Inc.

  38. © ZOZO, Inc. 38 9DPEFͰͷṖڍಈ  ϦϦʔεϏϧυͷܭଌ࣌ؒଌఆத νʔϜ಺ͷͱ͋Δਓ ໿290ඵ ໿430ඵ

    νʔϜ಺ͷଞͷϝϯόʔ
  39. © ZOZO, Inc. 39 9DPEFͰͷṖڍಈ  ϦϦʔεϏϧυͷܭଌ࣌ؒଌఆத MacͷεϖοΫɺOS͸Ұॹ
 ಛผͳXcodeͷઃఆ΋ͳ͠ νʔϜ಺ͷͱ͋Δਓ

    ໿290ඵ ໿430ඵ νʔϜ಺ͷଞͷϝϯόʔ ໿140ඵ
  40. © ZOZO, Inc. 40 9DPEFͰͷṖڍಈ  ϦϦʔεϏϧυͷܭଌ࣌ؒଌఆத ~/Library/Developer/Xcode/DerivedData/[Ϗϧυͷݻ༗ࣝผࢠ]/Build/Intermediates.noindex/ ArchiveIntermediates/[ϓϩδΣΫτ໊]/IntermediateBuildFilesPath/[ϓϩδΣΫτ໊].build/ Release-iphoneos/[ϓϩδΣΫτ໊].build/Objects-normal/arm64

    ϩάΛ௥͍ͬͯΔݶΓɺιʔεϑΝΠϧͷίϯύΠϧ࣌ؒʹࠩ෼͕ ͋ΔΑ͏ʹݟ͑Δ👀
  41. © ZOZO, Inc. 41 9DPEFͰͷṖڍಈ  ϦϦʔεϏϧυͷܭଌ࣌ؒଌఆத Obj-CϑΝΠϧͷίϯύΠϧ ଴ػ࣌ؒ(Ṗ) 12ඵ

    Obj-CͷίϯύΠϧ SwiftͷίϯύΠϧ 3ඵ 140ඵ 12ඵ 3ඵ 4ඵ Ϗϧυͷ஗͍ਓ Ϗϧυͷ଎͍ਓ
  42. © ZOZO, Inc. 42 9DPEFͰͷṖڍಈ  ղܾํ๏ ɾXcode13.2.1ͷ࠶μ΢ϯϩʔυ ɾXcode13.3.0ͰϏϧυͯ͠ΈͨΒɺSwiftϑΝΠϧͷίϯύΠϧ͔ΒObj-Cͷ ίϯύΠϧͰͷ଴ػ͕࣌ؒ1ඵະຬʹͳ͍ͬͯͨͷͰɺXcode13.2.1ͷόάʁ

  43. © ZOZO, Inc. 43 ࠓޙͷల๬  © ZOZO, Inc.

  44. © ZOZO, Inc. 44 ࠓޙͷల๬  3PTFUUB͔Βͷ୤٫ʂ ɾRosettaىҼʹΑΔෆ۩߹͔Βͷղ์👋 ɾσόοάϏϧυͷ଎౓͕଎͘ͳΔͷͰɺߋͳΔ։ൃޮ཰ͷ޲্💪 ɾRosettaͷαϙʔτऴྃΛߴΈͷݟ෺🤘

    →PowerPC͔ΒIntelҠߦͷࡍͷRosetta͸໿5೥ޙʹ͸αϙʔτऴྃ
  45. None