Skip to content

Deno is slow whenever it needs to compile #3111

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

Closed
CGQAQ opened this issue Oct 12, 2019 · 1 comment · Fixed by #3644
Closed

Deno is slow whenever it needs to compile #3111

CGQAQ opened this issue Oct 12, 2019 · 1 comment · Fixed by #3644

Comments

@CGQAQ
Copy link
Contributor

CGQAQ commented Oct 12, 2019

➜  try deno version
deno: 0.20.0
v8: 7.9.218
typescript: 3.6.3
USAGE:
    deno [OPTIONS] [SUBCOMMAND]

OPTIONS:
    -A, --allow-all                    Allow all permissions
        --allow-env                    Allow environment access
        --allow-hrtime                 Allow high resolution time measurement
        --allow-net=<allow-net>        Allow network access
        --allow-read=<allow-read>      Allow file system read access
        --allow-run                    Allow running subprocesses
        --allow-write=<allow-write>    Allow file system write access
    -c, --config <FILE>                Load compiler configuration file
        --current-thread               Use tokio::runtime::current_thread
    -h, --help                         Prints help information
        --importmap <FILE>             Load import map file
    -L, --log-level <log-level>        Set log level [possible values: debug, info]
        --no-fetch                     Do not download remote modules
        --no-prompt                    Do not use prompts
    -r, --reload                       Reload source code cache (recompile TypeScript)
        --seed <NUMBER>                Seed Math.random()
        --v8-flags=<v8-flags>          Set V8 command line options
        --v8-options                   Print V8 command line options
    -v, --version                      Print the version

SUBCOMMANDS:
    [SCRIPT]       Script to run
    bundle         Bundle module and dependencies into single file
    completions    Generate shell completions
    eval           Eval script
    fetch          Fetch the dependencies
    fmt            Format files
    help           Prints this message or the help of the given subcommand(s)
    info           Show info about cache or info related to source file
    install        Install script as executable
    run            Run a program given a filename or url to the source code
    test           Run tests
    types          Print runtime TypeScript declarations
    version        Print the version
    xeval          Eval a script on text segments from stdin

ENVIRONMENT VARIABLES:
    DENO_DIR        Set deno's base directory
    NO_COLOR        Set to disable color
    HTTP_PROXY      Set proxy address for HTTP requests (module downloads, fetch)
    HTTPS_PROXY     Set proxy address for HTTPS requests (module downloads, fetch)

first_try.ts

console.log("hello world.")
#include <stdio.h>

int main(int argc, char** argv) {
    printf("hello world!");
}
➜  try time deno first_try.ts
Compile file:///home/jason/code/deno/try/first_try.ts
hello world
deno first_try.ts  3.08s user 0.19s system 138% cpu 2.353 total
➜  try time deno first_try.ts 
Compile file:///home/jason/code/deno/try/first_try.ts
hello world. 
deno first_try.ts  3.02s user 0.16s system 141% cpu 2.248 total
➜  try time deno first_try.ts 
Compile file:///home/jason/code/deno/try/first_try.ts
hello world. dd
deno first_try.ts  3.13s user 0.19s system 141% cpu 2.349 total
➜  try time clang main.c 
clang main.c  0.18s user 0.13s system 12% cpu 2.490 total
➜  try time gcc main.c 
gcc main.c  0.11s user 0.06s system 14% cpu 1.184 total
➜  try time clang main.c     
clang main.c  0.22s user 0.06s system 92% cpu 0.300 total
➜  try time gcc main.c 
gcc main.c  0.08s user 0.04s system 96% cpu 0.119 total

Deno is slow whenever it needs to compile, and even I change a single bit of the code, the ts compile is completely cold start for compiling, I was wondering something like tsc -w watch mode, but deno seems don't have it, and also the cpu usage is too heavily.
If every change of code need to cold start tsc to compile, what is the advantage of deno when it comes to script vs (c and other compiling language). 2 and half second is just too slow, just lost the advantage of V8(blazing fast jit and other optimize)

@kitsonk
Copy link
Contributor

kitsonk commented Oct 12, 2019

Yeah, we know. It is tracked in our benchmarks (https://deno.land/benchmarks.html#exec-time).

The watch type functionality is non-trivial, it is dependent on #1826 but even that doesn't solve the problems of incremental compile, but something we want to look at in the longer term. Improving the overall performance of when we have to spin up the compiler is something that would be better overall. @ry and I have talked about several approaches offline to it, as well as I talked with the TypeScript team today on some approaches.

We don't have an explicit issue for this, so it feels like we should keep this one open as a reminder.

Related: #2789

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants