SlideShare a Scribd company logo
Why
a new CPAN client
cpm is fast
Shoichi Kaji
Me
• Shoichi Kaji
• Tokyo, Japan
• pause/github: skaji
• Perl5: cpm, App::FatPacker::Simple,
Mojo::SlackRTM
• Perl6: mi6, Frinfon, evalbot in Slack:)
Agenda
• What is cpm, and why?
• cpanm VS cpm
• The internal of cpm
• divide installing processes into pieaces
• learn from go language
• Roadmap
Q: What is cpm?
A: It’s yet another
CPAN client
Why a new CPAN client?
• Yes, I always use cpanm to install CPAN
modules. It’s awesome!
• Because cpanm installs modules in series,

it takes quite a lot of time to install a module
that has many dependencies
I want to install
CPAN modules
as fast as possible
Why a new CPAN client?
• So I created cpm
• Actually cpm is not a new CPAN client,

but it uses cpanm in parallel,

so that it can install CPAN modules much
faster
How fast?
cpanm VS cpm
installing Plack
cpanm
cpm
cpanm: 30sec
cpm: 10sec
cpm is 3x faster than cpanm!
Why cpm is so fast?
— The internal of cpm —
First, let’s think simple
$ cat modules | xargs cpanm
Can we just use xargs to parallelize cpanm?
NO, WE CAN’T.
The problem with
• The modules to be installed are not determined in advance.
• Even if you have a list of modules to be installed, cpanm
workers will be broken unless you synchronize cpanm
workers
• So we have to
• (1) divide installing process of CPAN module into pieces
that can be executed individually
• (2) synchronize cpanm workers in some way
$ cat modules | xargs cpanm
(1) Divide installing process
of CPAN modules
sub installing_process {
my $module = shift;
# 1. resolve
# query cpanmetadb
my $dist_url = resolve($module);
# 2. fetch (and extract)
# wget && tar xzf && read META.json
my ($dir, @configure_deps) = fetch($dist_url);
install_module($_) for @configure_deps;
# 3. configure
# perl Makefile.PL/Build.PL && read MYMETA.json
my @deps = configure($dir);
install_module($_) for @deps;
# 4. install
# make install (or ./Build install)
install($dir);
}
I divided the process
into 4 jobs:
* resolve
* fetch
* configure
* install
which are
independent
(2) synchronize
cpanm workers
Take a look at go language…
go introduces two concurrency primitives:
* goroutines
* channels
They are very simple but powerful.
func work(in <-chan string, out chan<- string) {
for {
job := <-in
// do work with job
out <- "result"
}
}
func main() {
in := make(chan string)
out := make(chan string)
go work(in, out)
in <- "job"
result := <-out
}
Take a look at go language…
func main() {
in1 := make(chan string)
out1 := make(chan string)
go work(in1, out1)
in2 := make(chan string)
out2 := make(chan string)
go work(in2, out2)
in1 <- "job1"
in2 <- "job2"
select {
case result1 := <-out1:
// do something with result1
case result2 := <-out2:
// do something with result2
}
}
It is very easy to
increase workers
You can use select() to
await multiple channels
simultaneously
Can we adopt this
idea to Perl5?
Of cource, we can.
go <-> Perl5
go Perl5
goroutine fork(2)
channel pipe(2)
select select(2)
The internal of cpm
Master
cpnam
worker
cpnam
worker
cpnam
worker
select
pipe x 2
pipe x 2 pipe x 2
cpanm worker
1. get job via pipe
2. work, work, work!
3. send result via pipe
Master
1. prepare pipes for
workers by pipe(2)
2. launch workers by
fork(2) and connect
them with pipes
3. loop {

calculate jobs and send
jobs to idle workers. if
all workers are busy,
then wait them and
recieve results by
select(2)

}
Roadmap
• Last year I talked with Tatsuhiko Miyagawa
about cpanm 2.0 (menlo)
• Then he said “why don’t you merge cpm into
cpanm itself?”
• I was very happy to hear that!
Roadmap
• So if you all find cpm is useful and stable,
then cpm should be merged into cpanm 2.0
• Before merging, there are some problems
that need to be resolved:
• The log file is very messy
• I will highly appreciate your feedback!
try cpm now
$ cpanm -nq App::cpm
thanks!

More Related Content

What's hot

Write a redis client of your own
Write a redis client of your ownWrite a redis client of your own
Write a redis client of your own
Chao Gao
 
