Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: efficient perl code to count, rank

by haj (Curate)
on Jul 17, 2021 at 18:05 UTC ( #11135103=note: print w/replies, xml ) Need Help??


in reply to efficient perl code to count, rank

Just a first guess: Do you have enough RAM? You're loading 62gig "raw data" into @data, and if you don't have sufficient RAM then swapping will cause that program to run like a snail.

Replies are listed 'Best First'.
Re^2: efficient perl code to count, rank
by Perl_Noob2021 (Initiate) on Jul 17, 2021 at 18:36 UTC
    I have 16gib, would that be enough?

      Well, obviously 16GB are not enough when you're loading 62GB of data into memory. This means lots of swapping. Start your program, and observe the progress with top.

      Let's say your program fills 16GB with data from the disk. There are 46GB more. So it writes the first 16GB to swap. Then, you probably run out of swap space as well (which is usually of the same size as RAM), so the system has to allocate more swap. Phew.

      When the processing loop starts, it starts with the first lines, which it needs to read from disk again (from swap in this case). But since your RAM is already full, it now swaps out the last records. While the loop continues, the first lines will be written to swap again. So you have a cyclic re-reading and writing, which is the worst which can happen to swap (or cache).

      You should read and process record by record, even if that means you have to go through your original file twice.

      Physically reading from Disk is slow. SSDs are faster, but still significantly slower than RAM.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135103]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2021-10-20 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (82 votes). Check out past polls.

    Notices?