From d3f15baa4a0d903210d70db5ec51d887afdc5ea1 Mon Sep 17 00:00:00 2001 From: Steve Chavez Date: Thu, 29 Feb 2024 16:44:10 -0500 Subject: [PATCH] nix: add `postgrest-profiled-run` (#3292) --- nix/tools/cabalTools.nix | 2 +- nix/tools/memory.nix | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/nix/tools/cabalTools.nix b/nix/tools/cabalTools.nix index decef9ab1..0174d7fa3 100644 --- a/nix/tools/cabalTools.nix +++ b/nix/tools/cabalTools.nix @@ -42,7 +42,7 @@ let [ "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_USE_ENV([PGRST_DB_POOL_ACQUISITION_TIMEOUT], [1], [PostgREST pool timeout])" "ARG_LEFTOVERS([PostgREST arguments])" ]; workingDir = "/"; diff --git a/nix/tools/memory.nix b/nix/tools/memory.nix index 15683275d..a39178afe 100644 --- a/nix/tools/memory.nix +++ b/nix/tools/memory.nix @@ -1,6 +1,7 @@ # The memory tests have large dependencies (a profiled build of PostgREST) # and are run less often than the spec tests, so we don't include them in # the default test environment. We make them available through a separate module. +# TODO both of these require reentering the nix-shell if you make a change to the code { buildToolbox , checkedShellScript , curl @@ -20,9 +21,31 @@ 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. Note: if you make a change to the code, you must reenter the nix-shell for an updated profiled build."; + 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 timeout])" + "ARG_LEFTOVERS([PostgREST arguments])" + ]; + workingDir = "/"; + withPath = [ postgrestProfiled ]; + } + '' + 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; }; }