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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder3.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.nl!195.62.100.242.MISMATCH!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.fsmpi.rwth-aachen.de!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: very fast procedure call Date: Thu, 01 Aug 2013 14:14:08 +0200 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: <874nb9pq0f.fsf@adaheads.sparre-andersen.dk> References: <91af1dde-9a21-44cd-959e-dfa86bb0c1a3@googlegroups.com> NNTP-Posting-Host: 94.191.234.67.bredband.3.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: loke.gir.dk 1375359250 16814 94.191.234.67 (1 Aug 2013 12:14:10 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 1 Aug 2013 12:14:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:bCFsyAGjG6juzOJWp7OS2irZ6wE= X-Original-Bytes: 3601 Xref: number.nntp.dca.giganews.com comp.lang.ada:182791 Date: 2013-08-01T14:14:08+02:00 List-Id: Wolfgan Rostek wrote: > For injecting a bunch of trace I'll need an ultimate fast store call. > The trace call will only provide storing 4 and 8 byte values. Each > call should generate a pair of id/value. There is no tasking/threading > involved. > The body will use an array storage area which will be copied to disk > at the end of each 20msec cycle. What about writing this out explicitly: package Trace is type IDs is mod 2 ** 32; procedure Put (ID : in IDs; Value : in ...) with Inline => (True); procedure Put (ID : in IDs; Value : in ...) with Inline => (True); procedure Put (ID : in IDs; Value : in ...) with Inline => (True); procedure Put (ID : in IDs; Value : in ...) with Inline => (True); end Trace; package body Trace is type Kinds is (...); type Data (Kind : Kinds := ...) is record ID : IDs; case Kind is when ... => ... end case; end record; type Indices is mod 2 ** ...; type Circular_Buffer is array (Index) of Data; Storage : Circular_Buffer; Next : Indices := 0; procedure Put (ID : in IDs; Value : in ...) is begin Storage (Next) := (Kind => ..., ID => ID, ... => Value); Next := Next + 1; end Put; ... end Trace; If you build your application with optimisation enabled, I would expect the compiler to inline all calls to Trace.Put. As the type of Next matches Storage'Range perfectly, there is no need for range checks on the array indexing. As Next is a modular number with a power of two modulus, the wrap-around arithmetic is easy to implement as a constant-time operation. > This should be sufficient for the caller (e.g. an emum must be > converted to use the first call). Why do it that way? You could just as will expand the Trace to include support for the enumeration types you are interested in storing. Also, remember that most well-written Ada applications and libraries don't use numerical types declared in terms of how many bits/bytes they require. > I would like to make all inline, no range checking, no C-usage, etc. The above is probably the nicest way to do it. Greetings, Jacob -- "Don't get me wrong, perl is an OK operating system, but it lacks a lightweight scripting language."