Skip to content

Commit

Permalink
postgresql: support JIT
Browse files Browse the repository at this point in the history
Disable it by default because of closure size, and to avoid surprise
negative performance changes in production (were observed with very
large and complex queries due to compilation time).

See also dcd9455 for a great
explanation on how JIT interacts with packaging and closure size.
  • Loading branch information
abbradar committed Dec 18, 2021
1 parent 42941d3 commit 0b4b98f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkgs/servers/sql/postgresql/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ let
# This is important to obtain a version of `libpq` that does not depend on systemd.
, enableSystemd ? (lib.versionAtLeast version "9.6" && !stdenv.isDarwin)
, gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic, libkrb5
# Disable to avoid depending on LLVM and Clang by default.
, jitSupport ? false, llvm, clang

# for postgreql.pkgs
, self, newScope, buildEnv
Expand All @@ -19,11 +21,15 @@ let
# for tests
nixosTests, thisAttr
}:

let
atLeast = lib.versionAtLeast version;
icuEnabled = atLeast "10";
lz4Enabled = atLeast "14";
this = stdenv.mkDerivation rec {
in
assert jitSupport -> atLeast "11";

let this = stdenv.mkDerivation rec {
pname = "postgresql";
inherit version;

Expand All @@ -43,7 +49,8 @@ let
++ lib.optionals lz4Enabled [ lz4 ]
++ lib.optionals enableSystemd [ systemd ]
++ lib.optionals gssSupport [ libkrb5 ]
++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ];
++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ]
++ lib.optionals jitSupport [ llvm clang ];

nativeBuildInputs = [ makeWrapper ] ++ lib.optionals icuEnabled [ pkg-config ];

Expand All @@ -70,7 +77,8 @@ let
] ++ lib.optionals icuEnabled [ "--with-icu" ]
++ lib.optionals lz4Enabled [ "--with-lz4" ]
++ lib.optionals gssSupport [ "--with-gssapi" ]
++ lib.optionals stdenv.hostPlatform.isRiscV [ "--disable-spinlocks" ];
++ lib.optionals stdenv.hostPlatform.isRiscV [ "--disable-spinlocks" ]
++ lib.optionals jitSupport [ "--with-llvm" ];

patches =
[ (if atLeast "9.4" then ./patches/disable-resolve_symlinks-94.patch else ./patches/disable-resolve_symlinks.patch)
Expand Down

0 comments on commit 0b4b98f

Please sign in to comment.