Import Library Speed

Feb 6, 2010 at 5:58 PM

I have a library which takes about 3-4 seconds to load. I imagine this is because my main library, general.sls, imports my other libraries and then reexports their exports. If i simply load all of the other libraries separately it is almost instant.

So is there any way to 'compile' a library so that whatever it has to do which makes it take so long to import is already done? Ive tried compiling them but it doesn't speed importing up.

Coordinator
Feb 7, 2010 at 8:25 AM

Hi

Sorry for being so quiet, been a bit ill and had work deadlines.

Anyways, if compiled correctly, this should be 'instant'.

How did compile it?

The best is to create a 'program' that simply imports that library, all the dependencies should be compiled too.

IOW (in a file called general.sps):

(import (all-mystuff))

Then compile this with:

(compile "general.sps")

You should see all the dependencies being serialized (not if all is up to date).

For each dependent library, you should see a .fasl file. The library reader will attempt to read the .fasl first if it is avaiable, and that should be very fast.

Note that you will get a warning if the .fasl file is out of date. Then simply recompile 'general.sps'.

Anyways, if this is what you been doing, something else seems fishy...

Cheers

leppie

Feb 9, 2010 at 12:17 AM
Edited Feb 9, 2010 at 12:20 AM

Hmm... Still taking the same amount of time. 3 seconds for the general utility library and approximately 9 seconds for the other one. I suppose 2-3 seconds of the other one might be understandable for the second one because it directly imports 3 assemblies using Assembly.LoadFrom but i have no clue where the other time is coming from.

I made sure to also recompile IronScheme source as i did make some changes to fix a previous bug. But besides that, i compiled everything the way you suggested. The general utility libraries have approximately 6 .sls library files which are interelated, but i don't think this should matter? These are the files I have:

/lib/utils/general.sls /lib/utils/general-core.sls /lib/utils/general-functions.sls /lib/utils/srfi/88.sls /lib/utils/srfi/89.sls /lib/utils/srfi/89/helpers.sls

Each one has a .fasl file by it. Is there something I'm missing?

 

EDIT: of course, the 3 seconds comes from restarting ironscheme and attempting to import library .

 

Coordinator
Feb 9, 2010 at 7:56 AM

If you rebuilt IronScheme, you can improve the startup speed by running:

ngen install ironscheme.boot.dll

 

I dont think you are missing anything though.

I know some libraries with heavy duty macros can take a while, but if precompiled, it should not be that bad.

Another option might be to move the 'program' part, to a separate library, and import that too. Obviously, this will also be precompiled if you do so, and that should help speed up things.

So basically, for the best speed, your program part should be a 'one-liner' calling into the main program library.

This will allow a full expansion to take place when you precompile (the content of a program never precompiles), and you wont see the runtime performance hit.

Hope this helps  :)