Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Internal of cpm

Shoichi Kaji
July 05, 2018
580

Internal of cpm

shibuya.pm #18 2018/07/05

Shoichi Kaji

July 05, 2018
Tweet

Transcript

  1. Me • Shoichi Kaji • CPAN, github: skaji • co-maintainer

    of
 Minilla, Perl-Build, Text- Xslate, Mouse, Test-PAUSE- Permissions
  2. ໨࣍ • cpmͱ͸ʁ • CPAN client ߴ଎ԽͷϙΠϯτ(A), (B) • Ͳ͏΍ͬͯ"ͲΜͲΜ"jobΛফԽ͢Δ͔

    • jobͷத਎ • ϓϩάϥϜύϥμΠϜ • IPC • select • ࣮ࡍͷcpmͷίʔυ • ࠷ޙʹ
  3. CPAN clientߴ଎ԽͷϙΠϯτ(A) • Ͳ͏΍ͬͯɺಈతʹܾ·Δ΍Δ΂͖͜ͱ(= job)Λ
 ؅ཧ͢Δ͔ • ͸͡ΊʹΘ͔͍ͬͯΔͷ͸ʮModuleAͷΠϯετʔ ϧʯͱ͍͏ΰʔϧͷΈ •

    ModuleXͷґଘ͸ModuleXͷMakefile.PLΛ࣮ߦ͠ ͯ͸͡Ίͯ֬ఆ͢Δ • Ͳͷjobʹ͸ґଘؔ܎ʹ͋ΓɺͲͷjob͸ಠཱ͔
  4. 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
  5. ϓϩάϥϜύϥμΠϜ • ͲͷϓϩάϥϜύϥμΠϜΛ࠾༻͢Ε͹"ͲΜͲΜ"jobΛফԽͰ͖Δ͔ • Ҋ1: ϚϧνεϨου • ࢒೦ͳ͕ΒPerlͰεϨουϓϩάϥϛϯά͸ݫ͍͠ • Ҋ2:

    Event Driven • jobͷ࣮ࡍͷத਎͸֎෦ϓϩάϥϜ࣮ߦɺHTTP௨৴ͩͬͨɻΑͬͯEvent DrivenʹͽͬͨΓɻ͕ɺطଘͷCPAN clientͷίʔυΛ࢖͑ͳ͍ • Ҋ3: Ϛϧνϓϩηε • ·ͣ͸͜ΕͰ
  6. Ϛϧνϓϩηε • ϚϧνϓϩηεΛ࠾༻ʂ • ໰1: master͔Βworker΁job ͷૹ৴ɺworker͔Βmaster ΁݁Ռͷૹ৴Λ͍ͨ͠ɻͲ͏ ΍ͬͨΒͰ͖ΔͩΖ͏ʁ •

    ໰2 master͸workerͷ "finished"Λ͍ͪૣ͘ݕ஌ ͠ɺ࣍ͷjobΛৼΓ͍ͨɻͲ͏ ΍ͬͨΒͰ͖ΔͩΖ͏ʁ worker worker worker master process
  7. IPC • Ͳ͏΍ͬͯmasterͱworker͸௨৴͢Δͷ͕͍͍ͷ͔ • Ҋ1: File • master͕workerͷ"finished"Λૉૣ͘ݕ஌Ͱ͖ͳ͍ɻinotifyͱ͔݁ߏ஗ ͍ɻ •

    Ҋ2: TCP/IP • େ͔͛͞ͳʁ • Ҋ3: pipe • ͦΕͧΕͷworkerʹૹ৴ɺड৴༻2ຊͷpipeΛܨ͙ͱΑͦ͞͏