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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.17.211 with SMTP id 80mr11265355ior.105.1509946890202; Sun, 05 Nov 2017 21:41:30 -0800 (PST) X-Received: by 10.157.52.218 with SMTP id t26mr521137otd.10.1509946890126; Sun, 05 Nov 2017 21:41:30 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.214.87.MISMATCH!k70no840486itk.0!news-out.google.com!193ni2514iti.0!nntp.google.com!l196no845735itl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 5 Nov 2017 21:41:29 -0800 (PST) In-Reply-To: <5b65b9f0-25d9-449a-b7eb-d1fc112f293f@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8303:2100:5985:2c17:9409:aa9c; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8303:2100:5985:2c17:9409:aa9c References: <5b65b9f0-25d9-449a-b7eb-d1fc112f293f@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: About good practice: Should protected objects be small? From: Robert Eachus Injection-Date: Mon, 06 Nov 2017 05:41:30 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:48726 Date: 2017-11-05T21:41:29-08:00 List-Id: On Friday, October 20, 2017 at 10:50:44 AM UTC-4, reinert wrote: > I am testing out using protected objects. >=20 > Is it reasonable good practice to keep protected objects small? > It seems like for me (?) and stubs ("is separate") is not allowed there. Not really the question asked, but it can jump up and bite you. You really= want the size of the protected object to be a multiple of hash lines on th= e actual hardware. Compilers do this by allocating the storage for any pro= tected object on a cache line boundary. But that is not guaranteed. Worse,= the compiler might be generating x86 code and have no idea what the actual= cache line size is. It is always possible to add Junk, usually under that= name ;-), so that each protected value takes one cache line. (Usually 64,= 128, or 256 bytes, you can determine it at run-time.*) Getting the beginn= ing of the value cache boundary aligned can be done by aligning the protect= ed record even if some of the data is never accessed. If you want to get really fancy, you can use non-temporal loads and stores = to avoid loading and saving the entire cache line. I don't know if any Ada = compilers do that for protected objects, and doing it yourself is a bad ide= a on large projects. * I have a function that does that for x86 will post if asked. It assumes t= hat if the CPUID instruction does not support this, just return 64, which i= s usually right for very old x86 CPUs.