ReBaseImage
(1)
DLLs
(1)
LoadLibrary
(1)
OptionArkady
(1)
Windows
(1)
Pietrek
(1)
Perforamance
(1)
E572023C533B
(1)
Optimize DLL load time
Asked By Danie
03-Jul-07 10:00 PM
Hi,
My application loads many DLLs using Loadlibrary. The number of the DLLs can
be as many as four hundred DLLs (in the same directory of the application). I
used the SDK rebase to rebase all the DLLs. Is there an API to get the
address of the loaded DLLs after it was loaded by the application? Also, any
advice about optimzing the DLL load time and run time is appreciated.
--
Thanks,
Daniel
The HMODULE value returned by LoadLibrary is actually the base address.
Asked By Skywing [MVP]
03-Jul-07 10:09 PM
The HMODULE value returned by LoadLibrary is actually the base address. You
can cast it to a pointer-sized type and examine it that way.
You can also use the various functions to enumerate loaded modules (e.g.
PSAPI, Toolhelp32), which return the HMODULE (base address) for each mapped
image, though this is relative to the address space of the target process.
Beyond that, a debugger (e.g. WinDbg) should be able to provide you with a
list of loaded modules and their base addresses - in WinDbg, use `lm' for
that purpose. Also, I believe Process Explorer (
http://www.sysinternals.com ) has an option to highlight rebased DLLs while
inspecting a process if you want to check if you have missed any that are
still getting moved at load-time.
--
Ken Johnson (Skywing)
Windows SDK MVP
http://www.nynaeve.net
regardless, 400 DLLs is not a perfomant design no matter what you do.
Asked By Doron Holan [MSFT]
04-Jul-07 12:38 AM
regardless, 400 DLLs is not a perfomant design no matter what you do.
Strongly consider reducing the number of DLLs you are trying to load
overall, it will reduce memory fragmentation for instance.
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
So my question here how many functions each dll have , seems to me not a lot
Asked By Arkady Frenkel
04-Jul-07 02:55 AM
So my question here how many functions each dll have , seems to me not a lot
proposition of Doron )
Arkady
Just to spread loading time, check /DELAYLOAD linker optionArkady"Daniel"
Asked By Arkady Frenkel
04-Jul-07 03:01 AM
Just to spread loading time, check /DELAYLOAD linker option
Arkady
Thanks for your answers and suggestions.
Asked By Danie
04-Jul-07 12:26 PM
Thanks for your answers and suggestions. Note that we are the only users of
this software.
The program calls LoadLibrary to load all these application specific DLLs.
So DELAYLOAD linker option is not applicable to this case. Right?
Is it a good idea to let the application to rebase the DLLs using
ReBaseImage to the address that was returned by HMODULE value (only the first
time it starts) so the next time the application starts, it would load
faster? Will the address be the same every time the application starts? if
two process of the same application starts will the virtual address would be
the same?
Is it better to rebase the DLLs randomly using a hash function and a range
of addresses?
--
Thanks,
Daniel
Oh, If you do that with LoadLibrary , you can do delay whenever you need, so
Asked By Arkady Frenkel
05-Jul-07 03:28 AM
Oh, If you do that with LoadLibrary , you can do delay whenever you need, so
you don't need to use DELAYLOAD switch. OTOH why you need to rebase dlls
during run-time, do it during development process ( you can set base address
in properties ), so that ( rebase) will not take time ( so that save
time-for-relocation * n-instances of your app )
Arkady
Use rebase.exe instead of RebaseImage(), it's easier.
Asked By Marc Sherman
07-Jul-07 10:31 PM
Use rebase.exe instead of RebaseImage(), it's easier. Also, after rebasing
all your dll's, look at using bind.exe to make load time a little bit
faster. Matt Pietrek wrote a really good article about rebasing and binding
some years ago in MSJ or (MSDN Mag). Just google for his name and rebase and
bind.
Marc
Thanks again.I rebased all the DLLs.
Asked By Danie
09-Jul-07 11:02 AM
Thanks again.
I rebased all the DLLs. There can be up to four process in one system
loading about 450 DLLs, 100 system and others. The relocations were reduced
from 70% to 7% so I was pleased with this result. I read that relocated DLLs
cause more fault paging and prevent sharing (the dll code) the physical
memory with other processes. So it optimizes the performance at run-time.
How can I measure this optimization? would perforamance monitor be the best
tool for that?
--
Thanks,
Daniel