Replies: 9 comments 12 replies
-
@kerams, would you mind paying a look at the recent comments I made in the broader/fuzzy discussion for incremental recompile (#8044)? What I touch on my comments in #8044 is targeted at identifying if a file and a diff of signatures before it should engender a recompile of the file. The same approach could be taken earlier, it could be on diff of AST that we could already identify opportunities to skip recompile of a file, or more likely, proceed in checking the next stage. Why is it related to incremental recompilation? Because incremental recompilation will require serialisation and heuristics on the serialized graphs, and making things like a graph and serialised, means they can conceptually be parallelised for read only usage 🙂 (I know I'm stretching everything a little bit). Now, regarding your more precise issue, I have few things coming to mind: Are you familiar with the If That would be the beginning of a
It means invalidation of the serialised One big pitfall, at least, nest of edge cases, is shadowing and aliasing features of the language, and also stuff like It sounds like "after assembly reference resolution" maybe the next stage if bare AST can't help much in sorting out what you are pointing at. edit:
Don't worry, you are covered at least 10x by all mine :) |
Beta Was this translation helpful? Give feedback.
-
We have a PR that could enable this: #11152 The restriction is that it will only parallelize type checking impl files that have a backing signature file. Our hope in the future is that we will add better tooling to create these signature files automatically through a gesture in an editor. Trying to parallelize type checking for impl files without sig files is a much more difficult undertaking. Sure, you could add heuristics like you suggested, but we would have to have a dependency graph of types and functions; which may be more expensive in of itself. |
Beta Was this translation helpful? Give feedback.
-
Yes, I'm specifically talking about no sig scenarios.
Yes, that would be expensive. I was thinking keeping track of namespaces and modules alone could theoretically suffice. For instance, if we collect those for file @smoothdeveloper, I'm afraid I don't know enough about those topics, or whether your approach, if viable, would supersede mine (perhaps they could even complement each other). My evening thoughts were very narrowly concerned about full compilation performance. |
Beta Was this translation helpful? Give feedback.
-
Here's a really silly idea. If I extract all namespaces and top level modules (a very shallow AST traversal would be enough) from file I'll answer myself. The aforementioned auto opens would cause a problem, but that can be easily checked separately. Partially qualified opens are worse though. |
Beta Was this translation helpful? Give feedback.
-
It seems to me like a great bang for buck first pass at splitting out stuff just at the AST level, like having both a genius and captain obvious being one and single person bringing this :D I'm curious what roadblocks would be hit by this heuristics to turn faulty in the wild. @vasily-kirichenko, any opinion? |
Beta Was this translation helpful? Give feedback.
-
Will move this to a discussion |
Beta Was this translation helpful? Give feedback.
-
To me this also seems to have a massive potential for speedup. I raised a similar 'idea' recently: #13733 .
I do think there are plenty of heuristics, either text-based or AST-based, that would be both quick and give a decent rate of true negatives. A simple thing that the user can do to help with performance would be putting individual files in separate modules/namespaces (so that . Another thing is that this wouldn't have to be limited to type-checking and could apply to next phases of code analysis/compilation. I don't have a good picture of how the compilation is structured, but in principle things like optimisation, constraint solving etc. could be parallelisable if two files in question don't depend on each other at all. @smoothdeveloper @kerams I think we should discuss some ideas further. |
Beta Was this translation helpful? Give feedback.
-
Hello, I'd like to pitch a related idea here. Sample layout:
Every The compiler could type-check these files in parallel if you know this (because the user specified it). It is very hard coded, and I don't really know yet how to expose this feature-wise.
There is no clever heuristic here, but I believe the use case is common enough to explore this. I believe the same magic number trick could be used for Any initial thoughts on this @dsyme and @vzarytovskii? //cc @safesparrow |
Beta Was this translation helpful? Give feedback.
-
FYI @kerams I mentioned some work I'm doing on implementing a parallelisation mechanism like this, based on AST information, in #14104 |
Beta Was this translation helpful? Give feedback.
-
The recent awesome work on parallel parsing and IL gen got me thinking whether it would be feasible to parallelize type checking as well.
Given F#'s significant file order, if the compiler can quickly establish that file
B
can't possibly reference anything in fileA
declared directly above it, can'tA
andB
be typechecked (and optimized) simultaneously? This would require an initial traversal of the AST in every file in order to create a file dependency graph. Specifically, things like this need to be checked:B
opens a module or class defined inA
,B
depends onA
A
contains anAutoOpen
that has immediate effect inB
(because of overlapping namespaces, regardless of actual contents),B
depends onA
B
references something fromA
using a qualified name,B
depends onA
I think these can be gleaned from the untyped syntax tree alone, the question is whether it would be fast enough to offset the overhead and whether typechecking has a significant cost. Apologies in advance if there's a gaping flaw in here somewhere :).
Beta Was this translation helpful? Give feedback.
All reactions