From 9c5c17a3ee30429b99ef5328247dfd3c5bbc2fc2 Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Thu, 18 Jan 2024 18:10:09 +0000 Subject: [PATCH] feat(cmd): Disable postgres JIT for boundary dev After updating `boundary dev` to use postgres:12 by default, it was noticed that the responsiveness of boundary was noticeably slower. This is due to the introduction of JIT being enabled by default in postgres:12. JIT seems to incur noticeable overhead without providing benefits, at least for the instance used for `boundary dev`. It is also worth noting that for postgres:14 and newer, JIT does not get triggered for the same queries since they seem to result in a cheaper query plan that does not exceed the default threshold for JIT. See: https://www.postgresql.org/docs/current/jit.html ICU-12283 --- internal/cmd/base/internal/docker/supported.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/cmd/base/internal/docker/supported.go b/internal/cmd/base/internal/docker/supported.go index dc4b925466..677808370a 100644 --- a/internal/cmd/base/internal/docker/supported.go +++ b/internal/cmd/base/internal/docker/supported.go @@ -41,6 +41,16 @@ func startDbInDockerSupported(dialect string, opt ...Option) (cleanup func() err } } + runOpts := &dockertest.RunOptions{ + Tag: tag, + Env: []string{"POSTGRES_PASSWORD=password", "POSTGRES_DB=boundary"}, + Cmd: []string{ + // JIT seems to cause noticeable overhead without providing noticeable benefit. + // See: ICU-12283 + "-c", "jit=off", + }, + } + switch dialect { case "postgres", "pgx": switch { @@ -48,13 +58,15 @@ func startDbInDockerSupported(dialect string, opt ...Option) (cleanup func() err url = os.Getenv("BOUNDARY_TESTING_PG_URL") return func() error { return nil }, url, "", nil case repository != "": - resource, err = pool.Run(repository, tag, []string{"POSTGRES_PASSWORD=password", "POSTGRES_DB=boundary"}) + runOpts.Repository = repository + resource, err = pool.RunWithOptions(runOpts) url = "postgres://postgres:password@localhost:%s?sslmode=disable" if err == nil { url = fmt.Sprintf("postgres://postgres:password@%s/boundary?sslmode=disable", resource.GetHostPort("5432/tcp")) } default: - resource, err = pool.Run(dialect, tag, []string{"POSTGRES_PASSWORD=password", "POSTGRES_DB=boundary"}) + runOpts.Repository = dialect + resource, err = pool.RunWithOptions(runOpts) url = "postgres://postgres:password@localhost:%s?sslmode=disable" if err == nil { url = fmt.Sprintf("postgres://postgres:password@%s/boundary?sslmode=disable", resource.GetHostPort("5432/tcp"))