Re: Faster StrNCpy - Mailing list pgsql-hackers

From mark@mark.mielke.cc
Subject Re: Faster StrNCpy
Date
Msg-id 20060927232639.GA15401@mark.mielke.cc
Whole thread Raw
In response to Re: Faster StrNCpy  ("Strong, David" <david.strong@unisys.com>)
Responses Re: Faster StrNCpy  ("Strong, David" <david.strong@unisys.com>)
List pgsql-hackers
On Wed, Sep 27, 2006 at 07:08:05AM -0700, Strong, David wrote:
> We sometimes see TupleDescInitEntry () taking high CPU times via
> OProfile. This does include, amongst a lot of other code, a call to
> namestrcpy () which in turn calls StrNCpy (). Perhaps this is not a
> good candidate right now as a name string is only 64 bytes.

Just wondering - are any of these cases where a memcpy() would work
just as well? Or are you not sure that the source string is at least
64 bytes in length?
   memcpy(&target, &source, sizeof(target));   target[sizeof(target)-1] = '\0';

I imagine any extra checking causes processor stalls, or at least for
the branch prediction to fill up? Straight copies might allow for
maximum parallelism? If it's only 64 bytes, on processors such as
Pentium or Athlon, that's 2 or 4 cache lines, and writes are always
performed as cache lines.

I haven't seen the code that you and Tom are looking at to tell
whether it is safe to do this or not.

Cheers,
mark

-- 
mark@mielke.cc / markm@ncf.ca / markm@nortel.com     __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada
 One ring to rule them all, one ring to find them, one ring to bring them all                      and in the darkness
bindthem...
 
                          http://mark.mielke.cc/



pgsql-hackers by date:

Previous
From: Matteo Beccati
Date:
Subject: Re: -HEAD planner issue wrt hash_joins on dbt3 ?
Next
From: "Adnan DURSUN"
Date:
Subject: Can i see server SQL commands ?