From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10c696,9bedf54b4be9359b X-Google-Attributes: gid10c696,public X-Google-Thread: 103376,9bedf54b4be9359b X-Google-Attributes: gid103376,public From: Markus Kuhn Subject: Re: Buffered I/O with GNAT on Linux Date: 1998/06/14 Message-ID: <35843B43.3EF8937D@cl.cam.ac.uk>#1/1 X-Deja-AN: 362621660 Content-Transfer-Encoding: 7bit References: <3583B587.2DB4EDBC@cl.cam.ac.uk> Content-Type: text/plain; charset=us-ascii Organization: Cambridge University, Computer Laboratory Mime-Version: 1.0 Newsgroups: comp.lang.ada,comp.os.linux.development.apps Date: 1998-06-14T00:00:00+00:00 List-Id: 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: