TypeFunction example: ImplictConvTargets

Steven Schveighoffer schveiguy at gmail.com
Wed Oct 7 14:10:56 UTC 2020


On 10/7/20 12:17 AM, H. S. Teoh wrote:
> On Tue, Oct 06, 2020 at 08:47:33PM -0700, Walter Bright via Digitalmars-d wrote:
>> On 10/6/2020 11:09 AM, Adam D. Ruppe wrote:
>>> The Phobos implementation started life with a very simple
>>> implementation too. It became what it is because it *had to*,
>>> specifically for performance reasons.
>>
>> Professional C Standard library implementations tend to be hideous
>> code to perform objectively simple operations. The reason is speed is
>> so desirable in foundational code that it drives out all other
>> considerations. (memcpy() is a standout example.)
> 
> A little tangential aside: one time as a little coffee break challenge,
> I decided to see how D compares to GNU wc in terms of the speed of
> counting lines in a text file.  The core of wc, of course, is in memchr
> -- because it's scanning for newline characters in a buffer.  In the
> course of ferreting out what made wc so fast, I studied how GNU libc
> implemented memchr.  Basically, in order to speed up scanning large
> buffers, it uses a series of fancy bit operations on 64-bit words in
> order to scan 8 bytes at a time, I suppose the goal being to achieve
> close to 8x speedup, and also to reduce the number of branches per
> iteration to capitalize on the CPU's pipeline.

memchr is also the secret sauce to how iopipe was able to beat Phobos 
byLine and getline.

I would like to go back to it at some point and see if it can be improved.

I know that part of the difference would be due to the opaque function 
call (this cannot be inlined), though perhaps memchr is an intrinsic?

-Steve


More information about the Digitalmars-d mailing list