public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/16339] New: Unformatted i/o on large arrays inefficient
@ 2004-07-03  1:42 rth at gcc dot gnu dot org
  2004-07-03  1:43 ` [Bug libfortran/16339] " rth at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-07-03  1:42 UTC (permalink / raw)
  To: gcc-bugs

Looking at a test case provided by Bud Davis, I see that we're writing out
(and reading back) each element of the array individually, which then gets
blocked and written by the library in page-sized chunks:

write(3, "\0\0\0\0\0\0\0\0\1\0\0\0\2\0\0\0\3\0\0\0\4\0\0\0\5\0\0"..., 8192) = 81
92
write(3, "\377\7\0\0\0\10\0\0\1\10\0\0\2\10\0\0\3\10\0\0\4\10\0\0"..., 8192) = 8
192
...
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x2000001a000
munmap(0x2000001a000, 16384)            = 0
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x4000) = 0x2000001a000
munmap(0x2000001a000, 16384)            = 0

Surely we should be writing out (and reading back) the entire array (or at
least columns) at a time.

I will also note in passing that mapping and unmapping memory is a relatively
expensive operation.  You only want to do it if you (1) actually require the
sharing semantics or (2) can map enough to make the overhead pay off.  The 16k
sliding window seen here does not meet either requirement.  In the case of these
unformatted reads, the most efficient thing is a read directly into the array
and not fiddling with mmap at all.

-- 
           Summary: Unformatted i/o on large arrays inefficient
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rth at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16339


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-12-09  9:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-16339-119@http.gcc.gnu.org/bugzilla/>
2005-10-07 20:02 ` [Bug libfortran/16339] Unformatted i/o on large arrays inefficient cvs-commit at gcc dot gnu dot org
2005-11-04 19:50 ` fxcoudert at gcc dot gnu dot org
2005-12-09  9:24 ` fxcoudert at gcc dot gnu dot org
2004-07-03  1:42 [Bug libfortran/16339] New: " rth at gcc dot gnu dot org
2004-07-03  1:43 ` [Bug libfortran/16339] " rth at gcc dot gnu dot org
2004-07-03  1:52 ` pinskia at gcc dot gnu dot org
2005-03-04 10:48 ` Thomas dot Koenig at online dot de
2005-06-04 17:50 ` jblomqvi at cc dot hut dot fi
2005-06-05 21:19 ` jblomqvi at cc dot hut dot fi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).