www.digitalmars.com         C & C++   DMDScript  

c++.announce - Backyard C++ Hotrodding

reply Walter Bright <newshound digitalmars.com> writes:
is now up on:

http://www.artima.com/cppsource/backyard.html
May 23 2006
next sibling parent reply Sean Kelly <sean f4.ca> writes:
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 23 2006
parent Walter Bright <newshound digitalmars.com> writes:
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.
May 23 2006
prev sibling parent reply James Mansion <James_member pathlink.com> writes:
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
Jun 01 2006
next sibling parent Sean Kelly <sean f4.ca> writes:
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
Jun 01 2006
prev sibling parent Walter Bright <newshound digitalmars.com> writes:
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?
Jun 01 2006