Wrapping java in awesomeness aka condensator
Wrapping java in awesomeness aka condensatorWrapping java in awesomeness aka condensator
Wrapping java in awesomeness aka condensator
Flowa Oy
 
Benchmarking and PHPBench
Benchmarking and PHPBenchBenchmarking and PHPBench
Benchmarking and PHPBench
dantleech
 
Async/Await: TPL & Message Pumps
Async/Await: TPL & Message Pumps Async/Await: TPL & Message Pumps
Async/Await: TPL & Message Pumps
Particular Software
 
Async/Await Best Practices
Async/Await Best PracticesAsync/Await Best Practices
Async/Await Best Practices
Particular Software
 
JavaScript Task Runners - Gulp & Grunt
JavaScript Task Runners - Gulp & GruntJavaScript Task Runners - Gulp & Grunt
JavaScript Task Runners - Gulp & Grunt
Lohith Goudagere Nagaraj
 
Javascript internals
Javascript internalsJavascript internals
Javascript internals
Ayush Sharma
 
Gulp: Your Build Process Will Thank You
Gulp: Your Build Process Will Thank YouGulp: Your Build Process Will Thank You
Gulp: Your Build Process Will Thank You
RadWorks
 
Conejo Architecture
Conejo ArchitectureConejo Architecture
Conejo Architecture
paulosuzart
 
Enforcing coding standards
Enforcing coding standardsEnforcing coding standards
Enforcing coding standards
Sebastiano Armeli
 
Ansible Israel Kickoff Meetup
Ansible Israel Kickoff MeetupAnsible Israel Kickoff Meetup
Ansible Israel Kickoff Meetup
ansibleil
 
Large-Scale Training with GPUs at Facebook
Large-Scale Training with GPUs at FacebookLarge-Scale Training with GPUs at Facebook
Large-Scale Training with GPUs at Facebook
Faisal Siddiqi
 
JavaScript code academy - introduction
JavaScript code academy - introductionJavaScript code academy - introduction
JavaScript code academy - introduction
Jaroslav Kubíček
 
Qtpvbscripttrainings
QtpvbscripttrainingsQtpvbscripttrainings
QtpvbscripttrainingsRamu Palanki
 
OSCamp #4 on Foreman | Ansible automation for Foreman by Ondřej Ezr
OSCamp #4 on Foreman | Ansible automation for Foreman by Ondřej EzrOSCamp #4 on Foreman | Ansible automation for Foreman by Ondřej Ezr
OSCamp #4 on Foreman | Ansible automation for Foreman by Ondřej Ezr
NETWAYS
 
Simple http and jms for beginners
Simple http and jms for beginnersSimple http and jms for beginners
Simple http and jms for beginners
Christian Hipolito
 
Simple Tips and Tricks with Ansible
Simple Tips and Tricks with AnsibleSimple Tips and Tricks with Ansible
Simple Tips and Tricks with Ansible
Keith Resar
 
How go makes us faster (May 2015)
How go makes us faster (May 2015)How go makes us faster (May 2015)
How go makes us faster (May 2015)
Wilfried Schobeiri
 

What's hot (20)

Write a redis client of your own
Write a redis client of your ownWrite a redis client of your own
Write a redis client of your own
 
Capistrano Overview
Capistrano OverviewCapistrano Overview
Capistrano Overview
 
Wrapping java in awesomeness aka condensator
Wrapping java in awesomeness aka condensatorWrapping java in awesomeness aka condensator
Wrapping java in awesomeness aka condensator
 
Benchmarking and PHPBench
Benchmarking and PHPBenchBenchmarking and PHPBench
Benchmarking and PHPBench
 
Async/Await: TPL & Message Pumps
Async/Await: TPL & Message Pumps Async/Await: TPL & Message Pumps
Async/Await: TPL & Message Pumps
 
Async/Await Best Practices
Async/Await Best PracticesAsync/Await Best Practices
Async/Await Best Practices
 
JavaScript Task Runners - Gulp & Grunt
JavaScript Task Runners - Gulp & GruntJavaScript Task Runners - Gulp & Grunt
JavaScript Task Runners - Gulp & Grunt
 
Javascript internals
Javascript internalsJavascript internals
Javascript internals
 
Gulp: Your Build Process Will Thank You
Gulp: Your Build Process Will Thank YouGulp: Your Build Process Will Thank You
Gulp: Your Build Process Will Thank You
 
Conejo Architecture
Conejo ArchitectureConejo Architecture
Conejo Architecture
 
Enforcing coding standards
Enforcing coding standardsEnforcing coding standards
Enforcing coding standards
 
