You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _blogposts/2020-09-25-release-8-3-2.mdx
+24-21Lines changed: 24 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,22 +40,23 @@ Note such vertical integration not only brings better performance, smaller sizes
40
40
41
41
## Build system enhancements for editor diagnostics
42
42
43
-
When people are coding in their favorite editors, they expect the editor to deliver the feedback loop in real-time, for example,
43
+
When people are coding in their favorite editors, they expect to see syntax and type errors in real-time.
44
+
There are multiple ways to achieve this. The most and reliable way is to always invoke the build system whenever the user saves a file. Due to not having an in-memory cache, our build system is very reliable. However we didn't yet optimize the build system for live feedback in editors.
44
45
what syntax errors, type checking errors do they have when editing? There are multiple ways to achieve this, the most easy
45
46
and reliable way is to always invoke the build system whenever the user saves the files, since it's the same build system
46
47
without any in-memory cache, the reliability is very high, however, there's several challenges to use the build system output as editor diagnostics.
47
48
48
-
### The build system/compiler has to be fast to deliver feedback loop in one hundred milliseconds for typical projects
49
+
### The build system/compiler has to be fast to deliver real-time feedback
49
50
50
-
Our build system is fast enough to deliver feedback loop for reasonable sizes of projects,
51
+
Our build system is fast enough to deliver feedback for reasonable sized projects in less than 100ms.
51
52
thanks to our previous [hard work](/blog/scalable). We continue improving
52
-
the build performance during each release, we believe such approach is reliable using our build tools.
53
+
Pushing the limits of performance in the build system allows us to provide real-time feedback in editors.
53
54
54
55
### The warnings for each file should not be flushed during a rebuild
55
56
56
57
For a typical file based build system, if the file A is compiled successfully with some warnings, the rebuild will not build A anymore.
57
-
This is problematic if we use the build system output as editor diagnostics. Since the second build will not capture those warnings, we
58
-
could use some caching mechanism to cache previous build output, but it will render such system stateful and not reliable.
58
+
This is problematic if we use the build system output for editor diagnostics. Since the second build will not capture those warnings, we
59
+
could use some caching mechanism to cache previous build output. But… stateful systems are not reliable and come with a whole range of different problems.
59
60
60
61
To solve such challenging problem, we did some innovations to co-ordinate the compiler and build system. When the file A is compiled with warnings,
61
62
the compiler will produce some marks to the build system, the build system will keep building but such marks are encoded in the build rules
@@ -66,42 +67,44 @@ The benefit is two fold:
66
67
- Rebuild will re-capture those warnings
67
68
- Rebuild will be fast since only those files with warnings get rebuilt, it will not trigger unnecessary builds since our build is [content-based](https://rescript-lang.org/blog/scalable) build system.
68
69
69
-
The integration between compiler and build system is encoded in a specialized protocol so that this new feature's almost cost-free.
70
+
The integration between compiler and build system is encoded in a specialized protocol. This makes it almost cost-free.
70
71
71
-
### A tiny client notification via .comipler.log
72
+
### Notifying clients through .compiler.log
72
73
73
-
To get the build output, instead of communicating with IPC, we adopted a simple protocol, whenever a build is done, we wrote the output to a file called `.compiler.log`.
74
+
To get the build output, instead of communicating through IPC, we adopted a simple protocol. Whenever a build is done, we write the output to a file called `.compiler.log`.
74
75
This makes the editor integration build-system agnostic, it does not need talk to the build system directly.
75
76
76
-
It also makes our build tool can work with other watchers including Facebook's [watchman](https://facebook.github.io/watchman/).
77
-
Watchman is a more scalable watcher tool for specific platform and less memory hungry, however, we still need a watchman-client to get the output of triggerred job.
78
-
Now since we write the output to `.compiler.log` per each build, such client is available for free.
77
+
It also makes our build tool work with other watchers including Facebook's [watchman](https://facebook.github.io/watchman/).
78
+
Watchman is a more scalable watcher tool for specific platform and less memory hungry, however, we still need a watchman-client to get the output of triggered job.
79
+
We write the output to `.compiler.log` per each build, allowing clients to read compiler diagnostics when they want.
79
80
80
81
## A better algorithm for removing stale outputs
81
82
82
-
Whenever we do some renaming from`a.res` to `b.res`, the output caused by `a.res`will be stale output. Thanks to the deeper integration of the build system and compiler,
83
-
we employ a more advanced strategy to remove stale outputs in this release, such pruning stale outputs is done in the beginning of each build.
83
+
Whenever we rename a file, e.g.`a.res` to `b.res`, will lead to the output of `a.res`being stale. Thanks to the deeper integration of the build system and compiler,
84
+
we employ a more advanced strategy to remove stale outputs in this release. Pruning stale outputs is done in the beginning of each build.
84
85
85
-
There're two ways of removing staled artifacts, the second one is introduced in this release:
86
+
There are two ways of removing staled artifacts, the second one is introduced in this release:
86
87
87
-
- Based on live analysis and prebuilt-in knowledge
88
+
- Based on live analysis and prebuilt-in knowledge
88
89
89
90
We scan `lib/bs` directory and check some dangling cm{i,t,j,ti} files, if it does not exist in
90
91
the current build set, it is considered stale artifacts. If it is `cmt` file, it would trigger some hooks of `genType`, notably -cmt-rm.
91
92
92
93
- Based on previous build logs
93
-
We stored previous compilation stats, so that for a file, if it is previous output, but no longer a output of the new build,
94
+
We store previous compilation stats. If a file is in the previous compiler output, but no longer in the output of the new build, it is considered stale and can be removed.
94
95
it is considered stale output which can be removed.
95
96
96
-
In general, the new introduced strategy 2 is more reliable and efficient.
97
+
In general, strategy two is more reliable and efficient.
97
98
98
-
- We don't need redo the path calculate since it's already done by the build system.
99
+
- We don't need to recompute the path since it is already done by the build system.
99
100
- When we change the in-source build to out-source build, it will still do the pruning properly
100
101
101
-
however, the former could be more customized for other buid system not aware systems including `genType`,
102
+
However, strategy one is easier for tooling like `genType`. Not every tool has knowledge of the build system.
102
103
we employ a combination of the two strategies.
103
104
104
-
When removing js outputs, we use strategy two, when removing .cm* files, we use the first strategy.
105
+
Sometimes a combination of both strategies is needed.
106
+
- When removing .cm* files, we use the first strategy.
107
+
- When removing generated javascript, we use strategy two,
0 commit comments