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
わかった気になる、Coroutine1.7.0のチャンネルのパフォーマンス向上
Search
RyuNen344
May 13, 2023
Technology
0
420
わかった気になる、Coroutine1.7.0のチャンネルのパフォーマンス向上
RyuNen344
May 13, 2023
Tweet
Share
More Decks by RyuNen344
See All by RyuNen344
せめて、ネイティブらしく
ryunen344
2
1.1k
Cache Me If You Can
ryunen344
3
8.1k
WindowInsetsだってテストしたい
ryunen344
2
340
サプライチェーン攻撃に備える
ryunen344
1
3.2k
Okioに愛を込めて
ryunen344
3
2.7k
Firebase Hostingを使ってPasskeyをandroidアプリで試してみよう
ryunen344
2
2k
Xcode Meets Gradle
ryunen344
0
390
K/NとNSKeyedArchiverと私
ryunen344
0
580
ComposeのModalBottomSheetは (まだ)沼
ryunen344
1
1.9k
Other Decks in Technology
See All in Technology
ドメイン駆動セキュリティへの道しるべ
pandayumi
0
180
新規事業における「一部だけどコア」な AI精度改善の優先順位づけ
zerebom
0
170
BPaaSオペレーション・kubell社内 n8n活用による効率化検証事例紹介
kentarofujii
0
290
ReproでのicebergのStreaming Writeの検証と実運用にむけた取り組み
joker1007
0
430
AI Agent Standards and Protocols: a Walkthrough of MCP, A2A, and more...
glaforge
1
560
それぞれのペースでやっていく Bet AI / Bet AI at Your Own Pace
yuyatakeyama
1
570
クラウドセキュリティの進化 — AWSの20年を振り返る
kei4eva4
0
160
Werner Vogelsが14年間 問い続けてきたこと
yusukeshimizu
2
210
みんなでAI上手ピーポーになろう! / Let’s All Get AI-Savvy!
kaminashi
0
220
Riverpod3.xで実現する実践的UI実装
fumiyasac0921
2
340
AI アクセラレータチップ AWS Trainium/Inferentia に 今こそ入門
yoshimi0227
1
320
人はいかにして 確率的な挙動を 受け入れていくのか
vaaaaanquish
4
2.5k
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
150
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
150
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.2k
Designing for Timeless Needs
cassininazir
0
120
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
Writing Fast Ruby
sferik
630
62k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
58
42k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
260
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
210
Transcript
Θ͔ͬͨؾʹͳΔɺCoroutine1.7.0ͷ νϟϯωϧͷύϑΥʔϚϯε্ 2023.05.13 KotlinConf 2023 Global in Kyoto Bunjiro Miyoshi
About Me • teamLab Inc.ॴଐ • (ࣗশ)ϚϧνϓϥοτϑΥʔϜܳਓ • ࠷ۙGoogle/TinkͷKMMϥούʔϥΠϒϥϦ࡞ͬͨ •
https://github.com/RyuNen344/tink-kmm
kotlinx.coroutine 1.7 ϦϦʔε͞Ε·ͨ͠Ͷ
Release Note
Release Note runTestͷdefault timeout͕60s͔Β10sʹมߋ͞ΕͨΓ
Release Note Kotlin NativeʹDispatchers.IO͕ొ
Release Note Kotlin NativeͷOld Memory Model͕আ͞Εͨ
Release Note Channelͷ࠶࣮
͢͜ͱɾ͞ͳ͍͜ͱ • ͢͜ͱ • چ࣮ɾ৽࣮ͷҧ͍ • ;ΜΘΓͱͨ͠Lock freeपΓͷ • ͞ͳ͍͜ͱ
• Lock freeपΓͷఆٛతʹਖ਼͍͠ղઆ • kumagi͞Μͷࢿྉ͕ͱͯษڧʹͳΓ·͢ • https://www.docswell.com/s/kumagi/ZP99EQ-lock-free • Ktorͷ3rd PartyϥΠϒϥϦͷӨڹ
ͳͥ࠶࣮ #1 • σʔλߏConcurrent Double Linked List • ͦͦޡͬͨཧΛݩʹ࣮ͯ͠ •
อकੑͷ • ઢܗԽՄೳੑͷ • ૢ࡞͕ஞ࣮࣍ߦ͞Ε͍ͯΔ͜ͱͷอূ
ͳͥ࠶࣮(Double Linked List) #1 ઌ಄ͱ࠷ޙͷϙΠϯλΛอ࣋ w w w w
ͳͥ࠶࣮(Double Linked List) #1 ཁૉྡ͢ΔͷϙΠϯλΛอ࣋
ͳͥ࠶࣮(Double Linked List) #1
ͳͥ࠶࣮(Double Linked List) #1 ৽͍͠ཁૉͷੜ DoubleLinkedListࣗମͷઌ಄ͱ چઌ಄ͷཁૉͷྡ͢ΔཁૉΛߋ৽
ͳͥ࠶࣮ #2 • ࣮͕ෳࡶʹͳ͍ͬͯͯbyte code size, dex sizeʹѱӨڹ • DCAS,
N-word CASͰ࣮ • ֦ுੑɺਖ਼֬ੑɺύϑΥʔϚϯεʹ͕͋Δ • CASɿCompare And Swap જࡏతͳσʔλڝ߹ͷ͕ൃੜͨ͠߹ͷਪଌͱमਖ਼Λࠔʹ͍ͯͨ͠
ͳͥ࠶࣮(Compare And Swap) #2
ͳͥ࠶࣮(Compare And Swap) #2 Pointerͷٙࣅίʔυ
ͳͥ࠶࣮(Compare And Swap) #2 PointerͷͱPointerʹೖͬͯΔ͖ΛνΣοΫ w w
ͳͥ࠶࣮(Compare And Swap) #2 ظͲ͓Γͷ͕Pointerʹ֨ೲ͞Ε͍ͯͨΒߋ৽
ͳͥ࠶࣮(D-Compare And Swap) #2
ͳͥ࠶࣮(D-Compare And Swap) #2 ظͲ͓Γͷ͕Pointerʹ֨ೲ͞ΕΔ·ͰԿCAS
ͲͷΑ͏ʹ࠶࣮ • σʔλߏྻͰ࣮ • ΦϒδΣΫτૢ࡞Fetch And Addʹมߋ
ͲͷΑ͏ʹ࠶࣮(Fetch And Add) Pointerʹೖ͍ͬͯͨݹ͍ΛҰ࣌อଘͯ͠ॲཧΛ࣮ߦ
ͲͷΑ͏ʹ࠶࣮(Fetch And Add) Ұ࣌อଘͨ͠ݹ͍Λݺͼग़͠ݩʹฦ٫
࠶࣮ͯ͠Ͳ͏ͳΔ • ҰൠతͳڥͰ10 ʙ 25%ߴԽ
·ͱΊ • 1.7.0ͰChannelࣗମͷ࠶࣮͕ͳ͞ΕͯύϑΥʔϚϯε্͕ͨ͠ • (Opt)BroadcastChannelܥΛআ͢Δ४උ͕ͬͨ • (Opt)͜ͷ࠶࣮ͷ͓͔͛ͰsemaphoremutexपΓͷվળೖͬͯ ͍Δ
͍͞͝ʹ ࢿྉ࡞ͬͯͨΒ1.7.1ϦϦʔε͞Εͨ😂
Ҿ༻ • https://github.com/Kotlin/kotlinx.coroutines/releases/tag/1.7.0 • https://github.com/Kotlin/kotlinx.coroutines/issues/3621 • https://github.com/Kotlin/kotlinx.coroutines/pull/3103 • https://arxiv.org/abs/2211.04986