From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9838 invoked by alias); 27 Nov 2014 19:20:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 9829 invoked by uid 89); 27 Nov 2014 19:20:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com From: "Wilco Dijkstra" To: =?iso-8859-2?Q?'Ond=F8ej_B=EDlka'?= Cc: , References: <001a01cfefa3$0fb21330$2f163990$@com> <20141123165227.GA27543@domone> In-Reply-To: <20141123165227.GA27543@domone> Subject: RE: [PATCH] Improve performance of strncpy Date: Thu, 27 Nov 2014 19:20:00 -0000 Message-ID: <000001d00a77$3d6bdf10$b8439d30$@com> MIME-Version: 1.0 X-MC-Unique: 114112719204903201 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2014-11/txt/msg00855.txt.bz2 > Ond=F8ej B=EDlka wrote: > On Fri, Oct 24, 2014 at 04:56:23PM +0100, Wilco Dijkstra wrote: > > Ping (there was some further discussion but I don't see an OK for this = patch) > > > Looks ok, any reason why not simplify it more to strnlen+memcpy+memset? Well that is possible too. I benchmarked this and it is 1.7x on x64, and 2x on AArch64 (compared to my patch). However it does seem to be mostly due to the large strings, small strings are slower as you can see below. I don't believe that bench-strncpy is a good benchmark as it only seems to test str= ings of 0.5x, 1.0x and 2.0x the buffer size (none of which would be common in the real world), do you happen to know a better strncpy benchmark? strncpy_orig strncpy Length 16, n 16, alignment 1/ 1: 31.1694 60.0666 Length 16, n 16, alignment 1/ 1: 36.8311 60.0364 Length 16, n 16, alignment 1/ 2: 35.9034 60.0394 Length 16, n 16, alignment 2/ 1: 37.768 60.0356 Length 2, n 4, alignment 7/ 2: 60.9953 75.4958 Length 4, n 2, alignment 2/ 7: 19.6473 57.3082 Length 2, n 4, alignment 7/ 2: 57.9887 75.4963 Length 4, n 2, alignment 2/ 7: 21.8327 57.3139 ... Length 256, n 512, alignment 0/ 0: 423.878 193.744 Length 1024, n 512, alignment 0/ 0: 729.506 262.873 Length 256, n 512, alignment 2/ 4: 423.877 207.391 Length 1024, n 512, alignment 2/ 4: 728.664 273.792 Length 512, n 1024, alignment 0/ 0: 796.739 315.629 Length 2048, n 1024, alignment 0/ 0: 1425.05 479.289 Length 512, n 1024, alignment 1/ 6: 791.347 333.821 Length 2048, n 1024, alignment 1/ 6: 1428.08 493.005