Lisp Optimiser : How it works


The Lisp Optimiser operates on (defun ...) code blocks within Lisp files only;
any Lisp expression entered via commandline or outside (defun ...) blocks is not analysed.

By default, the Lisp Optimiser is active for each Lisp file being loaded by the (load ...) statement.

It is possible to disable the Optimiser by (vle-optimiser nil), which is immediately effective, and suppresses code optimisations, until enabled again; the control statements can appear at any place in a Lisp file, to support troubleshooting, if necessary.
At the end of the file being loaded, the Lisp Optimiser is automatically reset to enabled status again.

If a Lisp file loads another Lisp file by (load ...), the Lisp optimiser is automatically (re-)activated for the sub-loaded Lisp file;
if loading that file is finished, the Lisp Optimiser returns to the original status of the main Lisp file - in other words, for each Lisp file the Optimiser maintains its own status

Once the loading of a Lisp file is finished and processed by the Optimiser, the Lisp code remains untouched in memory, no further operations will happen on it - this means, the Lisp Optimiser is only active at Lisp load-time, not at Lisp run time.

(for other CAD systems, the (vle-optimiser t/nil) function is a No-Operation, provided by vle-extension.lsp file)

When loading a Lisp file with enabled Lisp Optimiser :

For each (defun ...) block being loaded from file, the Lisp Optimiser intercepts the evaluation of the defun block, and parses the Lisp code for known inefficient patterns - if such code patterns are found, they are replaced with more efficient ones, either "native" Lisp or VLE function expressions. The main goal is to increase performance combined with reduced memory load; performance improvements on cost of memory load is not an option here.

Of course, this load-time analysis costs a bit performance and a slightly slower loading of a Lisp file - in average, the loading time increases by around than 5% or less.

The Bricsys automatic test system contains dedicated tests to monitor and verify the correct behaviour of the Lisp Optimiser - each optimisation case is covered by several tests.

For the code patterns currently processed see Optimised Code Patterns.

Our Lisp Benchmark also contains dedicated benchmarks to verify the effects of load-time code optimisations.


©  Bricsys NV. All rights reserved.