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

cpm at okinawa

cpm at okinawa

2016.08.27 okinawa.pm

E4967f90a08dadff9cc185b863cd99a7?s=128

Shoichi Kaji

August 27, 2016
Tweet

More Decks by Shoichi Kaji

Other Decks in Programming

Transcript

  1. cpm Shoichi Kaji

  2. About me • Shoichi Kaji • Born in 1984 •

    Born in Kanagawa, live in Tokyo • Work for Yahoo JAPAN • pause/github: skaji • perl5: cpm, Mojo::SlackRTM • perl6: mi6, frinfon
  3. cpm fast CPAN module installer

  4. None
  5. None
  6. cpm is 3x faster than cpanm

  7. ࠓ೔࿩͍ͨ͜͠ͱ • ͳͥcpmΛͭ͘Ζ͏ͱࢥ͔ͬͨ • ଎͞Λ࣮ݱ͢ΔͨΊͷ࣮૷Ҋ • CPAN moduleΠϯετʔϧฒྻԽ͸Կ͕໘౗͔ • ͦͷ໘౗͞Λ͍͔ʹγϯϓϧʹଊ͔͑ͨ

    • ࣮૷ͷΩʔϙΠϯτ • ݱঢ়ͷ࣮૷ • ࠓޙ
  8. ͳͥcpmΛͭ͘Ζ͏ͱࢥ͔ͬͨ • CPAN moduleΛ͍ͭ΋࢖͍ͬͯͨ (΋ͪΖΜࠓ΋) • ΋ͬͱ଎͘ΠϯετʔϧͰ͖Ε͹ͳɺͱ͍ͭ΋ࢥͬ ͍ͯͨ • CPAN

    moduleΠϯετʔϧ͸͋ΔछϒϥοΫϘο Ϋεͱͳ͍ͬͯͯखΛग़͢ਓ͸ඇৗʹݶΒΕ͍ͯͨ • ΋ͷ͸ࢼ͠ɺ΍ͬͯΈΑ͏
  9. ͳͥcpmΛͭ͘Ζ͏ͱࢥ͔ͬͨ • ଎͍ͨ͘͠ͱ͍͏ࢥ͍͕CPAN clientʹ࣮ࡍʹखΛग़ ͖͔͚ͬ͢Ͱ͋Δ͜ͱ͸ؒҧ͍ͳ͍͕ɺͦΕҎ֎ʹ΋ • CPANʹ·ͭΘΔऔΓܾΊΛ΋ͬͱγϯϓϧʹͰ͖ ͳ͍͔ɻͦ͏ͳΕ͹ɺࣗ෼ΛؚΊͯΈΜͳ΋ͬͱ؆ ୯ʹCPANΛhackͰ͖ΔΑ͏ʹͳΓָͦ͠͏ •

    ͱ͍͏ࢥ͍͕͋ͬͨɻͦͷ࣮ྫͱͳΔ΋Λ࢒͔ͨͬ͠ ͨɻ
  10. ଎͞Λ࣮ݱ͢ΔͨΊͷ࣮૷Ҋ • cpanm͸"௚ྻ"ʹCPAN moduleΛΠϯετʔϧ͍ͯͨ͘͠Ί ͋·Γ଎͘ͳ͍ɻͲ͏͢Δ͔ɻ(perl5Ͱ"଎͞"ΛٻΊΔͱ͢Ε ͹event driven or fork(2)ͱ͍͏͜ͱʹͳΔɻ) •

    (Ҋ1) event driven
 Ͱ͖ΔݶΓcpanmͷίʔυΛ࠶ར༻͔ͨͬͨ͠ɻevent drivenͷίʔυͷதͰcpanmΛ࢖͏ͷ͸ͪΐͬͱແཧɻ • (Ҋ2) forkΛ࢖͏
 ·͋ͪ͜ΒͰɻ
  11. CPAN moduleฒྻԽ͸
 Կ͕໘౗͔ • ࣄલʹ͢΂ͯͷtask͕ܾ·͍ͬͯͳ͍ɻ
 ྫ͑͹ PlackΛΠϯετʔϧ͠Α͏ͱ͢Δͱ͖ • ࠷ॳ͸"PlackΠϯετʔϧ"ͱ͍͏task͚͕ͩͩ •

    ͦΕͷmetadataΛfetchͨ͠ஈ֊ͰॳΊͯ File::ShareDir::InstallͷΠϯετʔϧ΋ඞཁͩͱൃ֮͢Δɻ • ͞ΒʹFSDIͷmetadataΛfetch͢ΔͱModule::Build::Tiny ΋ඞཁͩͱൃ֮͢Δɻblah blah blah…
  12. ͦͷ໘౗͞Λ͍͔ʹ
 γϯϓϧʹଊ͔͑ͨ • (1) "CPAN moduleΠϯετʔϧ"Λɺ
 ಠཱͰ࣮ߦՄೳͳࡉ͔͍taskʹ෼͚Δɻ(ࠓճ͸ ͜ͷઆ໌লུ) • (2)

    ͦͷtaskΛworkerʹৼΓɺ݁ՌΛऩूͯ͠ɺ ͞Βʹ৽ͨͳtask͕ੜ·ΕΕ͹ɺ࠶ͼworkerʹ ৼΔɻ͜ΕΛtask͕ͳ͘ͳΔ·Ͱ܁Γฦ͢ɻ
  13. (2)ͷ࣮૷ΩʔϙΠϯτ • (point1) workerʹtaskΛৼΔɺͦͯͦ͠ͷ݁Ռ Λऩू͢ΔͨΊʹ͸ɺԿ͔͠ΒͷIPC͕ඞཁ • (point2) ৽ͨͳtask͕ੜ·Εͨͱ͖ɺfinished/ readyͳworkerΛૉૣ͘ݕ஌ͦ͠ͷworkerʹ taskΛৼΔ࢓૊Έ͕ඞཁ


    ૉૣ͘ͱ͍͏ͱ͜Ζ͕ॏཁͰɺ͜Ε͕஗͍ͱ༡Μ Ͱ͍Δ͕࣌ؒ૿͑ͯશ͘଎͞ʹͭͳ͕Βͳ͍
  14. • ͸͡ΊIPCͱͯ͠ϑΝΠϧΛ࢖͍ɺwoker͔Βͷ ݁Ռͷฦ٫͸ϑΝΠϧʹͦΕΛॻ͘͜ͱͰ࣮ݱ ͠Α͏ͱͨ͠ɻ(ۮવkarupa͞Μͱ͔Ϳͬͨw) • ͦͯ͠filesystemͷchange notifyʹΑͬͯ workerͷfinishedΛݕ஌͠Α͏ͱͨ͠ɻ • …

    ஗͗ͯ͢ෆ࠾༻ɻ
  15. ݱঢ়ͷ࣮૷ • ݁ہɺIPCͱͯ͠pipe(2)Λ࢖͏͜ͱʹͨ͠ɻworkerͱ ͷؒʹ2ຊͷpipeΛ௨ͯ͠૒ํ޲Ͱ௨৴Ͱ͖ΔΑ͏ʹɻ • finishedͳworkerݕ஌͸select(2)Λ࢖͏ɻ • ظ଴௨Γͷ଎͞ͰfinishedΛݕ஌Ͱ͖ͨ • ݁Ռɺcpanm

    3xͷ଎͞ͰCPAN moduleΛΠϯετʔ ϧͰ͖ΔΑ͏ʹͳͬͨ
  16. worker worker worker worker main process Parallel::Pipes pipes pipes pipes

    pipes ݱঢ়ͷ࣮૷ (Πϝʔδ)
  17. ࠓޙ • cpm is a fast CPAN module installer •

    cpmΛsandboxͱͯ͠CPANͷ͋Δ΂͖࢟Λ໛ࡧͨ͠ ͍ • Ͱɺcpanmʹ͍͍ͱ͜ΖΛؐݩ͢Δʂ • cpmͷparallelͷ෦෼͸Parallel::Pipesͱͯ͠Ϟδϡʔ ϧʹ෼཭ͤͨ͞ɻଞʹ΋Ԡ༻Մೳͩͱࢥ͍ͬͯΔͷͰɺ ୭͔ʹ࢖ͬͯ΋Β͍͍ͨ :-)