This takes less than 3 minutes each to store and then retrieve 3.2 GB of AoA to disk (1e6 arrays of ave. 100 integers):

Update: If I use -O=5.8 which translates to somewhat over 630,000 arrays of ave:100 elements, but avoids pushing my machine into swapping, the time is 10 seconds to write and 11 to read.

#! perl -sw use strict; use Data::Dump qw[ pp ]; use Time::HiRes qw[ time ]; $|++; our $O //= 3; my @AoA; $#AoA = 10 ** $O; $AoA[ $_ ] = [ 1 .. 1+rand 200 ] for 0 .. $#AoA; pp \@AoA if $O <= 2; my $start = time; open O, '>:raw', 'junk26.bin' or die $1; for ( 0 .. $#AoA ) { printf O pack 'V/A*', pack 'V*', @{ $AoA[ $_ ] }; ## switched prin +tf to print } close O; printf "Store took %.6f secs\n", time() - $start; @AoA = (); $start = time; open I, '<:raw', 'junk26.bin' or die $!; for ( 0 .. 10 ** $O ) { read( I, my $n, 4 ); read( I, my $buf, unpack 'V', $n ); $AoA[ $_ ] = [ unpack 'V*', $buf ]; } close I; printf "Retrieve took %.6f secs\n", time() - $start; pp \@AoA if $O <= 2; __END__ C:\test>junk26 -O=6 Store took 169.778000 secs Retrieve took 170.926000 secs

Resultant file is 400 MB on disk and gzips to 6 MB.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

In reply to Re: Storing large data structures on disk by BrowserUk
in thread Storing large data structures on disk by roibrodo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.