[lkml]   [2022]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: [PATCH v4 00/34] Printbufs - new data structure for building strings
From: Kent Overstreet
> Sent: 20 June 2022 16:07

> On Mon, Jun 20, 2022 at 04:19:31AM +0000, David Laight wrote:
> > From: Kent Overstreet
> > > Rasmus pointed out that -fno-strict-aliasing is going to cause gcc to generate
> > > nasty code, and indeed it unfortunately does but according to worst case
> > > scenario microbenchmarks it's not a problem for actual performance.
> >
> > Just copy some of the structure members to local variables
> > and, if necessary, write them back at the end.
> You must not have read any of the code - half the point of this patch series is
> implementing proper helpers for printing chars, strings of bytes, etc. and that
> doesn't work if we're not using actual types.

I'm talking about things like:
out->buf[out->pos] = c;
(or whatever the field names are.)

Even without strict aliasing the compiler has to reread
'buf' and 'pos' every iteration.

Of course, you might find the compiler decides to 'optimise'
the loop to memcpy() or memset().


Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

 \ /
  Last update: 2022-06-20 17:26    [W:0.071 / U:0.976 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site