Since gcc 3.4.5 is used in the whole company, I have to use rtree of boost 1.57 because rtree of boost 1.59 has compile problem. I just use rtree in following way:
namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;
typedef bg::model::point<double, 2, bg::cs::cartesian> point;
typedef bg::model::box<point> box;
typedef std::pair<box, size_t> value;
// create the rtree using default constructor
bgi::rtree<value, bgi::linear<500> > rtree;
// create some values
ifstream ifs(bbox_filename);
if (!ifs.is_open()) return;
std::vector<box> boxes;
boost::timer t;
// ... (read box from test file)
std::cout << "read bbox file: " << t.elapsed() << " sec." << std::endl;
t.restart();
for (size_t i = 0; i < boxes.size(); ++i)
{
// insert new value
rtree.insert(std::make_pair(boxes[i], i));
}
std::cout << "build rtree with " << boxes.size() << " boxes in total: " << t.elapsed() << " sec." << std::endl;
In my use case, the element number would be tens of millions, the query speed is fast and acceptable, but the speed of building rtree is very slow (O2 is enabled of course).
When I compiled the same test program with gcc 4.4.7 and compare the testing result , I found it's because of gcc version.
test environment:
CentOS 6.6
Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz
test log for gcc 4.4.7:
read bbox file: 22.13 sec.
build rtree with 42517937 boxes in total: 163.28 sec.
test log for gcc 3.4.5:
read bbox file: 22.28 sec.
build rtree with 42517937 boxes in total: 468.73 sec.
It seems test program compiled by gcc 3.4.5 takes about 3 times of time to build rtree than 4.4.7.
Is there anyone who met this problem before? Any advice to improve the performance under gcc 3.4.5? (I cannot choose compiler currently:()