-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
[WIP] Use compiler services instead of language services #693
Conversation
For information:
So there is a serious slowdown using this method... I need to investigate what is going on here, and if there is pre-warming that can be done to the compiler. I believe the way the language services works, when we create the instance of it in the compiler during construction, causes a lot of pre-warming of TypeScript, which is now missing, because we don't really hit TypeScript until invocation. What might work, which I was thinking about overnight, is that we just use the |
@kitsonk I was experiencing the same thing with |
@qti3e yeah, thanks for the feedback... so what I will think I will do is make the |
It's odd to me that it'd be so much slower. What's createProgram doing that languageService isn't? One idea is to use the V8 profiler to figure this out: https://github.com/v8/v8/wiki/V8-Profiler |
@ry any bright ideas about how to do that, asking for a friend... I can play with |
Ok, I re-created enough of the compiler on Node.js to be able to profile the two different approaches. It is very confusing to say the least. It seems the Concerns around the compiler performance are covered in microsoft/TypeScript#25658 which is also another option in that in transpiling we could There is a "risk" that someone could be conflicting with a symbol in the deno global environment with Here are some interesting bits: |
@kitsonk You should be able to use --prof and other V8 flags in deno currently. |
Hmmm... the |
Ok, I got profiling working directly in Given:
This branch, summary:
And then the current master summary:
The bottom up, which shows the two are quite different beasts, first this branch:
And current master:
|
@kitsonk Nice work! 2601 ticks maybe isn't enough to really say what's happening - is there a way we can test a similar work load in a loop? Hm would be nice if there was some easy way of source mapping those filenames too...
seem to be inside the typescript compiler - does LazyCompile suggest V8 warm up would improve this? Maybe @piscisaureus knows more? |
I tried warming up more of TypeScript by doing a The bottom up looks quite a bit more like the master branch, but time wise, it is a crazy difference in duration, it is still looks like this:
Anyways, I am going to push my branch. But I think the best bet at the moment is to work on keeping |
77ddd59
to
6976de7
Compare
Closing this one as createProgram is too slow. I think this will be useful code in the future when we address bundling. Thanks for investigating @kitsonk ! |
Required for denoland#23305 Allowing cloning `Rc<ContextState>` into new contexts. During cleanup we assert that main context does not have more than one strong count to `JsRuntimeState` but this may not be true when there are more than one contexts that may not have been GC'ed yet. Hence, JsRuntimeState is now stored as a pointer to OpCtx as it is guarnateed to live longer than ops.
This is a work in progress to investigate using
ts.createProgram()
instead of using the language services to transpile each dependency.ts.createProgram()
works much more like the waytsc
out of the box works, making it easier to generate an AMD bundle of modules in the future. The language services are more designed to be leveraged in an editor, where incremental changes are transpiled as the file is edited.At the moment, it is purely additional APIs with
compileProgram()
andrunProgram()
replacingcompile()
andrun()
in the compiler. A few of the compiler unit tests are broken now, so they are commented out, but the rest of the test mostly work (except some of the errors functional cases because of the changes in the error stacks).Currently, the process is like this:
With this PR, it is like this: