From 9c5c17a3ee30429b99ef5328247dfd3c5bbc2fc2 Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Thu, 18 Jan 2024 18:10:09 +0000 Subject: [PATCH 1/3] 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")) From e25528499626b3d905f3687ecae037772e7c7a68 Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Thu, 18 Jan 2024 18:49:51 +0000 Subject: [PATCH 2/3] feat(test): Disable JIT for test database image --- testing/dbtest/docker/postgresql.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/dbtest/docker/postgresql.conf b/testing/dbtest/docker/postgresql.conf index 675082eee4..de69cfaa56 100644 --- a/testing/dbtest/docker/postgresql.conf +++ b/testing/dbtest/docker/postgresql.conf @@ -34,3 +34,4 @@ lc_monetary = 'en_US.utf8' lc_numeric = 'en_US.utf8' lc_time = 'en_US.utf8' default_text_search_config = 'pg_catalog.english' +jit = off # Disable JIT since it seems to just cause overhead and no gain From 1e51dbef4f3e87127696ec77f1532098c0ce2e70 Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Thu, 18 Jan 2024 18:50:07 +0000 Subject: [PATCH 3/3] feat(test): Add docker images for additional postgres versions --- testing/dbtest/docker/Dockerfile.14-alpine | 7 +++++++ testing/dbtest/docker/Dockerfile.15-alpine | 7 +++++++ testing/dbtest/docker/Dockerfile.16-alpine | 7 +++++++ 3 files changed, 21 insertions(+) create mode 100644 testing/dbtest/docker/Dockerfile.14-alpine create mode 100644 testing/dbtest/docker/Dockerfile.15-alpine create mode 100644 testing/dbtest/docker/Dockerfile.16-alpine diff --git a/testing/dbtest/docker/Dockerfile.14-alpine b/testing/dbtest/docker/Dockerfile.14-alpine new file mode 100644 index 0000000000..0bb26dc98d --- /dev/null +++ b/testing/dbtest/docker/Dockerfile.14-alpine @@ -0,0 +1,7 @@ +FROM postgres:14-alpine + +ADD init-db.sh /docker-entrypoint-initdb.d/00-init-db.sh +ADD restore-benchmark-dumps.sh /docker-entrypoint-initdb.d/01-restore-benchmark-dumps.sh +ADD postgresql.conf /etc/postgresql/postgresql.conf + +CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"] diff --git a/testing/dbtest/docker/Dockerfile.15-alpine b/testing/dbtest/docker/Dockerfile.15-alpine new file mode 100644 index 0000000000..45c1d676c4 --- /dev/null +++ b/testing/dbtest/docker/Dockerfile.15-alpine @@ -0,0 +1,7 @@ +FROM postgres:15-alpine + +ADD init-db.sh /docker-entrypoint-initdb.d/00-init-db.sh +ADD restore-benchmark-dumps.sh /docker-entrypoint-initdb.d/01-restore-benchmark-dumps.sh +ADD postgresql.conf /etc/postgresql/postgresql.conf + +CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"] diff --git a/testing/dbtest/docker/Dockerfile.16-alpine b/testing/dbtest/docker/Dockerfile.16-alpine new file mode 100644 index 0000000000..3a346045c0 --- /dev/null +++ b/testing/dbtest/docker/Dockerfile.16-alpine @@ -0,0 +1,7 @@ +FROM postgres:16-alpine + +ADD init-db.sh /docker-entrypoint-initdb.d/00-init-db.sh +ADD restore-benchmark-dumps.sh /docker-entrypoint-initdb.d/01-restore-benchmark-dumps.sh +ADD postgresql.conf /etc/postgresql/postgresql.conf + +CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]