more useful options | |
PerlMonks |
Re: Simple script goes from 2s to ~2mins when run on VPS (regexes)by tye (Sage) |
on Mar 17, 2016 at 21:17 UTC ( [id://1158161]=note: print w/replies, xml ) | Need Help?? |
The part of the code that you mention as being slow (and as using a lot of CPU) is the part that uses complex regexes to parse HTML. See Mojo::DOM::HTML's source for more details. Looking briefly at the regexes, I can imagine there being some versions of Perl where their performance is much worse than for other versions of Perl. But you don't even mention whether you are using the same versions of the Mojo modules between the two systems, so it could be that much different regexes are being used between the two. I don't consider this next item to be very likely to be the problem. But we recently discovered that some VM systems default to acting like they support every single optional CPU feature. This is probably done with the thinking of preventing some code from breaking because it requires some specific optional CPU feature. However, the more common case (in our experience) is that code only makes use of certain CPU features when they are available and works around the absence when not. And this leads to code that tries to make use of advanced, optional CPU features that the VM must emulate because the physical CPUs don't support it. Such emulation of a general feature can be orders of magnitude slower than the code's work around (for its specific use case). We have seen this lead to significant server performance problems. Simply configuring the VM to report support for only the CPU features that the physical CPUs actually support, made such performance problems disappear. - tye
In Section
Seekers of Perl Wisdom
|
|