[Bug 901] New: Usage of std::string objects to identify types slows down RTT


Summary: Usage of std::string objects to identify types slows
down RTT
Product: Toolchain
Version: master
Platform: All
OS/Version: GNU/Linux
Status: NEW
Severity: major
Priority: P3
Component: RTT
AssignedTo: orocos-dev [..] ...
ReportedBy: meyer [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

Created attachment 733
--> http://bugs.orocos.org/attachment.cgi?id=733
do not convert type_info names to std::string

When profiling my Orocos application using cachegrind I discovered a major
performance issue in the Orocos RTT type system.

The TypeInfoRepository::getTypeById() method currently uses a std::string
object to uniquely identify the types by their type_id and to retrieve the
TypeInfo object from its map. On the other hand typeid(T).name() returns a
"const char *". So each type lookup causes at least two temporary strings to be
created and compared (one for each TypeInfo object searched in the repository
and one for the type to be found).

I would propose to deprecate the TypeInfo::getTypeIdName() (or use const char *
directly) and use the address of the std::type_info object as a replacement.
This seems to be a valid solution according to this thread:
Of course this would break the API.

I created a patch to RTT and tested it with my application. The CPU load is now
much lower than without the patch. In addition, with Xenomai the instantiation
of strings might break real-timeliness.