-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Count allocations in realtime (ros ticket #3406) #242
Comments
[sglaser] Here are the methods I've examined:
Solution 1 doesn't work because malloc hooks don't work in multithreaded applications. Malloc hooks rely on modifying global variables in a non-thread safe way for installing and removing the hooks which inevitably leads to creating infinite recursion into the hooks when the hook installation process goes bad. The infinite recursion can be avoided, but without using locking these leads to the possibility that the hooks will not always be called. Solution 2 doesn't work because you must choose a priori which libraries to link with the --wrap option. For example, if I link robot_mechanism_controllers with --wrap=malloc but not KDL, then any allocations which occur in the KDL library will not be handled by the malloc wrapper. Every package that gets used in realtime would have to be changed to be linked with the malloc wrapping. Solution 3 seems like the only possibility, but I haven't attempted to implement it yet. |
[gunter] Interesting. Does it help to limit the scope? I.e. to observe only allocations of a particular controller at a particular time. Meaning it would be okay to link with a particular library to get the information? As nice as it would be to always be able to look at the info, having it be a special debug process seems still VERY useful to me??? -gunter |
[gerkey] Following up on Gunter's suggestion, it doesn't seem that bad to me to have to explicitly re-link the libs you're using. Presumably, only a select handful of libs get used in realtime, because most libs aren't realtime-safe. |
[sglaser] Observing only one controller makes the code slightly simpler, but it doesn't change the mechanics of replacing malloc, which is the difficult part. Not observing the libraries the controller depends upon, in my opinion, defeats the purpose of counting the allocations. I think it's painful to have to change the CMakeLists for every package used in realtime when you want to debug, and I don't expect the LD_PRELOAD solution to be much more difficult than the --wrap solution. |
As a debugging tool, count the allocations performed by each controller in a cycle of the realtime loop.
trac data:
The text was updated successfully, but these errors were encountered: