From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
Subject: Re: Buffered I/O with GNAT on Linux
Date: 1998/06/14
Date: 1998-06-14T00:00:00+00:00 [thread overview]
Message-ID: <35843B43.3EF8937D@cl.cam.ac.uk> (raw)
In-Reply-To: dewar.897825854@merv
Robert Dewar wrote:
> Markus comments on the buffering in GNAT. This is totally under control
> of the user, as documented in the GNAT manual. THe default for a non-regular
> file is buffering off, which is what most people want as a default!
>
> If you want buffering for stdout, turn it on!
I tried several things along the lines of
----------------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with System; use System;
with Interfaces.C_Streams; use Interfaces.C_Streams;
with Ada.Text_IO.C_Streams; use Ada.Text_IO.C_Streams;
procedure Strange is
begin
if setvbuf(C_Stream(Current_Output), Null_Address, IOFBF, 8092) /= 0 then
Put_Line("setvbuf failed");
end if;
for X in 1..10 loop
Put("Hello ");
end loop;
New_Line;
end Strange;
----------------------------------------------------------------------
but with no success. I still can't get buffered output.
In addition, if normal files are really buffered, then why are
gnatbind and gnatlink so incredibly slow (factor 50) on Linux
NFS mounted filesystems? It really looks like these two programs
use very inefficient buffered I/O. For instance, look at the system
calls when gnatbind is writing the C main program (recorded by
strace):
...
open("b_strange.c", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
write(3, "extern int gnat_argc;", 21) = 21
write(3, "\n", 1) = 1
write(3, "extern char **gnat_argv;", 24) = 24
write(3, "\n", 1) = 1
write(3, "extern char **gnat_envp;", 24) = 24
write(3, "\n", 1) = 1
write(3, "extern int gnat_exit_status;", 28) = 28
write(3, "\n", 1) = 1
write(3, "void adafinal ();", 17) = 17
...
And each of these write() system calls triggers a full blown
remote procedure call under Linux with NFS. Same with gnatlink.
Markus
--
Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK
email: mkuhn at acm.org, home page: <http://www.cl.cam.ac.uk/~mgk25/>
next prev parent reply other threads:[~1998-06-14 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-06-14 0:00 Buffered I/O with GNAT on Linux Markus Kuhn
1998-06-14 0:00 ` Robert Dewar
1998-06-14 0:00 ` Markus Kuhn [this message]
1998-06-15 0:00 ` Tarjei T. Jensen
1998-06-15 0:00 ` Tarjei T. Jensen
1998-06-14 0:00 ` ak
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox