Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Our company has a program that kills us. I really don't know perl but I think it tries to read an entire file into memory all at once and then split it into strings. Our files are really big and the program when it runs makes everything else take hours longer to run than it used to. What can I do to fix it?

Replies are listed 'Best First'.
Re: Help! Perl program kills production!
by LanX (Saint) on Jul 10, 2017 at 19:24 UTC
Re: Help! Perl program kills production!
by Marshall (Canon) on Jul 11, 2017 at 04:03 UTC
    This isn't a Perl question unless you have a Perl specific question.

    As a sys admin question, it appears that one program is taking over too much physical memory that it is affecting other non related programs.

    Of course, switch to 64 bit Perl and add a heck of a lot of GB's of memory is one possibility.

    Another possibility is to limit the amount of physical memory that this Perl program can use, perhaps limit-memory-usage-for-a-single-linux-process. This will of course slow this Perl program down dramatically, but allow other programs to proceed normally.

    And of course fix the Perl program! But to do that, we need code that is focused on the problem area. Don't expect a re-write of a 10,000 line program here. But you can expect help if you are attempting to modify this thing so that for example the split can happen on a record by record (usually line) basis instead of iterating over an in memory copy of the file.

Re: Help! Perl program kills production!
by Laurent_R (Canon) on Jul 10, 2017 at 21:03 UTC
    Please show us some details. It's not possible to comment on a program you haven't shown us.

    Having said that, I should add that I usually agree, when dealing with really big files, with the idea of processing it piece by piece, whether piece means a logical line or some other data block, when possible.

Re: Help! Perl program kills production!
by 1nickt (Canon) on Jul 10, 2017 at 19:27 UTC

    Our company has a program that kills us. I really don't know perl ... What can I do to fix it?

    You'll need to learn Perl, or hire a Perl programmer.


    The way forward always starts with a minimal test.
Re: Help! Perl program kills production!
by Anonymous Monk on Jul 10, 2017 at 19:22 UTC
    You can write bad code in any language. Why don't you show us the offending code? What kind of an input file is it, can it be processed record/line by record/line?