oracle / graalpython

A Python 3 implementation built on GraalVM
Other
1.2k stars 103 forks source link

docker container run slower than machine local #326

Closed rayduan closed 1 year ago

rayduan commented 1 year ago

hi,when i use java invoker python script with graalpython , i create 1000 task with 400 thread . when i use machine local it cost only 9003 ms, but when i build image and run with docker container ,it cost reach up to 35520 ms , image image

this is my dockerfile

FROM ghcr.io/graalvm/graalvm-ce:ol8-java11-22.3.1
RUN  gu install python
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
VOLUME /tmp
ARG JAR_FILE=target/script-agent*.jar
COPY ${JAR_FILE} app.jar
COPY run.sh .
RUN chmod 777 run.sh
RUN chmod 777 app.jar
RUN ls -l
RUN pwd
ENV JAVA_OPTS="-server -Xms512m -Xmx512m --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED"
ENTRYPOINT ["./run.sh"]
#!/bin/sh
java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /app/app.jar

is any way to improve my performance

msimacek commented 1 year ago

If you're running docker on your M1 laptop, check that you're getting the arm64 image and not amd64. You can try to run the docker build and run commands with --platform linux/arm64.

rayduan commented 1 year ago

If you're running docker on your M1 laptop, check that you're getting the arm64 image and not amd64. You can try to run the docker build and run commands with --platform linux/arm64.

when i set option python.ForceImportSite true, it cost more, how can make it cost shorter

msimacek commented 1 year ago

I don't know any direct way. Have you tried reusing the context in a thread local? The site import happens only during context initialization, so then it would only happen once per thread.

rayduan commented 1 year ago

I don't know any direct way. Have you tried reusing the context in a thread local? The site import happens only during context initialization, so then it would only happen once per thread.

i any way to reusing the context when i bindings is not sure? so when i used the context i need to restore the bindings .and what can i do to slove it?

msimacek commented 1 year ago

What do you mean by "restore the bindings"? If you mean resetting them, you can delete the values with removeMember.