Skip to content

Commit

Permalink
nix: add postgrest-profiled-run
Browse files Browse the repository at this point in the history
Runs a profiled build of postgREST that can be used for optimization.
  • Loading branch information
steve-chavez committed Feb 28, 2024
1 parent a1480c7 commit 97cd559
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ rec {

# Script for running memory tests.
memory =
pkgs.callPackage nix/tools/memory.nix { inherit postgrestProfiled withTools; };
pkgs.callPackage nix/tools/memory.nix { inherit postgrestProfiled postgrest withTools; };

# Utility for updating the pinned version of Nixpkgs.
nixpkgsTools =
Expand Down
26 changes: 25 additions & 1 deletion nix/tools/memory.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
, checkedShellScript
, curl
, postgrestProfiled
, postgrest
, withTools
}:
let
Expand All @@ -20,9 +21,32 @@ let
${withTools.withPg} -f test/spec/fixtures/load.sql test/memory/memory-tests.sh
'';

runProfiled =
checkedShellScript
{
name = "postgrest-profiled-run";
docs = "Run a profiled build of postgREST. This will generate a postgrest.prof file that can be used to do optimization.";
args =
[
"ARG_USE_ENV([PGRST_DB_ANON_ROLE], [postgrest_test_anonymous], [PostgREST anonymous role])"
"ARG_USE_ENV([PGRST_DB_POOL], [1], [PostgREST pool size])"
"ARG_USE_ENV([PGRST_DB_POOL_ACQUISITION_TIMEOUT], [1], [PostgREST pool size])"
"ARG_LEFTOVERS([PostgREST arguments])"
];
workingDir = "/";
withPath = [ postgrestProfiled ];
withEnv = postgrest.env;
}
''
export PGRST_DB_ANON_ROLE
export PGRST_DB_POOL
export PGRST_DB_POOL_ACQUISITION_TIMEOUT
postgrest +RTS -p -h -RTS "''${_arg_leftovers[@]}"
'';
in
buildToolbox
{
name = "postgrest-memory";
tools = { inherit test; };
tools = { inherit test runProfiled; };
}

0 comments on commit 97cd559

Please sign in to comment.