comp.lang.ada
 help / color / mirror / Atom feed
* 'others' - inefficient esp. DEC Ada? [1/1]
@ 1997-10-12  0:00 Rob Kirkbride
  1997-10-13  0:00 ` Tom Moran
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Rob Kirkbride @ 1997-10-12  0:00 UTC (permalink / 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




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1997-10-15  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-12  0:00 'others' - inefficient esp. DEC Ada? [1/1] Rob Kirkbride
1997-10-13  0:00 ` 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

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