Skip to content

Commit

Permalink
Allow for profiling startup in dockerized setting (#9865)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hubertp authored May 6, 2024
1 parent c0fd6ee commit f2779cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions tools/ci/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -60,4 +64,5 @@ ENV JAVA_OPTS=${JAVA_OPTS}
EXPOSE ${RPC_PORT}
EXPOSE ${DATA_PORT}


CMD ["--server", "--daemon", "--path", "/volumes/workspace/project_root"]
7 changes: 6 additions & 1 deletion tools/ci/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" "$@"

0 comments on commit f2779cf

Please sign in to comment.