tarantool/tarantool

sql: implement threaded interpretation for VDBE

Aperta

#4212 aperta il 14 mag 2019

 (3 commenti) (0 reazioni) (1 assegnatario)Lua (406 fork)batch import
good first issueoptimizationperformancesql

Metriche repository

Star
 (3633 stelle)
Metriche merge PR
 (Merge medio 13g 2h) (82 PR mergiate in 30 g)

Descrizione

Overall, problem is discussed here: https://github.com/tarantool/tarantool/issues/3330

Implementation of threaded interpretation is quite simple. However, it requires support of computed goto's by compiler. Most of mainstream compilers (gcc, clang, icc) provide that feature.

There are several examples of implementation: SQLite https://github.com/AlexKashuba/SQLite_JIT/blob/master/versions/sqlite_disp/jitsrc/vdbe.c#L646 PostgreSQL https://github.com/postgres/postgres/blob/master/src/backend/executor/execExprInterp.c#L117

Plan is following:

  1. Patch mkopcodec.sh and mkopcodeh.sh to produce array of goto addresses - it must be organised in the same order as corresponding OP_ values are defined.
  2. Define macros DISPATCH/CASE to hide internal implementation of dispatching: if compiler doesn't support precomputed labels, then we should use common switched technique.
  3. Replace break and case keywords with mentioned macros.
  4. Benchmark results using TPC-H set of queries.

Guida contributor