Improving Perl Application Performance
During this process I identified a function that probably wasn't performing as well as it could. I was able to achieve several modest performance gains by refining the logic of the calculation in Perl. I also tried using an open-source package, only to find that it was 48% worse than my original function. Finally, I implemented the standard deviation function in C and exposed it to Perl through an XS layer. The C version showed a 1,175% speedup compared to the original Perl version. Improvements are summarized in Figure 1.
In most cases, I have seen Perl performance that rivals C; however, this obviously isn't one of those cases. Perl is a good general-purpose language, and one of its benefits is the ability to step out of the language and implement code in a lower-level language. Don't be afraid of language mix-ins when you really need to improve performance, as long as you understand that there is a maintenance cost. The disadvantage of introducing additional languages is that it will increase the burden for those that must maintain the application in the future. They will need to know C and understand XS functions. However, in our case, the improved performance significantly outweighed the impact of supporting XS.
Bruce W. Lowther (firstname.lastname@example.org) is a software engineer for Micron Technology, Inc., in Boise, Idaho. He has worked at Micron for nine years and has spent the past five years there working on tools to help integrate semiconductor equipment into the Micron manufacturing process. He received his undergraduate and Master's degrees in Computer Science from the University of Idaho.
- Open-Source Space
- Silicon Mechanics Gives Back
- Numerical Python
- Reglue: Opening Up the World to Deserving Kids, One Linux Computer at a Time
- Our Assignment
- Talking to Twitter
- Quantum Cryptography
- New Storage Solution is Music to the Ears of Fast-Growing Digital Music Company
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Linux Systems Administrator