2013/6/2 Etienne Sandré-Chardonnal <etienne.san...@m4x.org>

> Dear all,
>
> I'm using Mingw gcc 4.8.0 rubenvb seh build for x64 (native compiler)
>
> In my program, I am using large binary trees, each node being a Node class
> which is either a true node (two children pointers) or a leaf (pointer on
> some data), never both. It also has an integer member which allows
> recognizing if this is a true node or leaf.
>
> As the trees are huge (millions of nodes) and memory use large (typically
> 8GB), I'm trying to fine tune the data structures memory footprints.
>
> So I tried using a union for the Node class, unionning the true node and
> leaf pointers. This by doing a union of anonymous structs.
>
> The new code works well, and this spared about 5% memory allocation (which
> is significant here), but it also runs about 3% slower (which is also
> significant), the tree traversal representing about 30% of CPU use, this
> means its code is about 10% slower.
>
> I also tried, instead of a union, using a void* ptr instead of two
> pointers (one children for the true node, and leaf data pointer) to achieve
> a similar thing, using reinterpret_cast in member functions for getting the
> proper pointer types. This was even slower than the union.
>
> The Node class has no inheritance and nothing virtual.
>
> Do someone has an explanation for this? I was expecting a slight speed
> increase due to better cache efficiency of the tree traversal, so I'm
> disappointed!
>

I suggest asking this (with a tad more code if possible) on
StackOverflow.com. There are some incredibly knowledgeable people there
that might give you some hints on what exactly is biting you. I would guess
it's pointer aliasing that's preventing some optimization.

At least you've approached this from a "measure, measure, measure"
perspective, which is a good thing ;-)

Sorry for the delayed answer,

Ruben


> Thanks,
>
> Etienne
>
>
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite
> It's a free troubleshooting tool designed for production
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://p.sf.net/sfu/appdyn_d2d_ap2
> _______________________________________________
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
>
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to