Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are your tricks for speeding up CPAN on limited resource devices?

Tags:

perl

cpan

I was recently trying to upgrade a few Perl modules on my cell phone (nokia n900), and installing the latest copy of Module::Build for an hour.

Most of the time (70%) seemed to be spent parsing and indexing the repository information.

It seems there are a few options, such as not rebuilding the index cache each time, or using CPAN::SQLite.

I would like to continue using CPAN on the device, rather than installing the modules manually. So I am wondering what techniques people have had success with on similar limited resource devices (slowish cpu, limited ram, slow disk (flash))?

like image 335
Eric Strom Avatar asked Jul 02 '10 20:07

Eric Strom


3 Answers

If the module is pure Perl (i.e. has no XS components and does not require any library to be compiled), you can install the package on another machine of a different operating system into a local::lib directory, and then simply copy that directory over to your device.

Otherwise (if compilation is necessary), the same technique can be used to only build the module once, so long as you install it on a device of the same architecture; after that, you can share the library between multiple devices. e.g. once you build these packages, you can put them up on your webpage to be shared among other Nokia n900 users, and gain many friends. :)

like image 39
Ether Avatar answered Nov 17 '22 16:11

Ether


If you're operating in a limited RAM environment, like a wireless router or something, adding swap can help. I don't think this is quite what you're looking for, but if your CPAN builds are running out of memory or getting killed, this will help.

In a shell:

# dd if=/dev/zero of=/path/to/swapfile.swp bs=1M count=512
# mkswap /path/to/swapfile.swp
# swapon /path/to/swapfile.swp

This will give you a 500MiB swap file. On my 128MB router this worked fine; I put the file on an attached USB thumb drive.

like image 35
Gabriel Bauman Avatar answered Nov 17 '22 16:11

Gabriel Bauman


I believe this was one of the primary reasons why Miyagawa created cpanminus.

From the POD:

Another CPAN installer?

OK, the first motivation was this: the CPAN shell runs out of memory (or swaps heavily and gets really slow) on Slicehost/linode's most affordable plan with only 256MB RAM. Should I pay more to install perl modules from CPAN? I don't think so.

I've not used cpanm on a limited resource device/machine but I have been using it exclusively on my Perl 5.12 dev and its been a dream!

/I3az/

like image 106
draegtun Avatar answered Nov 17 '22 16:11

draegtun