Re: Faster StrNCpy

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Faster StrNCpy
Дата
Msg-id 25223.1159885218@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Faster StrNCpy  ("Zeugswetter Andreas DCP SD" <ZeugswetterA@spardat.at>)
Ответы Another aspect of set_ps_display ()  ("Strong, David" <david.strong@unisys.com>)
Список pgsql-hackers
"Zeugswetter Andreas DCP SD" <ZeugswetterA@spardat.at> writes:
>> I'm still interested to experiment with MemSet-then-strlcpy 
>> for namestrcpy, but given the LENCPY results this may be a loser too.

> Um, why not strlcpy then MemSet the rest ?

Two reasons:

* The main point is to do the zeroing using word-wide operations, and if
you do the above then memset will probably be facing a zeroing request
that is neither word-aligned nor word-length.  It may be able to recover
(doing it partly byte-wide and partly word-wide), but this will easily
eat up the time savings of skipping the first couple words.

* On compilers that treat memset as a builtin, there are significant
advantages to doing memset with a constant length: the compiler might
be able to unroll the loop entirely.  (I was annoyed to find that FC5's
gcc on x86_64 seems to understand very well how to inline a constant
length memcpy, but not memset :-(.)

I did actually do some experiments with the above yesterday, and found
that it was a significant win on an old x86 (with about a 10-byte source
string) but about a wash on newer architectures.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: [PATCHES] Generic Monitoring Framework with DTrace patch
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Faster StrNCpy