From f2779cfea4af87b82e4c8b50bd76e88741cfcbd2 Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Mon, 6 May 2024 17:04:54 +0200 Subject: [PATCH] Allow for profiling startup in dockerized setting (#9865) When `PROFILING_FILENAME` and `PROFILING_TIME` are set, language server will collect profiling data on startup and place it under `/opt/enso/profiling/$PROFILING_NAME` where it can be fetched from. Needed to better analyze #9789. --- .../languageserver/ExecutorWithUnlimitedPool.scala | 5 +++-- tools/ci/docker/Dockerfile | 5 +++++ tools/ci/docker/docker-entrypoint.sh | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/infrastructure/languageserver/ExecutorWithUnlimitedPool.scala b/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/infrastructure/languageserver/ExecutorWithUnlimitedPool.scala index 0ac406ff43..790b3c0215 100644 --- a/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/infrastructure/languageserver/ExecutorWithUnlimitedPool.scala +++ b/lib/scala/project-manager/src/main/scala/org/enso/projectmanager/infrastructure/languageserver/ExecutorWithUnlimitedPool.scala @@ -5,6 +5,7 @@ import com.typesafe.scalalogging.Logger import org.apache.commons.lang3.concurrent.BasicThreadFactory import org.enso.logger.masking.Masking import org.enso.logging.LoggingServiceManager +import org.enso.projectmanager.boot.Cli.{PROFILING_PATH, PROFILING_TIME} import org.enso.projectmanager.service.versionmanagement.RuntimeVersionManagerFactory import org.enso.runtimeversionmanager.config.GlobalRunnerConfigurationManager import org.enso.runtimeversionmanager.runner.{LanguageServerOptions, Runner} @@ -103,10 +104,10 @@ object ExecutorWithUnlimitedPool extends LanguageServerExecutor { ) val profilingPathArguments = descriptor.profilingPath.toSeq - .flatMap(path => Seq("--profiling-path", path.toString)) + .flatMap(path => Seq(s"--$PROFILING_PATH", path.toString)) val profilingTimeArguments = descriptor.profilingTime.toSeq - .flatMap(time => Seq("--profiling-time", time.toSeconds.toString)) + .flatMap(time => Seq(s"--$PROFILING_TIME", time.toSeconds.toString)) val startupArgs = if (descriptor.skipGraalVMUpdater) Seq("--skip-graalvm-updater") else Seq() diff --git a/tools/ci/docker/Dockerfile b/tools/ci/docker/Dockerfile index b1b2f2dd37..b3a7684923 100755 --- a/tools/ci/docker/Dockerfile +++ b/tools/ci/docker/Dockerfile @@ -7,6 +7,8 @@ ARG RPC_PORT=30001 ARG DATA_PORT=30002 ARG PRINT_VERSION=0 ARG JAVA_OPTS="-XX:MaxRAMPercentage=90.0 -XX:InitialRAMPercentage=90.0" +ARG PROFILING_FILENAME +ARG PROFILING_TIME RUN useradd -u 2000 -c 'Enso Developer' -U -m ensodev @@ -27,6 +29,7 @@ ADD editions /opt/enso/editions RUN mkdir /opt/enso/work RUN mkdir /opt/enso/logs +RUN mkdir /opt/enso/profiling ENV ENSO_DATA_DIRECTORY=/volumes/workspace/data_root ENV ENSO_CONFIG_DIRECTORY=/volumes/workspace/config @@ -39,6 +42,7 @@ RUN chmod -R u=rX,g=rX /opt/enso RUN chmod a+x /opt/enso/bin/* RUN chmod a+rw /opt/enso/work RUN chmod a+rw /opt/enso/logs +RUN chmod a+rw /opt/enso/profiling RUN mkdir -p /volumes RUN chown -hR ensodev:ensodev /volumes @@ -60,4 +64,5 @@ ENV JAVA_OPTS=${JAVA_OPTS} EXPOSE ${RPC_PORT} EXPOSE ${DATA_PORT} + CMD ["--server", "--daemon", "--path", "/volumes/workspace/project_root"] diff --git a/tools/ci/docker/docker-entrypoint.sh b/tools/ci/docker/docker-entrypoint.sh index 1214246382..0800f6244f 100755 --- a/tools/ci/docker/docker-entrypoint.sh +++ b/tools/ci/docker/docker-entrypoint.sh @@ -13,4 +13,9 @@ if [ "$INTERFACE" == "" ]; then INTERFACE="0.0.0.0" fi -/opt/enso/bin/enso --log-level "$LOG_LEVEL" --rpc-port $RPC_PORT --data-port $DATA_PORT --root-id "$LS_ROOT_ID" --interface "$INTERFACE" "$@" +PROFILING_OPTIONS="" +if [ "$PROFILING_FILENAME" != "" ] && [ "$PROFILING_TIME" != "" ]; then + PROFILING_OPTIONS="--profiling-path /opt/enso/profiling/$PROFILING_FILENAME --profiling-time=$PROFILING_TIME" +fi + +/opt/enso/bin/enso $PROFILING_OPTIONS --log-level "$LOG_LEVEL" --rpc-port $RPC_PORT --data-port $DATA_PORT --root-id "$LS_ROOT_ID" --interface "$INTERFACE" "$@"