From: "Wilco Dijkstra" <wdijkstr@arm.com>
To: "'Ondřej Bílka'" <neleai@seznam.cz>
Cc: <azanella@linux.vnet.ibm.com>, <libc-alpha@sourceware.org>
Subject: RE: [PATCH] Improve performance of strncpy
Date: Thu, 27 Nov 2014 19:20:00 -0000 [thread overview]
Message-ID: <000001d00a77$3d6bdf10$b8439d30$@com> (raw)
In-Reply-To: <20141123165227.GA27543@domone>
> Ondřej Bílka 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 strings
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
next prev parent reply other threads:[~2014-11-27 19:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-24 15:56 Wilco Dijkstra
2014-11-23 16:52 ` Ondřej Bílka
2014-11-27 19:20 ` Wilco Dijkstra [this message]
2014-11-27 20:51 ` Ondřej Bílka
-- strict thread matches above, loose matches on Subject: below --
2014-09-10 15:21 Wilco Dijkstra
2014-09-10 17:34 ` Florian Weimer
2014-09-10 18:02 ` Rich Felker
2014-09-10 18:25 ` Wilco Dijkstra
2014-09-11 19:37 ` Wilco Dijkstra
2014-09-12 6:22 ` Ondřej Bílka
2014-09-12 11:04 ` Wilco Dijkstra
2014-09-10 18:09 ` Wilco Dijkstra
2014-08-20 12:44 Wilco Dijkstra
2014-08-22 12:02 ` Adhemerval Zanella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000001d00a77$3d6bdf10$b8439d30$@com' \
--to=wdijkstr@arm.com \
--cc=azanella@linux.vnet.ibm.com \
--cc=libc-alpha@sourceware.org \
--cc=neleai@seznam.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).