2.7 Startup speed

If Gforth is used for CGI scripts or in shell scripts, its startup speed may become a problem. On a 300MHz 21064a under Linux-2.2.13 with glibc-2.0.7, gforth -e bye takes about 24.6ms user and 11.3ms system time.

If startup speed is a problem, you may consider the following ways to improve it; or you may consider ways to reduce the number of startups (for example, by using Fast-CGI).

An easy step that influences Gforth startup speed is the use of the --no-dynamic option; this decreases image loading speed, but increases compile-time and run-time.

Another step to improve startup speed is to statically link Gforth, by building it with XLDFLAGS=-static . This requires more memory for the code and will therefore slow down the first invocation, but subsequent invocations avoid the dynamic linking overhead. Another disadvantage is that Gforth won't profit from library upgrades. As a result, gforth-static -e bye takes about 17.1ms user and 8.2ms system time.

The next step to improve startup speed is to use a non-relocatable image (see Non-Relocatable Image Files). You can create this image with gforth -e "savesystem gforthnr.fi bye" and later use it with gforth -i gforthnr.fi ... . This avoids the relocation overhead and a part of the copy-on-write overhead. The disadvantage is that the non-relocatable image does not work if the OS gives Gforth a different address for the dictionary, for whatever reason; so you better provide a fallback on a relocatable image. gforth-static -i gforthnr.fi -e bye takes about 15.3ms user and 7.5ms system time.