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!

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to