Skip to content
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

RTLD_LAZY vs RTLD_NOW in PluginLoader #34

Closed
osrf-migration opened this issue Apr 16, 2018 · 2 comments
Closed

RTLD_LAZY vs RTLD_NOW in PluginLoader #34

osrf-migration opened this issue Apr 16, 2018 · 2 comments
Labels

Comments

@osrf-migration
Copy link

Original report (archived issue) by Carlos Agüero (Bitbucket: caguero, GitHub: caguero).


Looking at the PluginLoader implementation, we're using the RTLD_LAZY as the flag parameter when calling dlopen. Here's a description of the available flags.

Based on the documentation and a chat with @mxgrey, we conclude that Ignition Common doesn't have a particular preference between RTLD_LAZY or RTLD_NOW. The main implications seem to affect performance. RTLD_NOW front-loads some of the work when dlopen() is called at the cost of resolving symbols that might not be used. On the other hand, RTLD_LAZY returns faster from dlopen() but it will require to resolve the symbol the first time is really used.

To accommodate the different use cases from the Ignition Common users, we could expose the ability to choose the mode to the users. We discussed two options:

  • Expose the flag at the PluginLoader class. All subsequent calls to LoadLibrary() will use the previously set flag.
  • Expose the flag as a new LoadLibrary() parameter (possibly with a default option).
@osrf-migration
Copy link
Author

Original comment by clalancette (Bitbucket: clalancette, GitHub: clalancette).


My main concern with RTLD_LAZY vs. RTLD_NOW isn't really with performance, but more with debugging. As I see it, the big problem with RTLD_LAZY is that you don't find out if you can't resolve a symbol until you actually try to call that symbol. That means that the program may be successfully running for a while, and then when some new functionality gets invoked the program crashes because it can't resolve the symbol. If we did RTLD_NOW, then the symbol resolution would fail at program startup time and it is an easy thing for a developer to see, understand, debug, and fix.

With that said, I'd be in favor of just switching ignition to RTLD_NOW and leaving it at that. If we want to make it configurable, I'm fine with that too, but would prefer RTLD_NOW to be the default.

@osrf-migration
Copy link
Author

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


  • changed state from "new" to "closed"

migrated to https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-plugin/issues/6/rtld_lazy-vs-rtld_now-in-pluginloader (gazebosim/gz-plugin#6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant