From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:aed:2143:: with SMTP id 61mr1943890qtc.136.1616450054085; Mon, 22 Mar 2021 14:54:14 -0700 (PDT) X-Received: by 2002:a25:2484:: with SMTP id k126mr972523ybk.165.1616450053951; Mon, 22 Mar 2021 14:54:13 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 22 Mar 2021 14:54:13 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=2601:3c3:401:f550:f6d1:8c0b:6974:417; posting-account=JSxOkAoAAADa00TJoz2WZ_46XrZCdXeS NNTP-Posting-Host: 2601:3c3:401:f550:f6d1:8c0b:6974:417 References: <07a56dcc-9e17-49b2-a980-3a5a2d265cedn@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Performance of records with variant parts From: John Perry Injection-Date: Mon, 22 Mar 2021 21:54:14 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:61645 List-Id: On Monday, March 22, 2021 at 1:59:34 PM UTC-5, Niklas Holsti wrote: > What is your optimization level? -O2? I've tried several. The one with the best performance is -O3 -funroll-loops -gnatn. > Moreover, in your case the compiler should > statically know the offset of each discriminant-dependent component, so > accessing such a component should not require any overhead compared to a > record without discriminants. Precisely this perplexes me. Nothing in this section of the code would be unknown after the discriminant check. -- Nothing that seems obvious to me, anyway. I'll copy some code in a reply to someone else in a moment. > However, in the past I've seen unexpectedly slow code for copying > records with discriminants. ... > [very interesting material excised for brevity] > If the compiler is stupidly checking the discriminant of obj for each > obj-component access, you may be able to speed up the code by creating > separate sub-procedures I liked this idea and thought it might be the problem, but that also didn't help out. I may have to look at the assembly, which I am loath to do. :-/ john perry