PDA

View Full Version : installer taking 100% CPU


adrien
07-16-2009, 11:57 PM
we recently changed our installer to do all the "work" of installation in the On Progress event handler for the "while installing" screen.

This was done so we could show progress of our tasks, some of which can take a long time.

Prior to this, we did our actions in On Pre Install and On Post Install. This would cause nothing to be displayed by the installer (no screen at all - nada) for too long (over 10s) while we say stop a service etc. This could lead users to think the installer had crashed, and terminate it with task manager.

Ok, so we put absolutely EVERYTHING into the while installing On Progress event.

This included writing a LOT of registry strings. We only did this work if e_Stage == INSTALL_STAGE_PREPARING (for stopping services and apps), and if e_Stage == INSTALL_STAGE_CREATING_SHORTCUTS (to install service, install driver, set registry).

One effect of doing this, is that installing files is now EXTREMELY slow, and the installer irsetup.exe runs at 100% CPU.

So I'm wondering if the installer is parsing the entire Lua script each file? Surely not? Why does putting actions in unrelated stages affect the INSTALL_STAGE_INSTALLING_FILES stage?

Actually ideally the framework would allow this - allow us to do stuff that we can show in the progress dialog of the main "While installing" screen.

Splitting out each stage into its own event would be great, and have another event you call between each stage. E.g. instead of having just On Progress, you would have

OnPreparing
OnPostPreparing
OnInstallingFiles
OnPostInstallingFiles
OnCreatingUninstaller
OnPostCreatingUninstaller
OnCreatingShortcuts
OnPostCreatingShortcuts

events.

how 'bout it?

Ulrich
07-20-2009, 09:03 AM
Hello,

while I understand what you wanted to achieve, your approach will not work as you expect. The On Progress event is a callback, fired by several actions, so your script will be executed several times. Even if you place tests to verify at which stage the installer is currently performing actions (for example, INSTALL_STAGE_CREATING_SHORTCUTS), this part of the script will still be executed for each shortcut you are creating. In your case, you say that you edit the registry... well, you probably are editing the registry repeatedly, each time new shortcut is created.

The Progress screen should be a reflection to what happens in your installer, and should be used to give visual feedback, instead of using it to perform additional actions. In other words, the screen should be driven by the installer, while you try to drive the installer with the screen. You should use the screen to show display some message, advance the progress bar, and allow the installer to resume its operation quickly.

So, what could you do instead? For example, you could add one or two additional screens where you perform your tasks. You say that you install/start/stop services. You could include a screen with progress bars, and advance them as needed. You could use one bar to show the total progress (service 1 of n installed/started/stopped), the second bar could be controlled by a timer, and show some activity while the setup is working in the background, waiting for the service to respond to the request. The user would have some visual feedback, and would know that the installer didn't freeze.

We added your suggestion for additional install stages to the database, the entry received the number 18803.

Ulrich

adrien
07-20-2009, 10:04 AM
Hi Ulrich

Thanks for your reply.

I actually used a couple of global variables to make sure each section was executed only once, but it's still slow. I saw that some stages were called many times.

So I was wondering if it might be something to do with the way the script is loaded / executed in the lua runtime. I've actually embedded lua in a C++ app before. Obviously the same runtime must be used for the entire installation, else globals wouldn't work, but you're not loading the script more than once perchance?

Might it be quicker if I took all the say registry code (about 400 lines) out and put it in a global function instead?

I'm a bit reluctant to add other screens although that's the obvious solution if we can't get it working any other way, since then there would be several progress screens that we move through.

Thanks

Adrien

Ulrich
07-20-2009, 02:58 PM
Hello,

I definitely would add a few screens, as in my opinion this would be best way to avoid problems.

Ulrich