Tips and tricks to speed up ConTeXt.
To avoid converting images on the fly every time ConTeXt is run, one can cache the images converted to PDF. Subsequently cached PDFs are used. Loading PDF is always faster compared to using other formats.
\externalfigure[cow.jpg] [width=40mm, cache=./cache, conversion=gray.pdf]
Command Line Options
They are mostly use on servers without human intervention, but can help on desktop, too. For the list of command line options use
ConTeXt finds itself how many runs are needed (up to 3) to make cross references right. There are occasions when one run is sufficient (development, partial processing). In that case one can use
Console output can be slow. When you don't need it, use
For production there are other useful options like
context --nosynctex --...
While optimizing the code one can compare the statistics of the ConTeXt run.
Hans on the list (LMTX):
The current version of lmtx has some updated tracing of memory usage. This is irrelevant for most users but some of you generat elarge an complex files so ... (I'm talking about mf here).
There is a command line option
that will make a run report some more statistics. The info shown might look somewhat cryptic but we basically have (per category)
- max: the maximum allowed memory (for many categories we can make that larger, but I need proof that it's needed)
- min: this is how we start out
- stp: when more memory is needed, this is the step that we use to increase
- set: this is the value that context configures by default, often larger than min, and less than max
- mem: the memory usage (often in units)
- all: the real usage (multiplied by the unit)
- ini, ptr and top: are the startup values (when something is also stored in the format), the current usage and the max usage (all within the mentioned min-max range).
The rest speaks for itself. Font usage reflects only the tex end, of course there is plenty usage at the lua end. The language info .... I might extend that with pattern and exception usage. Actually, tex memory usage is not that large in luametatex.
When mem gets increased, there is a message. We can use that to eventually determine the best values. Actually we might even lower some initial values (not that it matters much, lua uses more).
Of course there is also
but that one has been there from the start, although I did update it to reflect the more detailed tracing. The graphics are the same as always: red lines are usage, the blue line is the runtime.
In general, memory management has been improved: all categories are now more dynamic, there is more checking for overflows, there is some recovery slack in allocation, etc. I will play a bit more some of it, for instance we might end up with more detailed configuration options, in addition the the already new ones.