Execution engine

Execution engine mk Thu, 02/20/2014 - 04:02

The execution engine comes in several flavors. The default is a simple, sequential MAL interpreter. For each MAL function call it creates a stack frame, which is initialized with all constants found in the function body. During interpretation the garbage collector ensures freeing of space consumptive tables (BATs) and strings.  Furthermore, all temporary structures are garbage collected before the funtion returns the result.

This simple approach leads to an accumulation of temporary variables.  They can be freed earlier in the process using an explicit garbage collection command, but the general intend is to leave such decisions to an optimizer
or scheduler.
The execution engine is only called when all MAL instructions can be resolved against the available libraries.  Most modules are loaded when the server starts using a bootstrap script mal_init.mal. Failure to find the startup-file terminates the session.  It most likely points to an error in the MonetDB configuration file.
During the boot phase, the global symbol table is initialized with MAL function and factory definitions, and loading the pre-compiled commands and patterns.  The libraries are dynamically loaded by default.  Expect tens of modules and hundreds of operations to become readily available.
Modules can not be dropped without restarting the server.  The rational behind this design decision is that a dynamic load/drop feature is often hardly used and severely complicates the code base.  In particular, upon each access to the global symbol table we have to be prepared that concurrent threads may be actively changing its structure.  Especially, dropping modules may cause severe problems by not being able to detect all references kept around.  This danger required all accesses to global information to be packaged in a critical section, which is known to be a severe performance hindrance.