Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno v1.4.5 use 100% of CPU if it start an HTTP server #7909

Closed
jersou opened this issue Oct 9, 2020 · 3 comments · Fixed by #7911
Closed

deno v1.4.5 use 100% of CPU if it start an HTTP server #7909

jersou opened this issue Oct 9, 2020 · 3 comments · Fixed by #7911
Labels
bug Something isn't working correctly high priority

Comments

@jersou
Copy link
Contributor

jersou commented Oct 9, 2020

With deno 1.4.5, I have 100% CPU usage with all scripts that use an HTTP server, I don't have these problems with 1.4.4:

$ ./deno-1.4.4 --version                                                                                                                                       
      deno 1.4.4
      v8 8.7.75
      typescript 4.0.3
$ ./deno-1.4.5 --version
      deno 1.4.5
      v8 8.7.220.3
      typescript 4.0.3
$ ./deno-1.4.4  run --allow-net https://deno.land/[email protected]/examples/echo_server.ts & sleep 10 && ps -p "$(pgrep deno)" -o %cpu,%mem,cmd && pkill deno        
      [1] 43965
      Listening on 0.0.0.0:8080
      %CPU %MEM CMD
       0.0  0.0 ./deno-1.4.4 run --allow-net https://deno.land/[email protected]/examples/echo_server.ts
      [1]  + 43965 terminated  ./deno-1.4.4 run --allow-net                                                                                                                               
$ ./deno-1.4.5  run --allow-net https://deno.land/[email protected]/examples/echo_server.ts & sleep 10 && ps -p "$(pgrep deno)" -o %cpu,%mem,cmd && pkill deno
      [1] 44519
      Check https://deno.land/[email protected]/examples/echo_server.ts
      Listening on 0.0.0.0:8080
      %CPU %MEM CMD
      102  0.1 ./deno-1.4.5 run --allow-net https://deno.land/[email protected]/examples/echo_server.ts
      [1]  + 44519 terminated  ./deno-1.4.5 run --allow-net

cpu
My OS : Ubuntu 20.04.1 LTS

@jersou
Copy link
Contributor Author

jersou commented Oct 9, 2020

To be sure, I tried it from docker containers :

The Dockerfile :

# FROM https://github.com/hayd/deno-docker/blob/master/alpine.dockerfile
FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.31
RUN addgroup -g 1993 -S deno \
        && adduser -u 1993 -S deno -G deno \
        && mkdir /deno-dir/ \
        && chown deno:deno /deno-dir/
ENV DENO_DIR /deno-dir/
ENV DENO_INSTALL_ROOT /usr/local
ARG DENO_VERSION
RUN apk add --virtual .download --no-cache curl \
        && curl -fsSL https://github.com/denoland/deno/releases/download/v${DENO_VERSION}/deno-x86_64-unknown-linux-gnu.zip \
        --output deno.zip \
        && unzip deno.zip \
        && rm deno.zip \
        && chmod 777 deno \
        && mv deno /bin/deno \
        && apk del .download
CMD ["deno", "run", "--allow-net", "https://deno.land/[email protected]/examples/echo_server.ts"]

Build and run the 2 versions :

$ docker build -t deno-1.4.4 --build-arg DENO_VERSION=1.4.4 .
$ docker build -t deno-1.4.5 --build-arg DENO_VERSION=1.4.5 .
$ docker run -d --rm --init --name deno-1.4.4 deno-1.4.4 && docker run -d --rm --init --name deno-1.4.5 deno-1.4.5 && sleep 10 && docker stats --no-stream && docker kill deno-1.4.4 deno-1.4.5
33c6ab5a5c3abdea4427f337c7ffdce31e54817fef8956286986055fb30e9496
6bdbd15ef0fed716349dd6a316d02e76eac84087c063d805600c3bc1199f3d33
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
6bdbd15ef0fe        deno-1.4.5          99.28%              30.59MiB / 31.21GiB   0.10%               7.93kB / 1.33kB     0B / 0B             9
33c6ab5a5c3a        deno-1.4.4          0.00%               27.63MiB / 31.21GiB   0.09%               8.23kB / 1.33kB     0B / 0B             9
deno-1.4.4

screenshot-2020-10-10--00-22-56

$ uname -a 
Linux jer 5.4.0-48-generic #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

@jersou
Copy link
Contributor Author

jersou commented Oct 9, 2020

There is no relation to HTTP server finally, I have the same bug with catj example and others :

$ (sleep 10 && ps -p "$(pgrep deno)" -o %cpu,%mem,cmd && pkill deno) & ./deno-1.4.5 eval 'import { sleep } from "https://deno.land/x/sleep/mod.ts"; await sleep(100)'
%CPU %MEM CMD
 102  0.1 ./deno-1.4.5 eval import { sleep } from "https://deno.land/x/sleep/mod.ts"; await sleep(100)

$ (sleep 10 && ps -p "$(pgrep deno)" -o %cpu,%mem,cmd && pkill deno) & ./deno-1.4.5 run https://deno.land/[email protected]/examples/catj.ts -
%CPU %MEM CMD
 100  0.0 ./deno-1.4.5 run https://deno.land/[email protected]/examples/catj.ts -

$ (sleep 10 && ps -p "$(pgrep deno)" -o %cpu,%mem,cmd && pkill deno) & ./deno-1.4.5 eval 'new Promise(r => setTimeout(r, 100000))'
%CPU %MEM CMD
 0.1  0.0 ./deno-1.4.5 eval new Promise(r => setTimeout(r, 100000))

It's a strange bug, I guess deno doesn't have this behavior on all machines.
Edit: My Windows 7 VM have the same bug :
screenshot-2020-10-10--01-13-18

@ry
Copy link
Member

ry commented Oct 10, 2020

@jersou Thanks for the report - this is indeed a major oversight. I have a fix and we will make a new release tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants