JIT compiler
QuestDB includes a JIT compiler which is run on queries (and sub-queries) that perform a full scan over a table or table partitions. The main goal behind this feature is to improve performance for filters with arithmetical expressions. To do so, the JIT compiler emits machine code with a single function that may also use SIMD (vector) instructions.
For details on the implementation, motivation, and internals of this feature, see our article about SQL JIT compilation. This post describes our storage model, how we built a JIT compiler for SQL and our plans for improving it in future.
#
Queries eligible for JIT compilationThe types of queries that are eligible for performance improvements via JIT
compilation are those which contain WHERE
clauses. Here are some examples
which are supported based on the cpu-only
data set from the
Time Series Benchmark Suite
use case:
#
JIT compiler usageThe JIT compiler is enabled by default for QuestDB 6.3 onwards. If you wish to
disable it, change the cairo.sql.jit.mode
setting in the
server configuration file from on
to off
:
Embedded API users are able to enable or disable the compiler globally by
providing their CairoConfiguration
implementation. Alternatively, JIT
compilation can be changed for a single query by using the
SqlExecutionContext#setJitMode
method. The latter may look like the following:
Server logs should contain references to SQL JIT compiler mode
:
Due to certain limitations noted below, JIT compilation won't take place for all queries. To understand whether JIT compilation took place for a query, one will see something similar in the server logs:
#
Known limitationsThe current implementation of the JIT SQL compiler has a number of limitations:
- Only x86-64 CPUs are currently supported.
- Vectorized filter execution requires AVX2 instruction set.
- Filters with any SQL function, such as
now()
, orabs()
, orround()
, are not supported. - Filters with any pseudo-function or operator, such as
in()
on symbol column, orbetween
on non-designated timestamp column, orwithin
on geohash column, are not supported. - Only the following arithmetic operations are allowed to be present in the
filter:
+
,-
,*
,/
. - Only filters with fixed-size columns are supported: BOOLEAN, BYTE, GEOBYTE, SHORT, GEOSHORT, CHAR, INT, GEOINT, SYMBOL, FLOAT, LONG, GEOLONG, DATE, TIMESTAMP, DOUBLE.