|
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>31.1. What Is JIT compilation?</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="jit.html" title="Chapter 31. Just-in-Time Compilation (JIT)" /><link rel="next" href="jit-decision.html" title="31.2. When to JIT?" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">31.1. What Is <acronym xmlns="http://www.w3.org/1999/xhtml" class="acronym">JIT</acronym> compilation?</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="jit.html" title="Chapter 31. Just-in-Time Compilation (JIT)">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="jit.html" title="Chapter 31. Just-in-Time Compilation (JIT)">Up</a></td><th width="60%" align="center">Chapter 31. Just-in-Time Compilation (<acronym xmlns="http://www.w3.org/1999/xhtml" class="acronym">JIT</acronym>)</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="jit-decision.html" title="31.2. When to JIT?">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="JIT-REASON"><div class="titlepage"><div><div><h2 class="title" style="clear: both">31.1. What Is <acronym class="acronym">JIT</acronym> compilation?</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="jit-reason.html#JIT-ACCELERATED-OPERATIONS">31.1.1. <acronym class="acronym">JIT</acronym> Accelerated Operations</a></span></dt><dt><span class="sect2"><a href="jit-reason.html#JIT-INLINING">31.1.2. Inlining</a></span></dt><dt><span class="sect2"><a href="jit-reason.html#JIT-OPTIMIZATION">31.1.3. Optimization</a></span></dt></dl></div><p>
- Just-in-Time (<acronym class="acronym">JIT</acronym>) compilation is the process of turning
- some form of interpreted program evaluation into a native program, and
- doing so at run time.
- For example, instead of using general-purpose code that can evaluate
- arbitrary SQL expressions to evaluate a particular SQL predicate
- like <code class="literal">WHERE a.col = 3</code>, it is possible to generate a
- function that is specific to that expression and can be natively executed
- by the CPU, yielding a speedup.
- </p><p>
- <span class="productname">PostgreSQL</span> has builtin support to perform
- <acronym class="acronym">JIT</acronym> compilation using <a class="ulink" href="https://llvm.org/" target="_top"><span class="productname">LLVM</span></a> when
- <span class="productname">PostgreSQL</span> is built with
- <a class="link" href="install-procedure.html#CONFIGURE-WITH-LLVM"><code class="literal">--with-llvm</code></a>.
- </p><p>
- See <code class="filename">src/backend/jit/README</code> for further details.
- </p><div class="sect2" id="JIT-ACCELERATED-OPERATIONS"><div class="titlepage"><div><div><h3 class="title">31.1.1. <acronym class="acronym">JIT</acronym> Accelerated Operations</h3></div></div></div><p>
- Currently <span class="productname">PostgreSQL</span>'s <acronym class="acronym">JIT</acronym>
- implementation has support for accelerating expression evaluation and
- tuple deforming. Several other operations could be accelerated in the
- future.
- </p><p>
- Expression evaluation is used to evaluate <code class="literal">WHERE</code>
- clauses, target lists, aggregates and projections. It can be accelerated
- by generating code specific to each case.
- </p><p>
- Tuple deforming is the process of transforming an on-disk tuple (see <a class="xref" href="storage-page-layout.html#STORAGE-TUPLE-LAYOUT" title="68.6.1. Table Row Layout">Section 68.6.1</a>) into its in-memory representation.
- It can be accelerated by creating a function specific to the table layout
- and the number of columns to be extracted.
- </p></div><div class="sect2" id="JIT-INLINING"><div class="titlepage"><div><div><h3 class="title">31.1.2. Inlining</h3></div></div></div><p>
- <span class="productname">PostgreSQL</span> is very extensible and allows new
- data types, functions, operators and other database objects to be defined;
- see <a class="xref" href="extend.html" title="Chapter 37. Extending SQL">Chapter 37</a>. In fact the built-in objects are implemented
- using nearly the same mechanisms. This extensibility implies some
- overhead, for example due to function calls (see <a class="xref" href="xfunc.html" title="37.3. User-Defined Functions">Section 37.3</a>).
- To reduce that overhead, <acronym class="acronym">JIT</acronym> compilation can inline the
- bodies of small functions into the expressions using them. That allows a
- significant percentage of the overhead to be optimized away.
- </p></div><div class="sect2" id="JIT-OPTIMIZATION"><div class="titlepage"><div><div><h3 class="title">31.1.3. Optimization</h3></div></div></div><p>
- <span class="productname">LLVM</span> has support for optimizing generated
- code. Some of the optimizations are cheap enough to be performed whenever
- <acronym class="acronym">JIT</acronym> is used, while others are only beneficial for
- longer-running queries.
- See <a class="ulink" href="https://llvm.org/docs/Passes.html#transform-passes" target="_top">https://llvm.org/docs/Passes.html#transform-passes</a> for
- more details about optimizations.
- </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="jit.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="jit.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="jit-decision.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 31. Just-in-Time Compilation (<acronym class="acronym">JIT</acronym>) </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 31.2. When to <acronym class="acronym">JIT</acronym>?</td></tr></table></div></body></html>
|