I understand that our problem might not(only|at all) be related to Perl, but since this is the language of choice and I know there is a lot of wisdom to be found here, I beg to ask...
When migrating several older Perl programs from an old to a new server we saw a dramatic decrease in execution speed, although the newer machine should be much faster.
Old machine:
Intel Celeron @2.2GHz, 4533 bogomips, 2GB RAM, Perl 5.10.1, Ubuntu 10.04 LTS, kernel 2.6.32-45, mysql 14.14 Distrib 5.1.66, SysV init
New machine:
Intel Core i3-4160 @3.6GHz, 7200 bogomips, 8GB RAM, Perl 5.20.2, Debian jessie, kernel 3.16.0-4, mysql 15.1 Distrib 10.0.23-MariaDB, systemd 215
The difference in one task was about 10-fold (i.e. the script took more than 10 times as long to run on the new machine, 0m58 vs. 11m). In another case the slow down was about 4 to 8-fold. Measurements were taken with the 'time' command on the command line.
The slowest program reads a dBase database table sequentially, mangles the data a bit and writes the records to a text and to a MariaDB SQL table. When commenting out the only $sth->execute statement the execution time jumps up from 11 minutes to 38 seconds. Some careful performance tuning on the MySQL/MariaDB server brought the execution time down to 2m40 (from 11m), still about 3 times slower than the old machine.
Another program, which does not use SQL, reads a dBase file, mangles the data a bit and writes them to a text file. Here the slowdown is about 4-fold. Some analysis with Devel::NYTProf found that most time is spent in IO::Handle which in turn is called by XBase.pm.
What I did and concluded so far:
- Moved the location of the dBase files which I read, from the server to the local machine, slight speed up of maybe 5%. So I conclude that the network is not the issue.
- Copied the same large numbers of small and large files from the server to the local machines. The new machine is about 3% faster, so I conclude that disk write IO is not the issue. I understand that this is a very crude and simple performance test, and real performance test takes much more. I at least cleared disk caches in advance of each test.
- Added the 'noatime' option to all affected file systems in /etc/fstab. No discernible speed up seen.
- Ran the two slowest programs with -d:NYTProf option.
- the program which uses SQL spends 80% in DBI::st::execute, 17% in IO::Handle::CORE::read (which is called by XBase.pm);
- the program which does not use the database spends about 87% of the time in IO::Handle::CORE::read (which is called by XBase.pm).
- Changed some parameters on the SQL server, which resulted in visible speedup of the programs using the SQL server. Nice, but not enough. Parameters changed were mostly buffer sizes.
- Compared the XBase.pm version, since a lot of time seems to be spent there.
On the old machine it is 0.241, on the new one it is version 1.02. I did not yet look into the source of XBase.pm to see if there are any visible changes. Nor did I install the old version on the new machine. In fact I am a little bit afraid to do that and throw modules around... instead I came here to ask.
My question:
What else could be the reason for the slowdown? Is there anything which makes Perl 5.20 so much slower at IO handling? Is there anything obvious that I am missing, maybe something affecting IO in general? Buffering?
Any help is highly appreciated.
Thanks in advance,
Ekki
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.