Browse Source

Ensure sysctl fs.nr_open is set high enough in start-docker

Ian Goldberg 9 months ago
parent
commit
f5414b0235
1 changed files with 15 additions and 1 deletions
  1. 15 1
      docker/start-docker

+ 15 - 1
docker/start-docker

@@ -1,9 +1,23 @@
 #!/bin/bash
 #!/bin/bash
 
 
+# Get the maximum allowable number of open files per process on the host
+nr_open=`sysctl fs.nr_open | cut -d' ' -f3`
+
+# Ensure it's large enough; for 2^20 clients, the client simulator
+# process will need two file descriptors per client (one socket to
+# its ingestion server and one to its storage server), plus a handful
+# that don't depend on the number of clients (logfiles, etc.)
+needed_nr_open=$(((1<<21) + 10))
+
+if [ $nr_open -lt $needed_nr_open ]; then
+    echo "sysctl fs.nr_open is too low: currently $nr_open; needed $needed_nr_open" >&2
+    exit 1
+fi
+
 # The SYS_NICE capability allows you to use numactl to pin processes to
 # The SYS_NICE capability allows you to use numactl to pin processes to
 # NUMA nodes and/or individual cores
 # NUMA nodes and/or individual cores
 
 
 docker run -d --cap-add SYS_NICE --rm --device /dev/sgx_enclave \
 docker run -d --cap-add SYS_NICE --rm --device /dev/sgx_enclave \
     --device /dev/sgx_provision --name ${TEEMS_DOCKER_PREFIX}teems \
     --device /dev/sgx_provision --name ${TEEMS_DOCKER_PREFIX}teems \
-    --ulimit nofile=10485760:10485760 \
+    --ulimit nofile=${needed_nr_open}:${needed_nr_open} \
     -h ${TEEMS_DOCKER_PREFIX}teems -t ${TEEMS_DOCKER_PREFIX}teems bash
     -h ${TEEMS_DOCKER_PREFIX}teems -t ${TEEMS_DOCKER_PREFIX}teems bash