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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,718bd701b6b36346 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-12 18:21:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!falcon.america.net!eagle.america.net.POSTED!not-for-mail Message-ID: <3D585F63.6010205@otelco.net> From: Larry Hazel User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0rc2) Gecko/20020618 Netscape/7.0b1 X-Accept-Language: en,x-ns11F8K63r3NhQ,x-ns2r2e09O MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: GNAT/Ada95 Streams Performance Issue References: <3D51ECC9.8020406@cogeco.ca> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 12 Aug 2002 20:22:43 -0500 NNTP-Posting-Host: 66.0.32.230 X-Trace: eagle.america.net 1029201717 66.0.32.230 (Mon, 12 Aug 2002 21:21:57 EDT) NNTP-Posting-Date: Mon, 12 Aug 2002 21:21:57 EDT Organization: 24hoursupport.com Xref: archiver1.google.com comp.lang.ada:27966 Date: 2002-08-12T20:22:43-05:00 List-Id: Waldek Hebisch wrote: > Warren W. Gay VE3WWG (ve3wwg@cogeco.ca) wrote: > : 3. The individual characters that make up Msg are written > : out to stream S, using individual calls to Character'Write. > > : Step # 3 is the performance killer. > > : To help in this regard, APQ 1.2 (not released yet) now supports > : two new functions for performance reasons: > > : String_Output to substitute for String'Output > : String_Input to substitute for String'Input > > : These routines deal with the array of characters as > : one block of data. > > : But this is really just a patch over part of a much > : larger problem. > > : How have other people dealt with this type of streams > : performance issue? Or do people generally avoid > : streams when performance is important? > > Well, I just toyed with a simple cat program: > > loop > Ada.Text_IO.Get_Line( Line, Last ); > Ada.Text_IO.Put_Line( Line(1..Last) ); > end loop; > > Using GNAT (gcc 3.1.1), I get very bad performance (about 10 MB/s, raw > system calls (in C) give 450MB/s). I looked at the sources, and while > Put_Line essentialy outputs the block (it makes a copy and modifies it > slightly) Get_Line works with single characters. The problem is that to > cooperate nicely with C Ada has to go trough C stdio interface. Since Ada > and C semantics differ Ada cannot use C block input. The problem is magnified > becouse each C stdio function performs locking. > Somewhere around 1990, I wrote a simple file copy program using Sequential_IO on files of bytes. This was using the Verdix Ada 83 compiler on a Sun. I did this as a test because C people kept telling me how slow Ada was. I wanted to see for myself. It was consistently faster than the unix cp command. I suspect there was a lot of buffering going on behind the scenes. Larry