This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH][PING] Improve stpncpy performance


> 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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]