Gcc opt
Gcc optGcc opt
Gcc opt
 
Ansible Israel Kickoff Meetup
Ansible Israel Kickoff MeetupAnsible Israel Kickoff Meetup
Ansible Israel Kickoff Meetup
 
Large-Scale Training with GPUs at Facebook
Large-Scale Training with GPUs at FacebookLarge-Scale Training with GPUs at Facebook
Large-Scale Training with GPUs at Facebook
 
JavaScript code academy - introduction
JavaScript code academy - introductionJavaScript code academy - introduction
JavaScript code academy - introduction
 
Qtpvbscripttrainings
QtpvbscripttrainingsQtpvbscripttrainings
Qtpvbscripttrainings
 
OSCamp #4 on Foreman | Ansible automation for Foreman by Ondřej Ezr
OSCamp #4 on Foreman | Ansible automation for Foreman by Ondřej EzrOSCamp #4 on Foreman | Ansible automation for Foreman by Ondřej Ezr
OSCamp #4 on Foreman | Ansible automation for Foreman by Ondřej Ezr
 
Simple http and jms for beginners
Simple http and jms for beginnersSimple http and jms for beginners
Simple http and jms for beginners
 
Simple Tips and Tricks with Ansible
Simple Tips and Tricks with AnsibleSimple Tips and Tricks with Ansible
Simple Tips and Tricks with Ansible
 
How go makes us faster (May 2015)
How go makes us faster (May 2015)How go makes us faster (May 2015)
How go makes us faster (May 2015)
 

Similar to Why a new CPAN client cpm is fast

Modern Commandline Tool
Modern Commandline ToolModern Commandline Tool
Modern Commandline ToolYuji Shimada
 
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
Tsundere Chen
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
p3castro
 
Make your CPAN module static installable
Make your CPAN module static installableMake your CPAN module static installable
Make your CPAN module static installable
Shoichi Kaji
 
Capistrano
CapistranoCapistrano
Capistrano
Travis Roberts
 
CPAN Training
CPAN TrainingCPAN Training
CPAN Training
Pedro Figueiredo
 
CS4961-L9.ppt
CS4961-L9.pptCS4961-L9.ppt
CS4961-L9.ppt
MarlonMagtibay2
 
perlbrew yapcasia 2010
perlbrew yapcasia 2010perlbrew yapcasia 2010
perlbrew yapcasia 2010
Kang-min Liu
 
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
katherncarlyle
 
Revisiting ppm
Revisiting ppmRevisiting ppm
Revisiting ppm
charsbar
 
Php task runners
Php task runnersPhp task runners
Php task runners
Ignacio Velazquez
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development Workflow
Jeffery Smith
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)goccy
 
End to-end async and await
End to-end async and awaitEnd to-end async and await
End to-end async and awaitvfabro
 
Angular4 kickstart
Angular4 kickstartAngular4 kickstart
Angular4 kickstart
Foyzul Karim
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
Tomas Doran
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet
 
Debugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBDebugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDB
bmbouter
 
OpenPOWER Application Optimization
OpenPOWER Application Optimization OpenPOWER Application Optimization
OpenPOWER Application Optimization
Ganesan Narayanasamy
 
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Devel::NYTProf 2009-07 (OUTDATED, see 201008)Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Tim Bunce
 

Similar to Why a new CPAN client cpm is fast (20)

Modern Commandline Tool
Modern Commandline ToolModern Commandline Tool
Modern Commandline Tool
 
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
PyCon TW 2017 - PyPy's approach to construct domain-specific language runtime...
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
Make your CPAN module static installable
Make your CPAN module static installableMake your CPAN module static installable
Make your CPAN module static installable
 
Capistrano
CapistranoCapistrano
Capistrano
 
CPAN Training
CPAN TrainingCPAN Training
CPAN Training
 
CS4961-L9.ppt
CS4961-L9.pptCS4961-L9.ppt
CS4961-L9.ppt
 
perlbrew yapcasia 2010
perlbrew yapcasia 2010perlbrew yapcasia 2010
perlbrew yapcasia 2010
 
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
#define ENABLE_COMMANDER#define ENABLE_REPORTER#include c.docx
 
Revisiting ppm
Revisiting ppmRevisiting ppm
Revisiting ppm
 
Php task runners
Php task runnersPhp task runners
Php task runners
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development Workflow
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
End to-end async and await
End to-end async and awaitEnd to-end async and await
End to-end async and await
 
Angular4 kickstart
Angular4 kickstartAngular4 kickstart
Angular4 kickstart
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
 
Debugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBDebugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDB
 
OpenPOWER Application Optimization
OpenPOWER Application Optimization OpenPOWER Application Optimization
OpenPOWER Application Optimization
 
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Devel::NYTProf 2009-07 (OUTDATED, see 201008)Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
 

Recently uploaded

Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 

Recently uploaded (20)

Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 

Why a new CPAN client cpm is fast

  • 1. Why a new CPAN client cpm is fast Shoichi Kaji
  • 2. Me • Shoichi Kaji • Tokyo, Japan • pause/github: skaji • Perl5: cpm, App::FatPacker::Simple, Mojo::SlackRTM • Perl6: mi6, Frinfon, evalbot in Slack:)
  • 3. Agenda • What is cpm, and why? • cpanm VS cpm • The internal of cpm • divide installing processes into pieaces • learn from go language • Roadmap
  • 4. Q: What is cpm?
  • 5. A: It’s yet another CPAN client
  • 6. Why a new CPAN client? • Yes, I always use cpanm to install CPAN modules. It’s awesome! • Because cpanm installs modules in series,
 it takes quite a lot of time to install a module that has many dependencies
  • 7. I want to install CPAN modules as fast as possible
  • 8. Why a new CPAN client? • So I created cpm • Actually cpm is not a new CPAN client,
 but it uses cpanm in parallel,
 so that it can install CPAN modules much faster
  • 9. How fast? cpanm VS cpm installing Plack
  • 10. cpanm
  • 11. cpm
  • 12. cpanm: 30sec cpm: 10sec cpm is 3x faster than cpanm!
  • 13. Why cpm is so fast? — The internal of cpm —
  • 14. First, let’s think simple $ cat modules | xargs cpanm Can we just use xargs to parallelize cpanm? NO, WE CAN’T.
  • 15. The problem with • The modules to be installed are not determined in advance. • Even if you have a list of modules to be installed, cpanm workers will be broken unless you synchronize cpanm workers • So we have to • (1) divide installing process of CPAN module into pieces that can be executed individually • (2) synchronize cpanm workers in some way $ cat modules | xargs cpanm
  • 16. (1) Divide installing process of CPAN modules sub installing_process { my $module = shift; # 1. resolve # query cpanmetadb my $dist_url = resolve($module); # 2. fetch (and extract) # wget && tar xzf && read META.json my ($dir, @configure_deps) = fetch($dist_url); install_module($_) for @configure_deps; # 3. configure # perl Makefile.PL/Build.PL && read MYMETA.json my @deps = configure($dir); install_module($_) for @deps; # 4. install # make install (or ./Build install) install($dir); } I divided the process into 4 jobs: * resolve * fetch * configure * install which are independent
  • 18. Take a look at go language… go introduces two concurrency primitives: * goroutines * channels They are very simple but powerful. func work(in <-chan string, out chan<- string) { for { job := <-in // do work with job out <- "result" } } func main() { in := make(chan string) out := make(chan string) go work(in, out) in <- "job" result := <-out }
  • 19. Take a look at go language… func main() { in1 := make(chan string) out1 := make(chan string) go work(in1, out1) in2 := make(chan string) out2 := make(chan string) go work(in2, out2) in1 <- "job1" in2 <- "job2" select { case result1 := <-out1: // do something with result1 case result2 := <-out2: // do something with result2 } } It is very easy to increase workers You can use select() to await multiple channels simultaneously
  • 20. Can we adopt this idea to Perl5?
  • 22. go <-> Perl5 go Perl5 goroutine fork(2) channel pipe(2) select select(2)
  • 23. The internal of cpm Master cpnam worker cpnam worker cpnam worker select pipe x 2 pipe x 2 pipe x 2 cpanm worker 1. get job via pipe 2. work, work, work! 3. send result via pipe Master 1. prepare pipes for workers by pipe(2) 2. launch workers by fork(2) and connect them with pipes 3. loop {
 calculate jobs and send jobs to idle workers. if all workers are busy, then wait them and recieve results by select(2)
 }
  • 24. Roadmap • Last year I talked with Tatsuhiko Miyagawa about cpanm 2.0 (menlo) • Then he said “why don’t you merge cpm into cpanm itself?” • I was very happy to hear that!
  • 25. Roadmap • So if you all find cpm is useful and stable, then cpm should be merged into cpanm 2.0 • Before merging, there are some problems that need to be resolved: • The log file is very messy • I will highly appreciate your feedback!
  • 26. try cpm now $ cpanm -nq App::cpm thanks!