comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent Guerby <guerby@acm.org>
Subject: Re: Problems with large records (GNAT) [continued]
Date: 01 Mar 2001 20:38:55 +0100
Date: 2001-03-01T19:35:50+00:00	[thread overview]
Message-ID: <86hf1djn3k.fsf@acm.org> (raw)
In-Reply-To: 3A9E05B0.46B406ED@linuxchip.demon.co.uk

Dr Adrian Wrigley <amtw@linuxchip.demon.co.uk> writes:
> Since you ask, I have something like the following...
> ------------------------------------
>    type PriceSummary_T is record
>       OpenPrice   : Float;
>       HighPrice   : Float;
>       LowPrice    : Float;
>       ClosePrice  : Float; -- Split and dividend corrected price
>       UncorrectedClose : Float; -- Raw share price
>       Volume      : Integer;
>       Time        : Time_T;
>    end record;
> 
>    type StockIndex_T is new Integer range 1 .. 3000;
>    type TradingDay_T is new Integer range 0 .. 1860;
> 
>    type DailyArray_T is array (TradingDay_T, StockIndex_T) of PriceSummary_T;
> 
>    type BooleanDailyArray_T is array (TradingDay_T, StockIndex_T) of Boolean;
>    pragma Pack (BooleanDailyArray_T);
> 
>    type Oracle_T is record
> -- Various other record values may go here!
>       Tradeable    : BooleanDailyArray_T;
>       Daily        : DailyArray_T;
>    end record;
> ------------------------------------

Nice to see we're not alone using Ada for critical applications in the
financial world ;-). (Note that we have a support contract from Ada
Core Technologies, if you have one you can probably discuss the record
size limitation with them.)

Anyway, here I would probably want a few things:

- control the layout of the data to match computational access, if you
process your serie along time or stock.

- lazy loading (ie not mmap'ing the whole thing at once).

To do so, I wouldn't put all the things in the record, I would use
access types hidden behind proper abstraction. 

type PriceSummary_TV is array (Positive) of aliased PriceSummary_T;
type PriceSummary_TVA is access all PriceSummary_TV;

type Oracle_T is record
   N1 : Natural := 0;
   P1 : PriceSummary_TVA;
end record;

You mmap your stock history and store the pointer to it in your
Oracle_T (unchecked_convertion from the address returned by mmap to
PriceSummary_TVA). You need to use array of P1/N1 to implement
everything.  The "aliased" allow you to access any record by access
instead of copy when you're hiding things. N1 is needed to do manual
checking in your abstraction.

Note that if you compute historical volatilities or correlations, you
will probably be memory-bound performance wise (algorithm complexity
proportional to data size, with a small enough computation factor so
that memory access becomes dominant).

-- 
Laurent Guerby <guerby@acm.org>



  parent reply	other threads:[~2001-03-01 19:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-28 10:44 Problems with large records (GNAT) [continued] Dr Adrian Wrigley
2001-02-28  3:13 ` Robert A Duff
2001-02-28 12:09   ` Dr Adrian Wrigley
2001-02-28  9:51     ` Florian Weimer
2001-02-28 18:35 ` Laurent Guerby
2001-03-01  8:17   ` Dr Adrian Wrigley
2001-03-01  1:58     ` Robert A Duff
2001-03-01 22:18       ` Dr Adrian Wrigley
2001-03-01 17:02         ` Robert A Duff
2001-03-01  7:00     ` tmoran
2001-03-01 21:52       ` Dr Adrian Wrigley
2001-03-01 19:32         ` tmoran
2001-03-01 19:38     ` Laurent Guerby [this message]
2001-03-02 20:32 ` Randy Brukardt
2001-03-07  2:15 ` Dr Adrian Wrigley
replies disabled

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