I rather suspect its the difference in strategies for our file systems. OpenBSD uses ffs and I've enabled soft updates as well (normal and common). The filesystem is normally in sync mode and IIRC soft updates relaxes that somewhat for the data while continuing to be strict about meta-data. Again, IIRC Linux's ext2/3 operates in async mode by default which is faster but is less able to handle interruptions.

$ perl perrin-bench3.pl Benchmark: timing 10 iterations of berkeley write, file print, file sy +swrite, file write... berkeley write: 96 wallclock secs (25.02 usr + 21.67 sys = 46.69 CPU) +@ 0.21/s (n=10) file print: 54 wallclock secs (23.83 usr + 12.98 sys = 36.81 CPU) @ 0 +.27/s (n=10) file syswrite: 44 wallclock secs (23.17 usr + 11.72 sys = 34.89 CPU) @ + 0.29/s (n=10) file write: 54 wallclock secs (23.65 usr + 12.34 sys = 35.99 CPU) @ 0 +.28/s (n=10) s/iter berkeley write file print file write fil +e syswrite berkeley write 4.67 -- -21% -23% + -25% file print 3.68 27% -- -2% + -5% file write 3.60 30% 2% -- + -3% file syswrite 3.49 34% 6% 3% + -- Benchmark: timing 10 iterations of berkeley read, file read, file slur +p, file sysread... berkeley read: 170 wallclock secs (10.95 usr + 7.75 sys = 18.70 CPU) +@ 0.53/s (n=10) file read: 156 wallclock secs ( 7.68 usr + 6.01 sys = 13.69 CPU) @ 0 +.73/s (n=10) file slurp: 173 wallclock secs (11.71 usr + 6.62 sys = 18.33 CPU) @ +0.55/s (n=10) file sysread: 194 wallclock secs ( 6.80 usr + 5.45 sys = 12.25 CPU) @ + 0.82/s (n=10) s/iter berkeley read file slurp file read file s +ysread berkeley read 1.87 -- -2% -27% + -34% file slurp 1.83 2% -- -25% + -33% file read 1.37 37% 34% -- + -11% file sysread 1.23 53% 50% 12% + -- --- perrin-bench2.pl Tue Mar 18 12:00:06 2003 +++ perrin-bench3.pl Tue Mar 18 14:00:21 2003 @@ -35,6 +35,34 @@ return $value; } +sub slurp_file { + my $key = shift; + my $file = "$file_dir/$key"; + local $/; + open(FH, '<', $file) or die $!; + my $value = <FH>; + close FH; + return $value; +} + +sub sysread_file { + my $key = shift; + my $file = "$file_dir/$key"; + my $value; + open(FH, '<', $file) or die $!; + sysread FH, $value, (stat FH)[7]; + close FH; + return $value; +} + +sub print_file { + my ($key, $value) = @_; + my $file = "$file_dir/$key"; + open(FH, '>', $file) or die $!; + print FH $value; + close FH; +} + sub write_file { my ($key, $value) = @_; my $file = "$file_dir/$key"; @@ -43,13 +71,30 @@ close FH; } +sub syswrite_file { + my ($key, $value) = @_; + my $file = "$file_dir/$key"; + open(FH, '>', $file) or die $!; + print FH $value; + close FH; +} + cmpthese(10, { 'file write' => sub { for (0..1000) { write_file($_, $_ x 8000); } }, - + 'file print' => sub { + for (0..1000) { + print_file($_, $_ x 8000); + } + }, + 'file syswrite' => sub { + for (0..1000) { + syswrite_file($_, $_ x 8000); + } + }, 'berkeley write' => sub { for (0..1000) { $db_obj->db_put($_, $_ x 8000); @@ -62,6 +107,18 @@ my $test; for (0..1000) { $test = read_file($_); + } + }, + 'file slurp' => sub { + my $test; + for (0..1000) { + $test = slurp_file($_); + } + }, + 'file sysread' => sub { + my $test; + for (0..1000) { + $test = sysread_file($_); } }, 'berkeley read' => sub {

In reply to Re^4: BerkeleyDB vs. Linux file system by diotalevi
in thread BerkeleyDB vs. Linux file system by perrin

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.