gazebosim / gazebosim/gz-plugin
RTLD_LAZY vs RTLD_NOW in PluginLoader
- Dominant language
- C++
- Stars
- 47
- Forks
- 31
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 5
Description
**Original report ([archived issue](https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-plugin/issues/6)) by Steve Peters (Bitbucket: [Steven Peters](https://bitbucket.org/%7B2ccfed09-18b8-4921-8d58-15ef01092802%7D/), GitHub: [scpeters](https://github.com/scpeters)).**
----------------------------------------
Migrated from https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-common/issues/34/rtld_lazy-vs-rtld_now-in-pluginloader (ignitionrobotics/ign-common#34)
Looking at the `PluginLoader` implementation, we're using the `RTLD_LAZY` as the flag parameter when calling `dlopen`. [Here's](http://tldp.org/HOWTO/Program-Library-HOWTO/dl-libraries.html) 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).
Contributor guide
Research direction
Start with the PluginLoader implementation and its dlopen call, which currently uses RTLD_LAZY. Compare exposing the mode on PluginLoader with adding it to LoadLibrary(), then define completion as allowing users to choose between RTLD_LAZY and RTLD_NOW.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100