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

cpm at YAPC

cpm at YAPC

YAPC::Fukuoka 2017 HAKATA, 2017/07/01

E4967f90a08dadff9cc185b863cd99a7?s=128

Shoichi Kaji

July 01, 2017
Tweet

More Decks by Shoichi Kaji

Other Decks in Technology

Transcript

  1. cpm Shoichi Kaji

  2. Me Shoichi Kaji Perl 5/6 Lover Work at Yahoo JAPAN

  3. Agenda • What is cpm? • Features • cpm͕Ͱ͖Δ·Ͱ •

    Motivation • ࢼߦࡨޡͱ࢓૊Έͱ࣮૷
  4. What is cpm?

  5. Yet Another CPAN client (like CPAN.pm, CPANP, cpanm)

  6. Actually, cpm is not new, but it uses cpanm in

    parallel.
  7. Features • 1) Fast • 2) Self-contained, zero-dependency
 works fine

    with Perl 5.8.1 • 3) Flexible resolvers • 4) Support static-install • 5) Support prebuilt
 This is (of course!) inspired by Carmel
  8. Fast https://asciinema.org/a/127042

  9. cpm is 3x faster than cpanm

  10. Self-contained https://asciinema.org/a/127049

  11. Can be used in travisci curl -sL https://git.io/cpm | perl

    - install -g
  12. Prebuilt https://asciinema.org/a/127045

  13. Keeps builds in ~/.perl-cpm, and never fetch/build them again. I

    believe this is a big change.
  14. cpm͕Ͱ͖Δ·Ͱ

  15. Motivation • ๻͸ ೔ʑPerl5Λॻ͍͍ͯΔ • CPAN moduleͷΠϯετʔϧʹ͸cpanmΛ࢖͓ͬͯΓɺͦͷit just works͞ʹ ͍ͭ΋ײ৺ͤ͞ΒΕ͍ͯͨ

    • ҰํͰɺԼهͷཧ༝ʹΑΓmoduleΛΠϯετʔϧ͢Δػձ͸૿͍͑ͯΔ • Project͝ͱʹmoduleΛ؅ཧ͢Δͷ͕ҰൠతʹɻCartonͷొ৔ • CIͷਁಁ • ΠϯϑϥͷΫϥ΢υԽ • moduleͷΠϯετʔϧΛͱʹ͔͘଎͍ͨ͘͠
  16. ·ͣߟ͑ͨ͜ͱ • cpanm͸࢖͍͍ͨɻฒྻԽɾฒߦԽ͢Ε͹଎͘ͳΓͦ͏ • ૉ๿ʹߟ͑Δͱ cat modules | xargs cpanm

    • ແཧ • ཧ༝1: ࣄલʹΠϯετʔϧ͢΂͖moduleҰཡ͸෼͔͍ͬͯͳ ͍ • ཧ༝2: Ծʹ෼͔͍ͬͯͨͱͯ͠΋ɺґଘؔ܎Λຬͨͨ͢Ίʹ workerͷಉظ͕ඞཁ͕ͩɺ·͍ͬͨͯ͘͠ͳ͍
  17. ࣍ʹߟ͑ͨ͜ͱ • ࣄલʹґଘؔ܎શମΛ஌Δ͜ͱ͕Ͱ͖Ε͹͍͍͔ • treeঢ়ʹͳΒ΂ɺ༏ઌ౓Λ͚ͭɺద੾ʹΠϯετʔϧॱΛεέδϡʔϦϯά͢Δ ͱ͍͍͔ • ͢Ͱʹ͜Εʹؔ࿈͢Δཧ࿦͋Γͦ͏͕ͩɺͲ͔͜ΒखΛ͚͍͍͔ͭͯ • ҰํͰɺݱࡏCPANʹ͸ґଘؔ܎Λऔಘ͢ΔAPI͸ͳ͍

    • ࣗ෼Ͱ࡞Δ͔ • ͍΍ɺͦ΋ͦ΋CPAN͸ґଘؔ܎͕ಈతʹมΘΔ͜ͱΛڐ༰͍ͯͯ͠ɺstaticͳ API͸࡞Δ͜ͱ͕Ͱ͖ͳͦ͏ • … ਺ϲ݄ਐలͳ͠
  18. Ұ୴ࢭ·ͬͯ • ࣗ෼ʹΘ͔Δͱ͜Ζ͔ΒɺͳΔ΂͘γϯϓϧʹ ߟ͑Α͏ • CPAN moduleͷinstallΛ΋͏গ͠෼ղͯ͠ΈΔ • ͦͯ͠Ͳ͕͜ฒྻͰ࣮ߦͰ͖Δͱ͜Ζ͔ɺ
 Ͳ͔͜ಉظ͠ͳ͍ͱ͍͚ͳ͍ͱ͜Ζ͔ߟ͑ͯΈ

    Δ
  19. CPAN module install෼ղ • Resolve: Plack -> http://cpan.org/…/Plack-1.0041.tar.gz • Fetch:

    wget http://cpan.org/…/Plack-1.0041.tar.gz • Get conf reqs: File::ShareDir::Install => Go to install of F::SD::I • Configure: perl Makefile.PL • Get reqs: URI, Try::Tiny… => Go to install of URI, Try::Tiny… • Build: make build • Install: make install Block untill configure reqs are installed Block untill reqs are installed
  20. CPAN module install෼ղ • Resolve • Fetch
 (Get conf reqsؚΉ)

    • Configure
 (Get reqsؚΉ) • Install
 (Build΋ؚΉ) ಉظ͕ඞཁ } } } } ಠཱ࣮ͯ͠ߦՄೳ ಉظ͕ඞཁ ಠཱ࣮ͯ͠ߦՄೳ ಠཱ࣮ͯ͠ߦՄೳ ಠཱ࣮ͯ͠ߦՄೳ ಉظ͕ඞཁ
  21. CPAN module install෼ղ • ಠཱ࣮ͯ͠ߦՄೳͳjobʹ෼͚Δ͜ͱ͕Ͱ͖ͨ • ґଘ͕ղܾ͞Ε࣮ߦՄೳʹͳͬͨjobΛpoolʹͭ ΊɺͲΜͲΜ࣮ߦ͍͚ͯ͠͹Αͦ͞͏ɻ • ฒྻʹ

  22. Resolve Fetch Configure Install Plack Resolve Fetch Configure Install Try::Tiny

    Resolve Fetch Configure Install URI Resolve Fetch Configure Install F::SD::I Job Pool Plack, Resolve F::SD::I, Fetch URI, Rsolve, Try::Tiny, Resolve Plack, Fetch F::SD::I, Resolve Plack, Configure … … … … … Installation of Plack
  23. Poolʹཷ·ͬͨjobΛ
 Ͳ͏ฒྻͰ࣮ߦ͢Δ͔ • PerlͰ͸forkͰworkerϓϩηεΛཱͯฒྻԽ͢Δͷ͕ී௨ • ͦͷworkerʹjobΛ౉͠ɺͦͯ݁͠ՌΛಘ͍ͨ • ཁ݅: workerͷऴྃΛ͍ͪૣ͘ݕ஌͠ɺͰ͖ΔݶΓ଎݁͘Ռ Λಘ͍ͨ

    • pipe2ຊͰworkerͱ݁ͼɺselectͰworkerͷऴྃΛݕ஌͢ Ε͹͍͍
  24. Poolʹཷ·ͬͨjobΛ
 Ͳ͏ฒྻͰ࣮ߦ͢Δ͔ Job Pool Plack, Resolve F::SD::I, Fetch URI, Rsolve,

    Try::Tiny, Resolve Plack, Fetch F::SD::I, Resolve Plack, Configure … … XPSLFS XPSLFS XPSLFS pipe pipe pipe pipe pipe pipe select
  25. Installation of Plack https://asciinema.org/a/127072

  26. ·ͱΊͱࠓޙ • cpm is yet another CPAN client, which is

    fast • It parallelizes cpanm and synchronizes them by fork/pipe/select
  27. ·ͱΊͱࠓޙ • CPAN·ΘΓʹ͸
 * static install
 * central repository introduced

    by Carmel
 ͳͲɺ͍͔ͭ͘৽͍͠γϯϓϧͳΞΠσΞ͕͋Δ • ͥͻͦ͏͍͏ੈքʹม͍͖͍͑ͯͨ • ઌʹɺCPAN͸ґଘؔ܎͕ಈతʹมΘΔ͜ͱΛڐ༰͍ͯ͠Δͱ͍ͬͨɻ
 ҰํͰԾʹґଘؔ܎͕੩తʹऔಘͰ͖Δ͜ͱΛલఏͱͰ͖ΔͳΒ͹ CPAN client͸ ͞ΒʹΦϓςΟϚΠζͰ͖Δɻ͜ͷՄೳੑΛ୳Γ͍ͨɻ
 charsbar͞Μᐌ͘ɺMETA v3ɺPAUSE New Index 07(?)ΛఏҊ͢Δͷ͸͍ͭͰ΋ openͱͷ͜ͱ:) • ·ͩ·ͩ΍Δ͜ͱ͕ͨ͘͞Μ͋Δɻ·ͨԿͰ΋Ͱ͖Δ