Slide 1

Slide 1 text

1 ࠩ෼ܭࢉΞϧΰϦζϜΛ༻͍ ͨߴ଎ͳ UITableView ඳը

Slide 2

Slide 2 text

2 ύϑΥʔϚϯε ؾʹͯ͠·͔͢ʁ

Slide 3

Slide 3 text

3 “Most apps target a frame rate of 60 FPS, Equivalent to 16.67 ms per frame.” https://developer.apple.com/library/archive/documentation/3DDrawing/Conceptual/ MTLBestPracticesGuide/FrameRate.html

Slide 4

Slide 4 text

4 16 ms…

Slide 5

Slide 5 text

5 UITableView͕େྔʹฒͿ

Slide 6

Slide 6 text

6 UITableViewΛ ଎͍ͨ͘͠

Slide 7

Slide 7 text

7 UITableViewΛ଎͘͢Δʹ͸ • CellͷϨϯμϦϯά࠷దԽ • ඇಉظͳσʔλϑΣονͱΩϟογϡ • ඇಉظͳը૾ϩʔυͱΩϟογϡ • ΦϑϨϯμϦϯάΛආ͚Δ • αΠζͷࣄલܭࢉͱΩϟογϡ

Slide 8

Slide 8 text

8 ඳը͢Δߦ͕গͳ͚Ε ͹଎͍ͷͰ͸…

Slide 9

Slide 9 text

9 performBatchUpdates

Slide 10

Slide 10 text

10 ࠩ෼ߋ৽Λߦ͏ͨΊʹ͸ • มߋલͷσʔλΛมߋޙͷσʔλʹม׵͢ΔͨΊͷ
 ฤूૢ࡞Λܭࢉ͠ͳͯ͘͸ͳΒͳ͍ • มߋલޙͷσʔλͷ௕͞ΛͦΕͧΕM, Nͱͨ͠৔߹
 ૯౰ͨΓͰܭࢉྔ͸O(M * N)ʹͳΔ • ฤूૢ࡞Λܭࢉ͢Δํ๏͸͢Ͱʹଟ͘ͷΞϧΰϦζϜ͕
 ߟҊ͞Ε͓ͯΓɺ͜ΕΒΛ༻͍Δ͜ͱͰܭࢉྔΛখ͘͞
 ͢Δ͜ͱ͕Ͱ͖Δ

Slide 11

Slide 11 text

11 ͬ͘͟Γฤूૢ࡞ܭࢉ ΞϧΰϦζϜ

Slide 12

Slide 12 text

X ͬ͘͟Γฤूڑ཭ΞϧΰϦζϜ • จࣈྻͷฤूૢ࡞Λάϥϑʹϓ ϩοτ͠ɺ࠷খૢ࡞ύεʢฤू ڑ཭ʣΛ୳͢ • ૯ίετΛԾఆͯ͠࠷খίετ Λ୳ࡧ͢Δํ๏ʢMyerʣ • ࡟আૢ࡞ͷ૯਺ΛԾఆͯ͠࠷খ ίετΛ୳ࡧ͢Δํ๏ʢWuʣ https://susisu.hatenablog.com/entry/2017/10/09/134032

Slide 13

Slide 13 text

X ͬ͘͟ΓHeckel๏ • ྆ํͷཁૉྻʹݱΕΔڞ௨͔ͭ
 ̍౓͔͠ग़ݱ͠ͳ͍ཁૉΛ୳͢ • நग़ͨ͠ߦΛى఺ʹڞ௨ϒϩοΫ Λ୳ͯࠩ͠෼͔ΒऔΓআ͘ Paul Heckel (Apr 1978), “A technique for isolating differences between files”

Slide 14

Slide 14 text

12 ֤ΞϧΰϦζϜͷܭࢉྔ • Myer๏ • ܭࢉྔɿO(N + D^2) ~ O(N * D) • D͸ฤूڑ཭ʢฤूૢ࡞ͷ਺ʣ • Wu๏ • ܭࢉྔɿO(N + P * D) ~ O(N * P) • P͸࡟আૢ࡞ͷ਺ɺD͸ฤूڑ཭ • Heckel๏ • ܭࢉྔɿO(N)

Slide 15

Slide 15 text

13 ฤूૢ࡞ܭࢉΞϧΰϦζϜͷ࣮૷ • Dwifft • EditDistance • RxDataSources • DifferenceKit

Slide 16

Slide 16 text

14 Dwifft • https://github.com/jflinter/Dwifft • Myer๏ͬΆ͍࣮૷ => O(N * D) • ࠓճऔΓ্͛ͨ΋ͷͷதͰ͸ʢཧ࿦తʹ͸ʣҰ൪஗͍

Slide 17

Slide 17 text

15 EditDistance • https://github.com/kazuhiro4949/EditDistance • Wu๏ͬΆ͍࣮૷ => O(N * P) • WuͷΞϧΰϦζϜΛ࣮૷͍ͯ͠Δ΋ͷ͸ҙ֎ͱগͳ͍

Slide 18

Slide 18 text

