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.22.199 with SMTP id 190mr9740220iow.130.1510460178564; Sat, 11 Nov 2017 20:16:18 -0800 (PST) X-Received: by 10.157.51.119 with SMTP id u52mr583265otd.6.1510460178459; Sat, 11 Nov 2017 20:16:18 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!peer03.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!l196no1523004itl.0!news-out.google.com!x87ni2676ita.0!nntp.google.com!m191no954983itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 11 Nov 2017 20:16:18 -0800 (PST) In-Reply-To: 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: <763e3484-88f4-48ad-9552-694ec15ba688@googlegroups.com> Subject: Re: About good practice: Should protected objects be small? From: Robert Eachus Injection-Date: Sun, 12 Nov 2017 04:16:18 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3626 X-Received-Body-CRC: 2917669292 Xref: feeder.eternal-september.org comp.lang.ada:48828 Date: 2017-11-11T20:16:18-08:00 List-Id: On Monday, November 6, 2017 at 3:27:13 AM UTC-5, Niklas Holsti wrote: > On 17-11-06 07:41 , Robert Eachus wrote: =20 > > 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 >=20 > (That was meant to be "cache", not "hash", I think.) Yes. > > lines on the actual hardware. >=20 > In the context of this thread (protected object principles and=20 > practices), I feel called to comment on Robert's advice. >=20 > I am ready to believe that Robert's advice is very sound when the goal=20 > is to maximise performance of frequently accessed protected objects in a= =20 > multi-core system, where the Ada tasks are running in parallel on=20 > different cores. Core-to-core communication about the ownership of=20 > data-cache lines, and the movement of data-cache lines between per-core= =20 > caches, for the purpose of keeping the per-core data caches coherent,=20 > can have a large effect on execution speed, AIUI. >=20 > However, that concern, and Robert's advice, is about the *data*=20 > (variables) in the protected object, while the original question AIUI=20 > was perhaps more about the size of the *code* of the protected=20 > operations, and the fact that they cannot be made separate, as such. Yes. I have seen cases where the programmer triumphantly reduced the size = of the object of a protected type, then was shocked when execution time wen= t pear shaped. >=20 > I don't think there is any need to consider *code* cache-line size when= =20 > designing a protected object. Cores usually have separate=20 > (Harvard-style) Instruction and Data caches, and the I-cache is usually= =20 > read-only and does not need coherence management, unlike the D-cache.=20 > However, I am rather ignorant about the cache architetures of x86-based= =20 > systems, never having used such a system in a real-time application. In most x86 family chips the L1 Instruction lines start out as a multiple o= f the L2 cache line size, then gets extremely ugly. The chip front-end gra= bs up to 32 bytes non-aligned with the cache, then tries to mark where inst= ructions might begin. Fortunately, unless you modify code, then do a flush= , the instruction cache logic can be ignored.