Thread overview
Backyard C++ Hotrodding
May 23, 2006
Walter Bright
May 23, 2006
Sean Kelly
May 24, 2006
Walter Bright
Jun 01, 2006
James Mansion
Jun 01, 2006
Sean Kelly
Jun 02, 2006
Walter Bright
May 23, 2006
is now up on:

http://www.artima.com/cppsource/backyard.html
May 23, 2006
Walter Bright wrote:
> is now up on:
> 
> http://www.artima.com/cppsource/backyard.html

Great stuff!  I've only read the first page so far, but one thing caught my eye.  Change:

"We can then define a dehydrated pointer as being odd, and a hydrated pointer as being 1."

to:

"We can then define a dehydrated pointer as being odd, and a hydrated pointer as being even."


Sean
May 24, 2006
Sean Kelly wrote:
> Walter Bright wrote:
>> is now up on:
>>
>> http://www.artima.com/cppsource/backyard.html
> 
> Great stuff!  I've only read the first page so far, but one thing caught my eye.  Change:
> 
> "We can then define a dehydrated pointer as being odd, and a hydrated pointer as being 1."
> 
> to:
> 
> "We can then define a dehydrated pointer as being odd, and a hydrated pointer as being even."

Only about two dozen people reviewed that article, and all missed it <g>. Thanks.
June 01, 2006
>http://www.artima.com/cppsource/backyard.html

Hmm.  vptr is typically not at offset 0 if the base class is a POD.  It might be, depending on whether the compiler decides to change 'this' on the cast to base instead of just using an offset, but YMMV.

I can't help thinking that if you replace your malloc with nedmalloc or PTMalloc3 then most people will get a bigger speed boost than they will by trying to play dirty at such a low level.

James


June 01, 2006
James Mansion wrote:
>> http://www.artima.com/cppsource/backyard.html
> 
> Hmm.  vptr is typically not at offset 0 if the base class is a POD.  It might
> be, depending on whether the compiler decides to change 'this' on the cast to
> base instead of just using an offset, but YMMV.
> 
> I can't help thinking that if you replace your malloc with nedmalloc or
> PTMalloc3 then most people will get a bigger speed boost than they will by
> trying to play dirty at such a low level.

The tricks are useful in other ways though.  For example, I work with a piece of software whose "database" is a memory mapped file containing objects with modified vtbls.  The result is screaming fast and isn't something that could be accomplished by other means.  So I view this article more as a window to some of the evil (and sometimes useful) games one can play with C++ than as a template one should follow to increase performance in a typical application.


Sean
June 02, 2006
James Mansion wrote:
>> http://www.artima.com/cppsource/backyard.html
> 
> Hmm.  vptr is typically not at offset 0 if the base class is a POD.  It might
> be, depending on whether the compiler decides to change 'this' on the cast to
> base instead of just using an offset, but YMMV.

You do have to check that the vptr is in the right place, and adjust accordingly.


> I can't help thinking that if you replace your malloc with nedmalloc or
> PTMalloc3 then most people will get a bigger speed boost than they will by
> trying to play dirty at such a low level.

Why not do both and get double the speedup?