Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

stani

DLLs and speed...

This topic is 6410 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all. This was just a spontaneous question that I had and could not answer. Let''s assume I build a library of time-critical functions (a 3D engine, for example), do I loose speed if I access them from a DLL instead of having them compiled directly into the engine? If so, what is the overhead, meaning, how much am i loosing?

Share this post


Link to post
Share on other sites
Advertisement
For standard usage of a DLL, you''d probably only lose about 1 clock cycle on each non-local DLL call. That is a call from within the DLL to another function in that DLL would have no additional overhead. Calls to functions in delayloaded DLLs can be much, much more expensive.

Share this post


Link to post
Share on other sites
just a thought. but, under protected mode programming concepts. calling a function from a DLL would mean calling a function in a different code segment, thus requiring a far call. functions all in the same code base, mean linked by the linker and not by the windows loader would be a near call. a far call is definitely slower than a near call { however minute, it''s still slower } this a DLL function calls would be slower. i haven''t looked a the disassembly of DLL calls { i will though } to see if this is the case.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
quote:
Original post by jenova

just a thought. but, under protected mode programming concepts. calling a function from a DLL would mean calling a function in a different code segment, thus requiring a far call.


Hmm, your information is kind of... outdated.
All this NEAR-FAR crap was in the Win16.
Win32 uses flat address space, so all of the jump/call-s are NEAR.
(well, there are some exceptions in the kernel & drivers...)

P.S.
calling a function from a DLL is a little bit slower - it''s an indirect call (by pointer in a memory).

Share this post


Link to post
Share on other sites
thnx a lot to everybody.

so, how is it done in the industry? do the ''big guys'' use dlls for such stuff or do they compile it into the executable?

Share this post


Link to post
Share on other sites
quote:
Original post by stani
so, how is it done in the industry? do the ''big guys'' use dlls for such stuff or do they compile it into the executable?


If it is really time critical, then shouldn''t it be inlined?

A dll is used so that you do not need to recompile the program when you need to do updates to the lib.(if your interfaces stay constant)

If it is something then won''t be changed, then better not put it in dll cause too many dlls will slow your loading code by a lot!.

Share this post


Link to post
Share on other sites
If you rebase the DLLs, then loading time isn''t affected all that much.

And no a time critical tight loop shouldn''t contain a DLL call, but there''s no reason you can''t put that tight loop inside a DLL function.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!