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 (email@example.com) 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.
- Readers' Choice Awards 2013
- IBM Will Minimize Impact of Future Disasters
- RSS Feeds
- Sublime Text: One Editor to Rule Them All?
- December 2013 Issue of Linux Journal: Readers' Choice
- Linux Systems Administrator
- Tech Tip: Really Simple HTTP Server with Python
- Senior Perl Developer
- Technical Support Rep
- Linux Kernel News - October 2013
- Reply to comment | Linux Journal
11 hours 22 min ago
- It's Jupiter
12 hours 22 min ago
- GIMP is certainly a graphic
13 hours 24 min ago
- Thanks For Your Sharing
18 hours 9 min ago
- Studying linux, and looking
21 hours 35 min ago
- voting for Best Linux Distribution
1 day 6 hours ago
- tizen vs android
1 day 10 hours ago
- i switch my choice from KDE
1 day 10 hours ago
1 day 13 hours ago
- Belanja Online
1 day 15 hours ago