Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f46e3b

Browse files
authored
test(Makefile): fix postgresql memory usage (#16170)
1 parent eda8190 commit 7f46e3b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Makefile

+13-2
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,17 @@ test-migrations: test-postgres-docker
864864
# NOTE: we set --memory to the same size as a GitHub runner.
865865
test-postgres-docker:
866866
docker rm -f test-postgres-docker-${POSTGRES_VERSION} || true
867+
# Make sure to not overallocate work_mem and max_connections as each
868+
# connection will be allowed to use this much memory. Try adjusting
869+
# shared_buffers instead, if needed.
870+
#
871+
# - work_mem=8MB * max_connections=1000 = 8GB
872+
# - shared_buffers=2GB + effective_cache_size=1GB = 3GB
873+
#
874+
# This leaves 5GB for the rest of the system _and_ storing the
875+
# database in memory (--tmpfs).
876+
#
877+
# https://www.postgresql.org/docs/current/runtime-config-resource.html#GUC-WORK-MEM
867878
docker run \
868879
--env POSTGRES_PASSWORD=postgres \
869880
--env POSTGRES_USER=postgres \
@@ -876,9 +887,9 @@ test-postgres-docker:
876887
--detach \
877888
--memory 16GB \
878889
gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} \
879-
-c shared_buffers=1GB \
880-
-c work_mem=1GB \
890+
-c shared_buffers=2GB \
881891
-c effective_cache_size=1GB \
892+
-c work_mem=8MB \
882893
-c max_connections=1000 \
883894
-c fsync=off \
884895
-c synchronous_commit=off \

0 commit comments

Comments
 (0)