-
Notifications
You must be signed in to change notification settings - Fork 311
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
Precompile files #2659
Precompile files #2659
Conversation
5b8a338
to
af4e151
Compare
87e6a8c
to
b627427
Compare
50bec1b
to
a27c3d3
Compare
c2bd983
to
3c1c48c
Compare
@alfonsogarciacaro Sorry for the late answer, didn't see your question. Yes, you can easily merge Here is what I may be entirely wrong, cause I have not measured it, but I'm not sure the code generation portion is the slow part, it's probably the type-checking that is slower. |
Thanks for the reply @ncave! You're right, I was having a look at this and realized my first assumption was wrong. The problem is actually I'm compiling twice: one for the normal F# - Fable compilation cycle and another to generate the .dll. Ideally we should have a way to tell |
I'm sure there is a way, after all that's what the F# compiler does next, generating IL code from the type-checked AST. |
3c1c48c
to
cd5861c
Compare
cd5861c
to
9bea5ca
Compare
@ncave I think I got it :) Seems to work, in my tests calling |
@alfonsogarciacaro This is great, looks very minimal, I like it. |
Would it help if you detach the type-checking from the IL code generation (expose the Optional but nice:
|
Thanks for the advice @ncave, I applied it and it looks better now :) After checking the project, I start the dll compilation as a child but it still seems it doesn't do much work until the other operations are finished. I think now it's just because the Fable compilation and the serialization of inline expressions just take up all the threads in the thread pool. If you can think of a better idea to start the work, please let me know :) |
Just to clarify what I mean by "stagger (or pub-sub) the type-checking and IL compiling in the client":
|
That's a great idea @ncave! Indeed, type checking cannot be parallelized, it uses a mapFold that takes the accumulated However, a changes as suggests will likely require many more changes in the FCS pipeline as it's basically implemented in a step-by-step sequential fashion. There are several points that expect the full list of Not sure if this can be changed to a pub-sub pattern, but if it's possible it should be beneficial for the F# compilation itself too. In any case, you made me think we could try to apply the pub-sub pattern to F#-Fable compilation. Ideally this would kick-off Fable compilation before type checking finishes so Fable can use the free CPU. BTW, I just remembered about the incoming support for reference assemblies in F#. Maybe we can try rebasing with this branch and see if it's faster to generate reference assemblies (these should be enough for fable precompilation). |
@alfonsogarciacaro +1 for Fable always pushing the boundaries of the (b)leading edge of the F# compiler.
But joking aside, I really hope |
b774f07
to
ab26b3e
Compare
I'm merging this because I cannot find more opportunities to improve performance at the moment. I will try the sub-pub pattern with F#-Fable compilation in a different PR. |
@ncave I'm trying to add a
precompile
command so users can precompile common files and packages that are changed less often and speed up the compilations. For this, I need to generate a .dll assembly, so it can be referenced later from the main project. I'm using theFSharpChecker.Compile
method from FCS and it works, only it takes a long time and I cannot reuse the typed AST already generated (there's an overload to use the untyped AST but for this I don't have access to it currently and not sure if it will improve times a lot as parsing is much faster than type checking).Do you know if it would be possible/easy to integrate the
exports
branch of your fork intoservice_slim
to generate empty assemblies (only with metadata)? And whether these empty assemblies can be generated faster than assemblies with code? If it doesn't look feasible/easy to do we can forget about it though because precompiling shouldn't be done often anyways :)