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
580
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
3.6k
昔のGo, 今のGo ~比較, ソート編~
skaji
0
180
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
580
Writing Perl with w0rp/ale
skaji
0
2.2k
nginx unit
skaji
0
44
Perl6 ecosystem
skaji
1
1.4k
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
Visualization
eitanlees
146
15k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Mobile First: as difficult as doing things right
swwweet
222
9k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Writing Fast Ruby
sferik
628
61k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
A Philosophy of Restraint
colly
203
16k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
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ॻ͖͍ͨʂ