To reduce load on the dynamic linker, dlopen should cache the modules it opened. At ldb_connect time only the init function should be called, the module does not have to be fetched from disk again.
According to irc:
11:46 vl > abartlet: question -- why do I get the "trying to load
<module>" whenever I issue a lsaquery call against s4?
11:47 vl > abartlet: Couldn't smbd keep a list of loaded modules and
just call the init function when needed?
11:47 abartlet@> yeah, it currently makes one database connection per
11:48 abartlet@> 'use' - such as an LSA bind (kept for the whole session)
11:48 vl > abartlet: Sure, that part is ok. I mean it a level lower.
Keep a list of dlopen'ed files.
11:48 vl > This should reduce the load on dlopen considerably.
11:48 abartlet@> but that can seem excessive, and simply loading them off
the disk is what tridge noticed was slowing us down
11:48 abartlet@> yeah, that seems very reasonable
11:48 vl > shall I file a bug report with that?
11:49 abartlet@> please do
Marking as "Feature request"
Update on this report: we've now shared SAMDB contexts and better LDB-TDB indexes on s4 so a huge speedup was achieved. So my question: should we still keep this "dlopen" request open? Does it bring us still more performance?