comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca>
Subject: Re: Thoughts on the recent ICFP contest
Date: Fri, 13 Sep 2002 11:46:27 -0400
Date: 2002-09-13T11:46:27-04:00	[thread overview]
Message-ID: <3D820853.4040503@cogeco.ca> (raw)
In-Reply-To: OJ5g9.403067$me6.46839@sccrnsc01

tmoran@acm.org wrote:
...
>>that 'Write on a 1000-byte array will, by default, perform one 'Write on
>>each component of that array, amounting to 1000 'Writes. That means
>>any time someone is interested in efficency, they end up having to make
>>their own 'Write that calls Ada.Streams.Write once for each object that
>>they want transferred efficiently. This is an issue for *any* stream,
>>not just the one I'm proposing above.
> 
>   Agreed.  Anytime you make a data structure that needs to be read/written,
> part of the job is to write the Data_Structure'Write etc. routines.  So
> it would be nice to have an efficient String'Write, but I'm not sure how
> much real work it would let you avoid.

I encountered this type of performance problem with my APQ Ada95 interface
to PostgreSQL. I provide a streams interface to blobs. However, when I tried
to write strings to the blob, the performance was abysmal because each byte
was being sent to the database server and acknowledged back up the food chain.

I solved the problem (mostly) by providing buffered reads and writes to
the blob, much the same way the fread(2) and fwrite(2) calls in C work. It
turned out to be simpler than expected, because you can do all of the
buffering work at the bottom stream layer. See the following link if
you have the patience to sift through the code:

    http://home.cogeco.ca/~ve3wwg/apq-1.9.tar.gz

I have been tempted to look at that very same issue for sockets myself.
I have also pondered whether there is a universal way (non-GNAT specific)
using XDR routines to make the I/O endian neutral.  I know that GNAT uses
some vector of routines technique to do this, though I've not fully explored
this yet.  Do a google search -- it was discussed this year I think.

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




  parent reply	other threads:[~2002-09-13 15:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-12  2:35 Thoughts on the recent ICFP contest Ted Dennison
2002-09-12  3:11 ` tmoran
2002-09-12 14:23   ` Wes Groleau
2002-09-12 16:43     ` Ted Dennison
2002-09-12 16:53     ` David C. Hoos
2002-09-16 20:41       ` Wes Groleau
2002-09-17  3:21         ` Ted Dennison
2002-09-12 19:15     ` tmoran
2002-09-12 16:32   ` Ted Dennison
2002-09-12 19:15     ` tmoran
2002-09-13  1:45       ` Ted Dennison
2002-09-13 15:46       ` Warren W. Gay VE3WWG [this message]
2002-09-17 10:36 ` Jacob Sparre Andersen
2002-09-17 12:55   ` Ted Dennison
2002-09-17 14:41     ` Jacob Sparre Andersen
2002-09-17 10:56 ` Preben Randhol
2002-09-17 12:38   ` Ted Dennison
2002-09-18  0:31     ` tmoran
2002-09-18  7:15     ` Samuel Tardieu
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox