comp.lang.ada
 help / color / mirror / Atom feed
From: Rob Kirkbride <rk-comp@rk-comp.demon.co.uk>
Subject: 'others' - inefficient esp. DEC Ada? [1/1]
Date: 1997/10/12
Date: 1997-10-12T00:00:00+00:00	[thread overview]
Message-ID: <+3g7rFB7dIQ0EwNI@RK-COMP.DEMON.CO.UK> (raw)


I am involved in a project using DEC Ada under Unix OSF1. We are at a
stage in the project now where we are improving performance, reducing
memory requirements etc.

While doing this study I was staggered to find that the 'others'
construct when used to clear an error eg.
My_Array := (others => Null_Element) can be 3-4 times SLOWER than
using a loop eg.

for My_Element in My_Array'range loop
        My_Array (My_Element) := Null_Element;
end loop;

This is because using the 'others' the array is built up in another part
of memory before being copied back to My_Array, apparently because
Null_Element could be a function and it may raise a constraint error.

Apart from the performance this also costs in memory as if this is done
in a task, the stack size of the task could have to be doubled to cope.
In one task this causes us to add 3Mb to the task size!

Obviously the others can be replaced with the loop but as we have over
6000 of them this could be quite expensive! We have asked DEC and they
admitted it was "poor optimisation". We would obviously like them to
improve this situation.

Does anyone know of a compiler that does this efficiently?

Anyone starting to write their coding standards I would seriously look
at this issue as you may find it will cause you to lose some performance
and memory (it has us)

I have attached a small test program to illustrate this point.

[ Section: 1/1 File: check_si.a Encoder: Turnpike Version 3.03 ]

begin 644 check_si.a
<encoded_portion_removed>
end

sum -r/size 19077/4149 section (from "begin" to "end")
sum -r/size 62565/2989 entire input file

-- 
Rob Kirkbride




             reply	other threads:[~1997-10-12  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-12  0:00 Rob Kirkbride [this message]
1997-10-13  0:00 ` 'others' - inefficient esp. DEC Ada? [1/1] Tom Moran
1997-10-12  0:00   ` Michael & Amy Hartsough
1997-10-13  0:00   ` Rob Kirkbride
1997-10-14  0:00 ` Jeff Creem
1997-10-15  0:00 ` Matthew Heaney
replies disabled

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