This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RE: [PATCH][PING] Improve stpncpy performance
- From: "Wilco Dijkstra" <wdijkstr at arm dot com>
- To: 'OndÅej BÃlka' <neleai at seznam dot cz>
- Cc: <libc-alpha at sourceware dot org>
- Date: Wed, 19 Aug 2015 17:15:20 +0100
- Subject: RE: [PATCH][PING] Improve stpncpy performance
- Authentication-results: sourceware.org; auth=none
- References: <000301d0b7df$02f253d0$08d6fb70$ at com> <20150709110655 dot GA29253 at domone> <000c01d0ba58$44d1c170$ce754450$ at com> <20150812205744 dot GA15321 at domone>
> OndÅej BÃlka wrote:
> On Thu, Jul 09, 2015 at 04:02:26PM +0100, Wilco Dijkstra wrote:
> > > OndÅej BÃlka wrote:
> > >
> > > You don't have to use special case
> > >
> > > if (size == n)
> > > return dest;
> > >
> > > as it should be handled by
> > >
> > > return memset (dest, '\0', 0);
> > >
> > > That could improve performance a bit if its rare case. That doesn't
> > > matter much as memset makes that function slow and it shouldn't be
> > > used in performance sensitive code.
> > >
> > > Otherwise ok for me.
> >
> > On the benchtests the extra if made a significant difference, particularly
> > since memset of 0 is relatively expensive as it is being regarded as a very
> > rare case. It seems it should be less likely than the benchtests indicate,
> > but we'd have to fix the benchtest first to use more realistic data.
> >
> Ok, I did data collection and I take my objection back as it almost
> always happens in bash. I was surprised why it needs to use strncpy to
> copy small number of bytes.
>
> When I tested dryrun benchmark special casing is faster. I got following
> data on strncpy but no on stpncpy so we could reuse that for stpcpy patch that you also
> submitted.
OK thanks for checking the statistics. I've now committed it.
Wilco