Skip to content

Commit 16ace03

Browse files
Apply suggestions from code review
Co-authored-by: Iwan <[email protected]>
1 parent 8428a2d commit 16ace03

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

_blogposts/2020-09-25-release-8-3-2.mdx

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,23 @@ Note such vertical integration not only brings better performance, smaller sizes
4040

4141
## Build system enhancements for editor diagnostics
4242

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.
4445
what syntax errors, type checking errors do they have when editing? There are multiple ways to achieve this, the most easy
4546
and reliable way is to always invoke the build system whenever the user saves the files, since it's the same build system
4647
without any in-memory cache, the reliability is very high, however, there's several challenges to use the build system output as editor diagnostics.
4748

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
4950

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.
5152
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.
5354

5455
### The warnings for each file should not be flushed during a rebuild
5556

5657
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.
5960

6061
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,
6162
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:
6667
- Rebuild will re-capture those warnings
6768
- 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.
6869

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.
7071

71-
### A tiny client notification via .comipler.log
72+
### Notifying clients through .compiler.log
7273

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`.
7475
This makes the editor integration build-system agnostic, it does not need talk to the build system directly.
7576

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.
7980

8081
## A better algorithm for removing stale outputs
8182

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.
8485

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:
8687

87-
- Based on live analysis and prebuilt-in knowledge
88+
- Based on live analysis and prebuilt-in knowledge
8889

8990
We scan `lib/bs` directory and check some dangling cm{i,t,j,ti} files, if it does not exist in
9091
the current build set, it is considered stale artifacts. If it is `cmt` file, it would trigger some hooks of `genType`, notably -cmt-rm.
9192

9293
- 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.
9495
it is considered stale output which can be removed.
9596

96-
In general, the new introduced strategy 2 is more reliable and efficient.
97+
In general, strategy two is more reliable and efficient.
9798

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.
99100
- When we change the in-source build to out-source build, it will still do the pruning properly
100101

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.
102103
we employ a combination of the two strategies.
103104

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,
105108

106109

107110

0 commit comments

Comments
 (0)