|
楼主 |
发表于 2008-11-7 17:32:35
|
显示全部楼层
用gprof对引擎进行分析,结果非常出人意料,主要开销居然在unref操作上面!之前用d语言+tango+derelict(d语言opengl接口)实现了现有的渲染引擎,因为d支持垃圾回收所以没有维护引用计数的开销,毕竟偶尔的回收比经常的引用计数维护要高效。
x86平台 OpenThreads库的OpenThreads::Atomic::operator++/operator--操作通过lock xadd $eax, _refCount实现效率尚且如此,MIPS下OpenThreads没有使用gcc builtin atomic结果就更加难看了。
下面是x86平台运行结果gprof输出:
$ gprof osgviewer
% cumulative self self total
time seconds seconds calls ms/call ms/call name
52.72 0.49 0.49 3 163.43 163.43 osg::Referenced::unref() const
47.34 0.93 0.44 osgDB::AuthenticationDetails::AuthenticationDetails(std::string const&,
std::string const&, osgDB::AuthenticationDetails::HttpAuthentication)
0.00 0.93 0.00 199091995 0.00 0.00 data_start
0.00 0.93 0.00 2 0.00 0.00 std::basic_string<char, std::char_traits<char>, std::allocator<char> >
std::operator+<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allo
cator<char> > const&, char const*)
0.00 0.93 0.00 1 0.00 0.00 global constructors keyed to main
0.00 0.93 0.00 1 0.00 163.43 osg::ArgumentParser::~ArgumentParser()
0.00 0.93 0.00 1 0.00 0.00 osgGA::KeySwitchMatrixManipulator::KeySwitchMatrixManipulator()
0.00 0.93 0.00 1 0.00 0.00 osgUtil::Optimizer::~Optimizer()
0.00 0.93 0.00 1 0.00 0.00 std::_Rb_tree<osg::Object const*, std::pair<osg::Object const* const, u
nsigned int>, std::_Select1st<std::pair<osg::Object const* const, unsigned int> >, std::less<osg::Object const*>, std::alloca
tor<std::pair<osg::Object const* const, unsigned int> > >::_M_erase(std::_Rb_tree_node<std::pair<osg::Object const* const, un
signed int> >*)
0.00 0.93 0.00 1 0.00 0.00 std::_Rb_tree<std::string, std::pair<std::string const, osg::ArgumentPa
rser::ErrorSeverity>, std::_Select1st<std::pair<std::string const, osg::ArgumentParser::ErrorSeverity> >, std::less<std::stri
ng>, std::allocator<std::pair<std::string const, osg::ArgumentParser::ErrorSeverity> > >::_M_erase(std::_Rb_tree_node<std::pa
ir<std::string const, osg::ArgumentParser::ErrorSeverity> >*)
-----------------------------------------------
[1] 52.7 0.00 0.49 main [1]
0.33 0.00 2/3 osg::Referenced::unref() const [2]
0.00 0.16 1/1 osg::ArgumentParser::~ArgumentParser() [4]
0.00 0.00 49/199091995 data_start [5]
0.00 0.00 2/2 std::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*) [9]
0.00 0.00 1/1 osgGA::KeySwitchMatrixManipulator::KeySwitchMatrixManipulator() [11]
0.00 0.00 1/1 osgUtil::Optimizer::~Optimizer() [12]
-----------------------------------------------
0.16 0.00 1/3 osg::ArgumentParser::~ArgumentParser() [4]
0.33 0.00 2/3 main [1]
[2] 52.7 0.49 0.00 3 osg::Referenced::unref() const [2]
0.00 0.00 198776802/199091995 data_start [5]
-----------------------------------------------
<spontaneous>
[3] 47.3 0.44 0.00 osgDB::AuthenticationDetails::AuthenticationDetails(std::string const&, std::string const&, osgDB::AuthenticationDetails::HttpAuthentication) [3]
-----------------------------------------------
0.00 0.16 1/1 main [1]
[4] 17.6 0.00 0.16 1 osg::ArgumentParser::~ArgumentParser() [4]
0.16 0.00 1/3 osg::Referenced::unref() const [2]
0.00 0.00 1/1 std::_Rb_tree<std::string, std::pair<std::string const, osg::ArgumentParser::ErrorSeverity>, std::_Select1st<std::pair<std::string const, osg::ArgumentParser::ErrorSeverity> >, std::less<std::string>, std::allocator<std::pair<std::string const, osg::ArgumentParser::ErrorSeverity> > >::_M_erase(std::_Rb_tree_node<std::pair<std::string const, osg::ArgumentParser::ErrorSeverity> >*) [14]
-----------------------------------------------
0.00 0.00 2/199091995 osgGA::KeySwitchMatrixManipulator::KeySwitchMatrixManipulator() [11]
0.00 0.00 49/199091995 main [1]
0.00 0.00 315142/199091995 osg::Object::~Object() [19]
0.00 0.00 198776802/199091995 osg::Referenced::unref() const [2]
[5] 0.0 0.00 0.00 199091995 data_start [5]
[[i] 本帖最后由 lifc 于 2008-11-7 17:34 编辑 [/i]] |
|