Skip to content

Commit 82def17

Browse files
committed
test(Makefile): fix postgresql memory usage
Since setting work mem will raise the memory consumption of _all_ connections, let's keep it in range of what we're actually giving the container and how many total connections we allow.
1 parent cbe3004 commit 82def17

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,12 @@ 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 _always_ allocate this much:
869+
# - work_mem=8MB * max_connections=1000 = 8GB
870+
# - shared_buffers=2GB + effective_cache_size=1GB = 3GB
871+
# This leaves 5GB for the rest of the system _and_ storing the
872+
# database in memory (--tmpfs).
867873
docker run \
868874
--env POSTGRES_PASSWORD=postgres \
869875
--env POSTGRES_USER=postgres \
@@ -876,9 +882,9 @@ test-postgres-docker:
876882
--detach \
877883
--memory 16GB \
878884
gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} \
879-
-c shared_buffers=1GB \
880-
-c work_mem=1GB \
885+
-c shared_buffers=2GB \
881886
-c effective_cache_size=1GB \
887+
-c work_mem=8MB \
882888
-c max_connections=1000 \
883889
-c fsync=off \
884890
-c synchronous_commit=off \

0 commit comments

Comments
 (0)