16 RxDataSources • https://github.com/RxSwiftCommunity/RxDataSources • Heckel๏ + α => O(N) • IGListKit΋ಉ༷ʹHeckel๏Λ࠾༻͍ͯ͠Δ͕ɺ
 ΑΓ࠷దԽ͞Ε͍ͯΔRxDataSourceΛ࠾༻͢Δ • ࠩ෼ܭࢉΞϧΰϦζϜ෦෼͸ Differentiator.framework
 ͱͯ͠෼཭͞Ε͍ͯΔͷͰଞͷϑϨʔϜϫʔΫ͔Β
 ར༻͢Δ͜ͱ͕ՄೳͰ͋Δ

Slide 19

Slide 19 text

17

Slide 20

Slide 20 text

18 DifferenceKit • https://github.com/ra1028/DifferenceKit • Heckel๏ + α => O(N) • iOSDC1ϲ݄લʹಥ೗ͱͯ͠ݱΕͨ৽੕

Slide 21

Slide 21 text

19

Slide 22

Slide 22 text

20 ύϑΥʔϚϯεൺֱ

Slide 23

Slide 23 text

21 ϨΪϡϨʔγϣϯ • Insert 10% + Delete 10% • ཁૉ਺: 1,000 • ཁૉ਺: 10,000 • Insert 30% + Delete 30% • ཁૉ਺: 1,000 • ཁૉ਺: 10,000

Slide 24

Slide 24 text

22 ύϑΥʔϚϯεൺֱ(1,000ߦ)

Slide 25

Slide 25 text

23 ύϑΥʔϚϯεൺֱ(10,000ߦ)

Slide 26

Slide 26 text

24 ࠩ෼ߋ৽ύϑΥʔϚϯε(1,000ߦ)

Slide 27

Slide 27 text

25 ࠩ෼ߋ৽ύϑΥʔϚϯε(100ߦ)

Slide 28

Slide 28 text

26 ಈ͔ͤΔαϯϓϧ • https://github.com/fumito-ito/iOSDC-2018-Sample

Slide 29

Slide 29 text

27 ύϑΥʔϚϯεҎ֎ͷൺֱ؍఺ • ଟ࣍ݩ഑ྻʹରԠ͍ͯ͠Δ͔ • ≒ ηΫγϣϯͷαϙʔτ • ॏෳͨ͠σʔλΛڐ༰͢Δ͔ • UITableViewͰදݱՄೳͳૢ࡞Λαϙʔτ͍ͯ͠Δ͔

Slide 30

Slide 30 text

28 ϥΠϒϥϦͷػೳൺֱ

Slide 31

Slide 31 text

29 ೔ܦిࢠ൛ͷࠩ෼ܭࢉ • RxASDataSourceΛ࠾༻ͨ͠ • RxDataSourcesͷޓ׵ϥΠϒϥϦ • ΋ͱ΋ͱར༻͍ͯͨ͠RxSwiftɺTextureͱ૬ੑͷ͍͍
 ϥΠϒϥϦΛ࢖͍͔ͨͬͨ

Slide 32

Slide 32 text

30 ೔ܦిࢠ൛Ͱͷվળྫ reloadData ࠩ෼ߋ৽

Slide 33

Slide 33 text

31 ࠩ෼ߋ৽ ຊ౰ʹ΍Δ΂͖ʁ

Slide 34

Slide 34 text

32 ࠩ෼ߋ৽͸ίετʹݟ߹ͬͯΔʁ • ཁૉ਺ʹൺྫͯ͠ܭࢉίετ͕૿େ͢Δ͸ͣ • ࣮ࡍʹηϧͷ਺͕େ͖͗͢Δ৔߹͸ඇৗʹ஗͘ͳΔ
 ໰୊͕ࢦఠ͞Ε͍ͯΔ • “I have a huge data set and - performBatchUpdatesAnimated: completion: is super slow. What do I do?”
 - IGListKit, performBatchUpdates long perform on main thread #803
 https://github.com/Instagram/IGListKit/issues/ 803#issuecomment-305276659

Slide 35

Slide 35 text

33 ؾʹͳΔํ͸ͪ͜Β • ʮ5000ߦͷUITableViewΛࠩ෼ߋ৽͢Δʯ • 2018/09/01 14:20 ~ @Track A • https://fortee.jp/iosdc-japan-2018/proposal/ 530b6839-cc50-452c-9682-897afa9db18c

Slide 36

Slide 36 text

34 ·ͱΊ • ࠩ෼ߋ৽Λ༻͍Δ͜ͱͰUITableViewΛߴ଎ʹ
 ඳը͢Δ͜ͱ͕Ͱ͖Δ • ࠩ෼ͷܭࢉʹΞϧΰϦζϜΛద༻͢Δ͜ͱͰܭࢉྔΛ
 ݮΒ͠ɺύϑΥʔϚϯεΛ޲্ͤ͞Δ͜ͱ͕Ͱ͖Δ • දࣔ͢Δσʔλͷྔ͕େ͖͍৔߹͸ࠩ෼ܭࢉΛ͢Δͷ͔ɺ reloadDataΛ͢Δͷ͔ߟ͑ͨํ͕ྑ͍

Slide 37

Slide 37 text

35 RxASDataSourceͷ ίϯτϦϏϡʔλʔ ืूதͰ͢ɻ @fumito_ito fumito-ito

Slide 38

Slide 38 text

36 ग़య • Paul Heckel (Apr 1978), “A technique for isolating differences between files” • James W. Hunt, M. Douglas Mcllory (Jun 1976), “An Algorithm for Differential File Comparison” • E. Myers (1986), “An O(ND) Difference Algorithm and Its Variations”