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

Compare bootstrap speed with Node.js #45

Closed
hefangshi opened this issue May 31, 2018 · 18 comments
Closed

Compare bootstrap speed with Node.js #45

hefangshi opened this issue May 31, 2018 · 18 comments

Comments

@hefangshi
Copy link

➜ tmp echo "console.log('Hello world')" > index.js
➜ tmp time deno index.js
Hello world
deno index.js 1.89s user 0.22s system 138% cpu 1.515 total
➜ tmp time node index.js
Hello world
node index.js 0.08s user 0.03s system 94% cpu 0.109 total

The golang runtime has a huge influence for bootstrap time. How you think about this, seems golang bootstrap time is had to improve.

@qti3e
Copy link
Contributor

qti3e commented May 31, 2018

it's not related to Golang but V8 and TS, as far as I know, Ryan is going to fix this issue by using V8 snapshots : )

@hefangshi
Copy link
Author

hefangshi commented May 31, 2018

I compiled a nodejs without snapshot

./configure --without-snapshot --prefix "$BASE_DIR/"

But the performance didn't drop a lot

time node index.js
Hello world

real	0m0.167s
user	0m0.123s
sys	0m0.042s

@ry
Copy link
Member

ry commented May 31, 2018

@hefangshi You've pointed out the issue that bothers me the most. But it's not Golang - it's the TypeScript compiler getting loaded, parsed, and then parsing the input. I believe snapshots will make this much faster ... work is in progress to fix it.

PS if you want to see the speed of Golang startup try time deno -help

@hefangshi
Copy link
Author

hefangshi commented May 31, 2018

@ry You are right. I do encounter with some issue of the golang startup performance in other extreme scenario, glad to know that deno don't have this issue.

Although snapshot for ts may reduce typescript load time, but compile time is still hard to improve, maybe deno could provide precomiled running mode for production enviroment in future.

@qti3e
Copy link
Contributor

qti3e commented May 31, 2018

@hefangshi Deno caches the compiled code (see ~/.deno/cache)

and about production mode you're probably addressing #21 : )

@yorkie
Copy link
Contributor

yorkie commented May 31, 2018

@qti3e #21 was good to go, however I have another proposal. Deno is absolutely based on TypeScript, such that we actually can compile the source code(TypeScript) into LLVM, and then we have 2 choices:

  • if we compile it to WebAssembly, v8 is required, and bootstrap and execution are optimized;
  • if we compile it to executable or loadable library, v8 is not required any more, and bootstrap, execution and RSS are optimized both;

@benjamingr
Copy link
Contributor

What about using something that removes the types when run in a production build https://github.com/alangpierce/sucrase?

@ry
Copy link
Member

ry commented Jun 1, 2018

@benjamingr I want only one transpiler compiled in and that is TS. I am confident that V8 snapshotting plus other startup optimizations will reduce startup time substantially. I will know soon and report back.

@SASUKE40
Copy link
Contributor

SASUKE40 commented Jun 5, 2018

Is it workable that rewrite TS compiler with golang?
IMHO, it is too heavy to optimize / translate TS on V8 engine. And if we do that, it maybe another Dart, and it makes deno more difficult for spreading in community.
Rewriting TS compiler with golang will optimize the performance in bootstrap period, it could be a easy way.

@kitsonk
Copy link
Contributor

kitsonk commented Jun 5, 2018

I highly doubt it is workable to rewrite TypeScript in Go. Because it wouldn't only be the language extensions on JavaScript, but a whole JavaScript engine, which is like rewriting the whole of V8 in another language. Even if it were cleanly separable, you would be ignoring the hundreds of people maintaining TypeScript and always be playing catchup. V8 snapshots are the easiest way to find out if they solve the challenge before exploring other solutions.

@tunnckoCore
Copy link

I think it's not the golang too, but the TS. I'm pretty curious how will optimize the TS part - it's impossible ;d But let's believe.

@ansarizafar
Copy link

Why not just AOT compile javascript/Typescript to a single native binary. Why use V8 runtime?

@kitsonk
Copy link
Contributor

kitsonk commented Jun 7, 2018

Why not just AOT compile javascript/Typescript to a single native binary. Why use V8 runtime?

You would have to have all code be knowable at run time, including the programme. At that point you are talking about static compilers for JavaScript like EncloseJS or nexe. Both those projects are not deno, both of those projects are already available if that is what you need.

@thysultan
Copy link

thysultan commented Jun 7, 2018

I think the best of both worlds would be as the goals for file extensions suggest to only run through a TypeScript compiler if it is a .ts extension. That is .js files should strictly be JavaScript and take the fast path.

Edit: Though i think if the core modules are written in '.ts' you would still have to compile that through TypeScript irregardless. So these sound like interesting design decision yet to be finalized depending on the tradeoffs.

@tunnckoCore
Copy link

@thysultan make sense, i thought about that too.

@qti3e
Copy link
Contributor

qti3e commented Jun 25, 2018

@ry maybe it should be closed by now (?)

@ry
Copy link
Member

ry commented Jun 25, 2018

Yep - snapshots are running now and start up is much better - but we aren’t yet on feature parity with the Go implementation so a bit hard to compare. Closing this and will publish some benchmarks soon

@ry ry closed this as completed Jun 25, 2018
@ry
Copy link
Member

ry commented Jan 15, 2019

Just FYI our benchmarks in this area have improved

> echo "console.log('Hello world')" > hello.js

> deno -v
deno: 0.2.7
v8: 7.2.502.16
typescript: 3.2.1

> time deno hello.js
Hello world

real	0m0.089s
user	0m0.043s
sys	0m0.033s

> node -v
v10.14.2

> time node hello.js
Hello world

real	0m0.680s
user	0m0.097s
sys	0m0.122s

piscisaureus pushed a commit to piscisaureus/deno that referenced this issue Oct 7, 2019
humancalico pushed a commit to humancalico/deno that referenced this issue Aug 24, 2020
hardfist pushed a commit to hardfist/deno that referenced this issue Aug 7, 2024
Now all `JsRealm` instances have a `ModuleMap`, but only the "main realm"
`ModuleMap` is being used.

Co-authored-by: Andreu Botella <andreu@andreubotella.com>
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

No branches or pull requests

10 participants