Contributor
Anastasia Neklepaeva

Various SQL VM improvements: threaded interpretation and instruction merging


Mentors
imun, Kirill Yukhin, Nikita Pettik, Timur Safin
Organization
Tarantool

Tarantool uses SQL VM with conventional interpretation technique: loop over instruction, inside which dispatching switch-case executes logic of current opcode. Beyond introduction of JIT to SQL subsystem there are multiple smaller improvements which might be developed for SQL virtual machine:

  • merge CHECKs bytecode into a monolithic program;
  • add VDBE assembler;
  • use threaded interpretation. The easiest approach in its implementation is 'threaded-code'. Threaded code is a programming technique where the code has a form that essentially consists entirely of calls to subroutines. It is often used in compilers, which may generate code in that form or be implemented in that form themselves. The code may be processed by an interpreter or it may simply be a sequence of machine code call instructions. Another optimization is instruction merging: a sequence of opcodes is replaced by a single mega opcode. There is a proposal to create a single VDBE running all the CHECK constraints.