I really love the Factor language. But I find that compiling programs written in it is incredibly slow, and thus it’s not feasible to create real projects with Factor.
For example, compiling the sample Calculator WebApp takes about 5 minutes on my laptop (i3 processor, 2GB RAM, running Fedora 15).
I’ve searched around but couldn’t find a faster way to compile Factor programs than using the interpreter (the main factor binary executable).
It becomes ridiculous when you attempt to only use the interpreter for each run and not “deploy” your program to a native binary file (which doesn’t even work on many programs).
It means that every time I want to run the Calculator, for example, I have to wait a 5 minute cold-start duration.
I’d like to know whether this is a common issue, and whether there’s a good way to tackle it.
I admit that before today, I had never heard of Factor. I took the opportunity to play with it. It is looking nice (reminds me of squeak-vm and lisp at the same time). I’ll cut the smalltalk (pun very much intended) and jump to your question.
Analysis
It appears that the way Factor works, results in loading vocabularies being slow.
I compiled Factor on my 64 bit quadcore linux system (from git revision
60b1115452, Thu Oct 6). Putting everything on tmpfs the build dir takes 641Mb, of which 2x114Mb is in the factor.image and its backup (factor.image.fresh).When
strace-ing the calculator app loading, there is a huge list of factor files being loaded:Can you confirm whether this is the case (likely if you are running some kind of shared host or VPS appliance). If you run a virtual machine, consider increasing the available system memory.
Saving Heap Images (snapshots)
I already mentioned the factor.image file (114Mb) before. It contains a ‘precompiled’ (bootstrapped, actually) heap image for the Factor VM. All operations in the VM (working on the UI listener or compiling factor files) affects the heap image.
To avoid having to recompile your source files time and time again, you can save the end-result into a custom heap image:
http://docs.factorcode.org/content/article-images.html
New images can be created from scratch: Bootstrapping new images
Deploying applications
Saving heap images results in files that will (typically) be bigger than the original bootstrap image.
The Application deployment tool creates stripped-down images containing just enough code to run a single application
Concluding
I expect you’ll benefit from (in order of quickest win):
This step brought the compilation on my system down from ~
30sto0.835sIn short, thanks for bringing Factor to my attention, and I hope my findings will be of any help, Cheers