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=-0.5 required=3.0 tests=BAYES_05 autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a05:620a:16ad:: with SMTP id s13mr1231917qkj.68.1616435122142; Mon, 22 Mar 2021 10:45:22 -0700 (PDT) X-Received: by 2002:a25:6610:: with SMTP id a16mr773418ybc.339.1616435121919; Mon, 22 Mar 2021 10:45:21 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!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 10:45:21 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=2601:3c3:401:f550:9ee:b41e:1376:69a6; posting-account=JSxOkAoAAADa00TJoz2WZ_46XrZCdXeS NNTP-Posting-Host: 2601:3c3:401:f550:9ee:b41e:1376:69a6 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 17:45:22 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:61631 List-Id: On Monday, March 22, 2021 at 12:39:54 PM UTC-5, Dmitry A. Kazakov wrote: > On 2021-03-22 18:02, John Perry wrote: > > > Is there a reason that the record with variant parts runs so much slower? I can make the complete source available if need be. > It must check the discriminant if the object is dynamically constrained. I'm not quite sure I understand. Are you saying that it has to check the discriminant at run-time? How would that differ from checking the value if it were merely a field of the record? (Sorry if this is is a dumb question, but I guess I don't understand variant records as well as I thought.) > Checking the discriminant and accessing a scalar field is roughly in the > same league, so 15-30% penalty is a quite good outcome. I would expect > 50% or even worse with cache misses between independent memory accesses. OK, so 15-30% is actually good news. Interesting. john perry