Slide 1

Slide 1 text

cpm Shoichi Kaji

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Agenda • What is cpm? • Features • cpm͕Ͱ͖Δ·Ͱ • Motivation • ࢼߦࡨޡͱ࢓૊Έͱ࣮૷

Slide 4

Slide 4 text

What is cpm?

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Fast https://asciinema.org/a/127042

Slide 9

Slide 9 text

cpm is 3x faster than cpanm

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

Prebuilt https://asciinema.org/a/127045

Slide 13

Slide 13 text

Keeps builds in ~/.perl-cpm, and never fetch/build them again. I believe this is a big change.

Slide 14

Slide 14 text

cpm͕Ͱ͖Δ·Ͱ

Slide 15

Slide 15 text

Motivation • ๻͸ ೔ʑPerl5Λॻ͍͍ͯΔ • CPAN moduleͷΠϯετʔϧʹ͸cpanmΛ࢖͓ͬͯΓɺͦͷit just works͞ʹ ͍ͭ΋ײ৺ͤ͞ΒΕ͍ͯͨ • ҰํͰɺԼهͷཧ༝ʹΑΓmoduleΛΠϯετʔϧ͢Δػձ͸૿͍͑ͯΔ • Project͝ͱʹmoduleΛ؅ཧ͢Δͷ͕ҰൠతʹɻCartonͷొ৔ • CIͷਁಁ • ΠϯϑϥͷΫϥ΢υԽ • moduleͷΠϯετʔϧΛͱʹ͔͘଎͍ͨ͘͠

Slide 16

Slide 16 text

·ͣߟ͑ͨ͜ͱ • cpanm͸࢖͍͍ͨɻฒྻԽɾฒߦԽ͢Ε͹଎͘ͳΓͦ͏ • ૉ๿ʹߟ͑Δͱ cat modules | xargs cpanm • ແཧ • ཧ༝1: ࣄલʹΠϯετʔϧ͢΂͖moduleҰཡ͸෼͔͍ͬͯͳ ͍ • ཧ༝2: Ծʹ෼͔͍ͬͯͨͱͯ͠΋ɺґଘؔ܎Λຬͨͨ͢Ίʹ workerͷಉظ͕ඞཁ͕ͩɺ·͍ͬͨͯ͘͠ͳ͍

Slide 17

Slide 17 text

࣍ʹߟ͑ͨ͜ͱ • ࣄલʹґଘؔ܎શମΛ஌Δ͜ͱ͕Ͱ͖Ε͹͍͍͔ • treeঢ়ʹͳΒ΂ɺ༏ઌ౓Λ͚ͭɺద੾ʹΠϯετʔϧॱΛεέδϡʔϦϯά͢Δ ͱ͍͍͔ • ͢Ͱʹ͜Εʹؔ࿈͢Δཧ࿦͋Γͦ͏͕ͩɺͲ͔͜ΒखΛ͚͍͍͔ͭͯ • ҰํͰɺݱࡏCPANʹ͸ґଘؔ܎Λऔಘ͢ΔAPI͸ͳ͍ • ࣗ෼Ͱ࡞Δ͔ • ͍΍ɺͦ΋ͦ΋CPAN͸ґଘؔ܎͕ಈతʹมΘΔ͜ͱΛڐ༰͍ͯͯ͠ɺstaticͳ API͸࡞Δ͜ͱ͕Ͱ͖ͳͦ͏ • … ਺ϲ݄ਐలͳ͠

Slide 18

Slide 18 text

Ұ୴ࢭ·ͬͯ • ࣗ෼ʹΘ͔Δͱ͜Ζ͔ΒɺͳΔ΂͘γϯϓϧʹ ߟ͑Α͏ • CPAN moduleͷinstallΛ΋͏গ͠෼ղͯ͠ΈΔ • ͦͯ͠Ͳ͕͜ฒྻͰ࣮ߦͰ͖Δͱ͜Ζ͔ɺ
 Ͳ͔͜ಉظ͠ͳ͍ͱ͍͚ͳ͍ͱ͜Ζ͔ߟ͑ͯΈ Δ

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

CPAN module install෼ղ • Resolve • Fetch
 (Get conf reqsؚΉ) • Configure
 (Get reqsؚΉ) • Install
 (Build΋ؚΉ) ಉظ͕ඞཁ } } } } ಠཱ࣮ͯ͠ߦՄೳ ಉظ͕ඞཁ ಠཱ࣮ͯ͠ߦՄೳ ಠཱ࣮ͯ͠ߦՄೳ ಠཱ࣮ͯ͠ߦՄೳ ಉظ͕ඞཁ

Slide 21

Slide 21 text

CPAN module install෼ղ • ಠཱ࣮ͯ͠ߦՄೳͳjobʹ෼͚Δ͜ͱ͕Ͱ͖ͨ • ґଘ͕ղܾ͞Ε࣮ߦՄೳʹͳͬͨjobΛpoolʹͭ ΊɺͲΜͲΜ࣮ߦ͍͚ͯ͠͹Αͦ͞͏ɻ • ฒྻʹ

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

Poolʹཷ·ͬͨjobΛ
 Ͳ͏ฒྻͰ࣮ߦ͢Δ͔ • PerlͰ͸forkͰworkerϓϩηεΛཱͯฒྻԽ͢Δͷ͕ී௨ • ͦͷworkerʹjobΛ౉͠ɺͦͯ݁͠ՌΛಘ͍ͨ • ཁ݅: workerͷऴྃΛ͍ͪૣ͘ݕ஌͠ɺͰ͖ΔݶΓ଎݁͘Ռ Λಘ͍ͨ • pipe2ຊͰworkerͱ݁ͼɺselectͰworkerͷऴྃΛݕ஌͢ Ε͹͍͍

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

Installation of Plack https://asciinema.org/a/127072

Slide 26

Slide 26 text

·ͱΊͱࠓޙ • cpm is yet another CPAN client, which is fast • It parallelizes cpanm and synchronizes them by fork/pipe/select

Slide 27

Slide 27 text

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