简体   繁体   English

boost :: rtree受gcc编译器的影响很大

[英]boost::rtree is affected by gcc compiler greatly

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. 由于整个公司都使用gcc 3.4.5,因此我必须使用boost 1.57的rtree,因为boost 1.59的rtree有编译问题。 I just use rtree in following way: 我只是通过以下方式使用rtree:

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). 在我的用例中,元素数将是数千万,查询速度很快且可以接受,但是构建rtree的速度非常慢(当然启用了O2)。

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. 当我用gcc 4.4.7编译相同的测试程序并比较测试结果时,我发现这是因为gcc版本。

test environment: 测试环境:

CentOS 6.6
Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz

test log for gcc 4.4.7: 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: 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. 看来gcc 3.4.5编译的测试程序构建rtree的时间是4.4.7的三倍。

Is there anyone who met this problem before? 有人遇到过这个问题吗? Any advice to improve the performance under gcc 3.4.5? 有什么建议可以改善gcc 3.4.5下的性能? (I cannot choose compiler currently:() (我目前无法选择编译器:()

Thanks for everyone's help and the post packing algorithm in rtree in boost . 感谢大家的帮助以及boost中rtree中的后打包算法

After using packing algorithm (range constructor), the performance of building rtree is improved greatly. 使用打包算法(范围构造器)后,构建rtree的性能大大提高。

std::vector<value> boxes;

boost::timer t;

// ... (read box from test file)

std::cout << "read bbox file: " << t.elapsed() << " sec." << std::endl;

t.restart();
bgi::rtree<value, bgi::linear<500> > rtree(boxes);
std::cout << "build rtree with " << boxes.size() << " boxes in total: " << t.elapsed() << " sec." << std::endl;

test log for gcc 4.4.7 + packing algorithm: gcc 4.4.7 +打包算法的测试日志:

read bbox file: 23.07 sec.
build rtree with 42517937 boxes in total: 8.15 sec.

test log for gcc 3.4.5 + packing algorithm: gcc 3.4.5 +打包算法的测试日志:

read bbox file: 23.06 sec.
build rtree with 42517937 boxes in total: 10.94 sec.

Now the runtime difference between gcc 3.4.5 and 4.4.7 is acceptable. 现在,gcc 3.4.5和4.4.7之间的运行时差异是可以接受的。

PS: During my test, the runtime of building rtree without O2 and packing algorithm could be 1000 times slower. PS:在我的测试过程中,不使用O2和打包算法构建rtree的运行时间可能会慢1000倍。 Hope this post could give someone who uses boost::rtree later some hint. 希望这篇文章可以给后来使用boost :: rtree的人一些提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM