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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,3a6a9f1d654285ba X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sun, 02 Aug 2009 14:55:57 +0200 From: Georg Bauhaus Reply-To: rm.tsoh+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada Shootout program for K-Nucleotide (patches) References: <4a743343$0$32674$9b4e6d93@newsspool2.arcor-online.net> <0c18b36c-7af0-454c-8208-9b0416111a1f@w41g2000yqb.googlegroups.com> In-Reply-To: <0c18b36c-7af0-454c-8208-9b0416111a1f@w41g2000yqb.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4a758ce2$0$31338$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 02 Aug 2009 14:56:02 CEST NNTP-Posting-Host: 0ef5db4a.newsspool4.arcor-online.net X-Trace: DXC=U_a^o6O56XPE47KDAk81NW4IUK Ludovic Brenta wrote: > Georg Bauhaus wrote on comp.lang.ada: >> This is about the K-Nucleotide program at the >> Computer Language Benchmark Game,http://shootout.alioth.debian.org/u32/benchmark.php?test=knucleotide&... >> where some Ada programs have started to fail. >> >> In order to have one of them work again, I have patched >> knucleotide.gnat, with some success. New version is here:http://home.arcor.de/bauhaus/Ada/knucleotide.gnat >> >> Comments? Does it work on your machine? >> >> The two changes: >> >> 1 - [stack exhaustion] a loop reading input lines into an >> ubounded string replaces the recursive String "&"ing >> procedure. (Noting that the input text file is ~240MB ...) >> >> 2 - [heavy bounded strings] a lightweight bounded string ADT >> replaces an instance of Generic_Bounded_Length, yielding >> an improved running time of ~22s down from ~30s for >> the 2,500,000 case. >> >> Still, on a relatively small virtual machine running 64bit >> Debian, the program cannot handle the 25,000,000 case. > > I note that both Martin and yourself use Ada.Text_IO (especially > Read_Line) which is notoriously slow. I would use Character'Read and > a finite state machine to detect the portion of the input file to be > processed, then to fill in the buffer. That should be faster. Not sure that Character'Read will really be faster. The following Getline has left me unconvinced. I made a simple test just reading big files and measuring the time; Text_IO.Get_Line wins on Windows and even more or Debian. Also, unless there is bug in the program below, using Streams and then child packages of Text_IO for output formatting, seems to confuse the I/O system. (Would we be shooting ourselves in the foot anyway?) GNAT.IO is, I think, getting us in trouble; it doesn't signal End_Error, if I'm not mistaken. with Ada.Text_IO.Text_Streams; procedure Getline (Item: in out String; Last : out Natural) is -- -- Input via Character'Read. -- Assume Unix or Windows line ending conventions. -- Stdin: constant Ada.Text_IO.Text_Streams.Stream_Access := Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Standard_Input); C : Character; begin Last := Item'First - 1; loop Character'Read (Stdin, C); exit when C = ASCII.LF; if C /= ASCII.CR then Last := Last + 1; Item (Last) := C; end if; exit when Last = Item'Last; end loop; end Getline;