I have a small monster of a Perl script that runs too slow, but then runs fast. I am familiar with programs running fast, and then, once they run low on memory, slow, but I can't imagine what would drive it in the other direction. I am wondering if there is some explanation for this behavior.
In short, the program utilizes Inline::C to call a C library to read in a large data structure (1 GB), and then to query the data structure for each line of an input file. Whether the input is only 20 lines or 1 million lines, the progress is very slow for about the first 20%, then greatly accelerated for the rest of the file. I can follow the memory usage with top and there doesn't seem to be a memory limitation (the system has 4 GB). Is there any possible explanation for this sudden acceleration?