-1

Will I get better performance if I break my code into pieces put them in DLLs?

Is there something wrong with having multiple DLLs in terms of performance or is it better? Or does not have any affect?

My project is quite large and I heard that DLLs are not suitable for cross-platform apps. Is it true?

  • 1
    "Do DLLs improve performance?": yes and no. If shared among multiple instances of the application, or multiple applications, they can save memory, which reduces paging, which improves performance considerably. If there is no paging, no. – user207421 Feb 23 '22 at 09:28

2 Answers2

0

DLLs can have positive and negative impact on performance. As with all performance questions you should get data before committing to a strategy.

Huge headers / huge code / slow compilation does not mean slow performance. It's often the other way around: that slow compilation is because you've given the optimizer a lot to work with. And simply rearranging your project won't reduce the amount of code. You'll just cordon off bits so the optimizer has less to work with. You may benefit in project structure, but at the cost of optimization opportunities.

A lot of modern elegant C++ is templated and purely in header files. That allows inlining as the optimizer sees fit. Breaking code into separate images will prevent optimization across image boundaries.

Consider the development cost of using DLLs as well. Interfaces across DLLs present a lot of complications. For example templated / header-inlined code should be avoided in the ABI. It's the entire reason COM was invented: to deal with the difficulties of passing basic objects between DLL boundaries.

To try and answer the question, my gut feeling is that "No", breaking your project into multiple modules will do absolutely nothing to improve performance and is much more likely to make it perform worse. I say that with about 93% confidence. But as I said: The only way to properly answer your question is to measure.

tenfour
  • 36,141
  • 15
  • 83
  • 142
-1

No. DLL(s) cause more delay in loading than a statically linked libraries. Because the operating system loader needs to open the DLL and link it individually which affects time. Calling DLL functions is not slow because they are pointed in the import address table of your executable image, the loader then modify these pointers to match the address of symbols imported in the DLL.

  • Yes. But rather than that, DLL's can be updated without recompiling your code , if you're statically linking your application to an operating system dll. It can make your application unusable after a time. But it's not always the case because os providers know that and does not remove functions from support. They add a newer function that can be used without removing the old functions. –  Feb 14 '22 at 19:36
  • That's totally the opposite of what you think. So yeah, DLL's are what affects "only" load time. Then in runtime, it becomes the same as statically linking a library. –  Feb 14 '22 at 19:57