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
Internal of cpm
Search
Shoichi Kaji
July 05, 2018
0
570
Internal of cpm
shibuya.pm #18 2018/07/05
Shoichi Kaji
July 05, 2018
Tweet
Share
More Decks by Shoichi Kaji
See All by Shoichi Kaji
宿泊予約サイトにおける検索と料金計算の両立
skaji
2
2.5k
昔のGo, 今のGo ~比較, ソート編~
skaji
0
170
Perl Quiz
skaji
0
130
cpm at PerlCon 2019
skaji
0
110
Perl5 Package Manager
skaji
0
660
How to execute external programs in Perl
skaji
3
570
Writing Perl with w0rp/ale
skaji
0
2.2k
nginx unit
skaji
0
44
Perl6 ecosystem
skaji
1
1.4k
Featured
See All Featured
Navigating Team Friction
lara
183
14k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
How GitHub (no longer) Works
holman
310
140k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Transcript
cpmͷ࣮ͷཪଆ Shoichi Kaji
Me • Shoichi Kaji • CPAN, github: skaji • co-maintainer
of Minilla, Perl-Build, Text- Xslate, Mouse, Test-PAUSE- Permissions
ࠓͷత • cpmͷ࣮ͷࢼߦࡨޡΛ͠ɺ ͍Ζ͍ΖͳΓ͔͕ͨ͋Δͱ͍͑ͨɻ ໘ന͍ͱࢥͬͯΒ͑ͨΒɺ͞Βʹ͏Ε͍͠ɻ • Ͳ͏͍͏͕͔͋ͬͨɺͲΜͳղܾҊ͕͋ͬͨ ͷ͔ɺͳͥͦͷղܾҊΛ࠾༻ͨ͠ͷ͔ • େɺͳͥͦͷҊΛબΜ͔ͩͱݴΘΕͯɺ"ͳΜ
ͱͳ͘"ͱ͍͏͜ͱ͕ଟ͍͚ΕͲ:)
࣍ • cpmͱʁ • CPAN client ߴԽͷϙΠϯτ(A), (B) • Ͳ͏ͬͯ"ͲΜͲΜ"jobΛফԽ͢Δ͔
• jobͷத • ϓϩάϥϜύϥμΠϜ • IPC • select • ࣮ࡍͷcpmͷίʔυ • ࠷ޙʹ
cpmͱ?
cpm is a fast CPAN client
https://github.com/skaji/cpm
CPAN clientΛߴԽ͢Δʹ େ͖͘2ͭͷϙΠϯτ͕͋Δ
CPAN clientߴԽͷϙΠϯτ(A) • Ͳ͏ͬͯɺಈతʹܾ·ΔΔ͖͜ͱ(= job)Λ ཧ͢Δ͔ • ͡ΊʹΘ͔͍ͬͯΔͷʮModuleAͷΠϯετʔ ϧʯͱ͍͏ΰʔϧͷΈ •
ModuleXͷґଘModuleXͷMakefile.PLΛ࣮ߦ͠ ͯ͡Ίͯ֬ఆ͢Δ • Ͳͷjobʹґଘؔʹ͋ΓɺͲͷjobಠཱ͔
CPAN clientߴԽͷϙΠϯτ(B) • Ͳ͏ͬͯ"ͲΜͲΜ"jobΛফԽ͢Δ͔ • ࠓͪ͜ΒΛѻ͍͍ͨ
job job job job job job job job job Ͳ͏ͬͯjobΛ
"ͲΜͲΜ"ফԽ͢Δ͔
jobͷத • ֎෦ίϚϯυ࣮ߦ • perl Makefile.PL • tar xzf Module-0.1.tar.gz
• HTTP௨৴ • API͔ΒdisturlΛऔಘ • CPAN͔ΒtarballΛऔಘ job job job job job job job job job
ϓϩάϥϜύϥμΠϜ • ͲͷϓϩάϥϜύϥμΠϜΛ࠾༻͢Ε"ͲΜͲΜ"jobΛফԽͰ͖Δ͔ • Ҋ1: ϚϧνεϨου • ೦ͳ͕ΒPerlͰεϨουϓϩάϥϛϯάݫ͍͠ • Ҋ2:
Event Driven • jobͷ࣮ࡍͷத֎෦ϓϩάϥϜ࣮ߦɺHTTP௨৴ͩͬͨɻΑͬͯEvent DrivenʹͽͬͨΓɻ͕ɺطଘͷCPAN clientͷίʔυΛ͑ͳ͍ • Ҋ3: Ϛϧνϓϩηε • ·ͣ͜ΕͰ
Ϛϧνϓϩηε • ϚϧνϓϩηεΛ࠾༻ʂ • 1: master͔Βworkerjob ͷૹ৴ɺworker͔Βmaster ݁Ռͷૹ৴Λ͍ͨ͠ɻͲ͏ ͬͨΒͰ͖ΔͩΖ͏ʁ •
2 masterworkerͷ "finished"Λ͍ͪૣ͘ݕ ͠ɺ࣍ͷjobΛৼΓ͍ͨɻͲ͏ ͬͨΒͰ͖ΔͩΖ͏ʁ worker worker worker master process
IPC • Ͳ͏ͬͯmasterͱworker௨৴͢Δͷ͕͍͍ͷ͔ • Ҋ1: File • master͕workerͷ"finished"Λૉૣ͘ݕͰ͖ͳ͍ɻinotifyͱ͔݁ߏ ͍ɻ •
Ҋ2: TCP/IP • େ͔͛͞ͳʁ • Ҋ3: pipe • ͦΕͧΕͷworkerʹૹ৴ɺड৴༻2ຊͷpipeΛܨ͙ͱΑͦ͞͏
select • Ͳ͏ͬͨΒɺmasterworkerͷ"finished"Λ ͍ͪૣ͘ݕͰ͖Δ͔ • workerpipeʹ݁ՌΛॻ͖ࠐΈɺmasterʹ "finished"Λ͑ΔͭΓ • Αͬͯ select(2)Ͱworkerͨͪʹܨ͕ΔpipeΛ
ࢹ͢Εɺ͍ͪૣ͘"finished"ΛݕͰ͖Δ
·ͱΊΔͱ • ϚϧνϓϩηεΛ࠾༻ • masterͱworkerΛ2ຊͷpipe Ͱͭͳ͙ • masterworker͔Βͷड৴ ༻pipeΛselect͢Δ͜ͱͰɺ workerͷ"finished"Λ͍ͪૣ
͘ݕͰ͖Δ worker worker worker master process pipe pipe pipe select
࣮ࡍͷcpmͷίʔυ master͕jobΛܭࢉ ready (= "finished")ͳworkerΛऔಘ (෦ͰpipeͨͪͷselectΛ͍ͯ͠Δ!) pipeΛ௨ͯ͠ͷworkerͱͷ௨৴෦Λ Parallel::PipesϞδϡʔϧͱͯ͠நԽ readyͳworkerʹjobΛૹ৴ ͜ͷίʔυʹCPAN
clientߴԽͷ΄ͱΜͲ͕٧·ͬͯΔ
࠷ޙʹ • cpmͷ࣮ʹ͍ͭͯͨ͠ • cpmૣ͍ͨ͘͠ͱͷࢥ͍Ͱ͍ͭͬͯͨ͘Βɺ "ͨ·ͨ·"͍·ͷ࣮ʹͳͬͨ • "Γ͔ͨͻͱͭ͡Όͳ͍" • Γ͍ͨ͜ͱɺࢼͯ͠Έ͍ͨ͜ͱ͕ͨ͘͞Μ͋Δ
• event driven CPAN clientॻ͖͍ͨʂ