|
1 |
| -Compiler supports configuring how to watch files and directories using the environment variables. |
| 1 | +μ»΄νμΌλ¬λ νκ²½ λ³μλ₯Ό μ¬μ©νμ¬ νμΌκ³Ό λλ ν°λ¦¬λ₯Ό κ°μνλ λ°©λ² κ΅¬μ±μ μ§μν©λλ€. |
2 | 2 |
|
3 |
| -## Configuring file watching using environment variable `TSC_WATCHFILE` |
| 3 | +## νκ²½ λ³μ `TSC_WATCHFILE`μ μ¬μ©νμ¬ νμΌ κ°μ μ€μ (Configuring file watching using environment variable `TSC_WATCHFILE`) |
4 | 4 |
|
5 |
| -Option | Description |
| 5 | +μ΅μ
| μ€λͺ
|
6 | 6 | -----------------------------------------------|----------------------------------------------------------------------
|
7 |
| -`PriorityPollingInterval` | Use `fs.watchFile` but use different polling intervals for source files, config files and missing files |
8 |
| -`DynamicPriorityPolling` | Use a dynamic queue where in the frequently modified files will be polled at shorter interval and the files unchanged will be polled less frequently |
9 |
| -`UseFsEvents` | Use `fs.watch` which uses file system events (but might not be accurate on different OS) to get the notifications for the file changes/creation/deletion. Note that few OS eg. linux has limit on number of watches and failing to create watcher using `fs.watch` will result it in creating using `fs.watchFile` |
10 |
| -`UseFsEventsWithFallbackDynamicPolling` | This option is similar to `UseFsEvents` except on failing to create watch using `fs.watch`, the fallback watching happens through dynamic polling queues (as explained in `DynamicPriorityPolling`) |
11 |
| -`UseFsEventsOnParentDirectory` | This option watches parent directory of the file with `fs.watch` (using file system events) thus being low on CPU but can compromise accuracy. |
12 |
| -default (no value specified) | If environment variable `TSC_NONPOLLING_WATCHER` is set to true, watches parent directory of files (just like `UseFsEventsOnParentDirectory`). Otherwise watch files using `fs.watchFile` with `250ms` as the timeout for any file |
| 7 | +`PriorityPollingInterval` | `fs.watchFile`μ μ¬μ©νμ§λ§ μμ€ νμΌ, μ€μ νμΌ λ° λλ½λ νμΌμ λν΄ λ€λ₯Έ ν΄λ§ μ£ΌκΈ°(polling intervals)λ₯Ό μ¬μ©ν©λλ€. |
| 8 | +`DynamicPriorityPolling` | μμ£Ό μμ λλ νμΌμ μμ£Ό ν΄λ§νκ³ λ³κ²½λμ§ μμ νμΌμ λ μμ£Ό ν΄λ§ νλ λμ νλ₯Ό μ¬μ©ν©λλ€. |
| 9 | +`UseFsEvents` | νμΌ μμ€ν
μ΄λ²€νΈλ₯Ό μ¬μ©νλ `fs.watch`λ₯Ό μ¬μ©νμ¬ νμΌ λ³κ²½/μμ±/μμ μ λν μλ¦Όμ λ°μ΅λλ€. (`fs.watch`λ OSλ§λ€ λ€λ₯΄κ² μλν μ μμ΅λλ€.) μλ₯Ό λ€μ΄. 리λ
μ€λ watcher μμ μ νμ΄ μμΌλ©° `fs.watch`λ₯Ό μ¬μ©νμ¬ watcherλ₯Ό λ§λ€μ§ λͺ»νλ©΄, `fs.watchFile`λ₯Ό λμ μ¬μ©νμ¬ watcherλ₯Ό λ§λ€κ² λ©λλ€. |
| 10 | +`UseFsEventsWithFallbackDynamicPolling` | μ΄ μ΅μ
μ `fs.watch`λ₯Ό μ¬μ©νμ¬ κ°μμλ₯Ό λ§λ€μ§ λͺ»ν κ²½μ° ν΄λ§μ΄ λμ νλ₯Ό ν΅ν΄ μνλλ€λ κ²μ μ μΈνκ³ λ `UseFsEvents` μ΅μ
κ³Ό λΉμ·ν©λλ€.(λμ νμ λν κ²μ `DynamicPriorityPolling`μ΅μ
μμ μ€λͺ
νμμ΅λλ€.). |
| 11 | +`UseFsEventsOnParentDirectory` | μ΄ μ΅μ
μ `fs.watch`(νμΌ μμ€ν
μ΄λ²€νΈ μ¬μ©νλ)λ‘ νμΌμ μμ λλ ν°λ¦¬λ₯Ό κ°μν©λλ€. λ€λ§, CPU μ¬μ©λμ΄ λμ΄λκ³ μ νλλ λ¨μ΄μ§ μ μμ΅λλ€. |
| 12 | +default (no value specified) | νκ²½ λ³μ`TSC_NONPOLLING_WATCHER`κ° trueλ‘ μ€μ λλ©΄ νμΌμ μμ λλ ν°λ¦¬λ₯Ό κ°μν©λλ€. (`UseFsEventsOnParentDirectory`μ λμΌ).false μΌ λλ `fs.watchFile`μ μ¬μ©νμ¬ `250ms` μκ° μ νκ³Ό ν¨κ» λͺ¨λ νμΌλ€μ κ°μν©λλ€. |
13 | 13 |
|
14 |
| -## Configuring directory watching using environment variable `TSC_WATCHDIRECTORY` |
| 14 | +## νκ²½ λ³μ`TSC_WATCHDIRECTORY`λ₯Ό μ¬μ©νμ¬ λλ ν°λ¦¬ κ°μ μ€μ (Configuring directory watching using environment variable `TSC_WATCHDIRECTORY`) |
15 | 15 |
|
16 |
| -The watching of directory on platforms that don't support recursive directory watching natively in node, is supported through recursively creating directory watcher for the child directories using different options selected by `TSC_WATCHDIRECTORY`. Note that on platforms that support native recursive directory watching (e.g windows) the value of this environment variable is ignored. |
| 16 | +κΈ°λ³Έμ μΌλ‘ nodeμμ λλ ν°λ¦¬μ μ¬κ·μ μΈ κ°μλ₯Ό μ§μνμ§ μλ νλ«νΌμμ, λλ ν°λ¦¬ κ°μ κΈ°λ₯μ `TSC_WATCHDIRECTORY`μμ μ νν λ€μν μ΅μ
μ μ¬μ©νμ¬ νμ λλ ν°λ¦¬μ λν λλ ν°λ¦¬ watcherλ₯Ό μ¬κ·μ μΌλ‘ μμ±ν¨μΌλ‘μ¨ μ§μλ©λλ€. κΈ°λ³Έμ μΌλ‘ μ¬κ· λλ ν°λ¦¬ κ°μ(μ: windows)λ₯Ό μ§μνλ νλ«νΌμμλ μ΄ νκ²½ λ³μμ κ°μ΄ 무μλ©λλ€. |
17 | 17 |
|
18 |
| -Option | Description |
| 18 | +μ΅μ
| μ€λͺ
|
19 | 19 | -----------------------------------------------|----------------------------------------------------------------------
|
20 |
| -`RecursiveDirectoryUsingFsWatchFile` | Use `fs.watchFile` to watch the directories and child directories which is a polling watch (consuming CPU cycles) |
21 |
| -`RecursiveDirectoryUsingDynamicPriorityPolling`| Use dynamic polling queue to poll changes to the directory and child directories. |
22 |
| -default (no value specified) | Use `fs.watch` to watch directories and child directories |
| 20 | +`RecursiveDirectoryUsingFsWatchFile` | `fs.watchFile`μ μ¬μ©νμ¬ ν΄λ§ κ°μ(CPU cycles μ¬μ©)μΈ λλ ν°λ¦¬ λ° νμ λλ ν°λ¦¬λ₯Ό κ°μν©λλ€. |
| 21 | +`RecursiveDirectoryUsingDynamicPriorityPolling`| λμ ν΄λ§ νλ₯Ό μ¬μ©νμ¬ λλ ν°λ¦¬ λ° νμ λλ ν°λ¦¬μ λν λ³κ²½μ¬νμ ν΄λ§ ν©λλ€. |
| 22 | +default (no value specified) | `fs.watch`λ₯Ό μ¬μ©νμ¬ λλ ν°λ¦¬ λ° νμ λλ ν°λ¦¬λ₯Ό κ°μν©λλ€. |
23 | 23 |
|
24 |
| -## Background |
| 24 | +## λ°°κ²½ (Background) |
25 | 25 |
|
26 |
| -`--watch` implementation of the compiler relies on `fs.watch` and `fs.watchFile` provided by node, both of these methods have pros and cons. |
| 26 | +μ»΄νμΌλ¬μ `--watch` ꡬνμ nodeμμ μ 곡νλ `fs.watch`μ `fs.watchFile`μ μμ‘΄νλ©°, μ΄ λ λ°©λ² λͺ¨λ μ₯λ¨μ μ΄ μμ΅λλ€. |
27 | 27 |
|
28 |
| -`fs.watch` uses file system events to notify the changes in the file/directory. But this is OS dependent and the notification is not completely reliable and does not work as expected on many OS. Also there could be limit on number of watches that can be created, eg. linux and we could exhaust it pretty quickly with programs that include large number of files. But because this uses file system events, there is not much CPU cycle involved. Compiler typically uses `fs.watch` to watch directories (eg. source directories included by config file, directories in which module resolution failed etc) These can handle the missing precision in notifying about the changes. But recursive watching is supported on only Windows and OSX. That means we need something to replace the recursive nature on other OS. |
| 28 | +`fs.watch`λ νμΌ μμ€ν
μ΄λ²€νΈλ₯Ό μ¬μ©νμ¬ νμΌ/λλ ν°λ¦¬μ λ³κ²½ μ¬νμ μ립λλ€. νμ§λ§ OSμ λ°λΌ λ€λ₯΄λ©°, μλ¦Όμ μμ ν λ―Ώμ μκ° μκ³ , λ§μ OSμμ μμλλ‘ λμνμ§ μμ΅λλ€. λν, μμ±ν μ μλ watcherμ μμ μ νμ΄ μμ μ μμΌλ©°(μ: linux), νμΌ μκ° λ§μ νλ‘κ·Έλ¨μ μ¬μ©νλ©΄ λ§€μ° λΉ λ₯΄κ² μμ§ν μ μμ΅λλ€. κ·Έλ¬λ μ΄ μμ
μ νμΌ μμ€ν
μ΄λ²€νΈλ₯Ό μ¬μ©νκΈ° λλ¬Έμ CPU cycleμ λ§μ΄ κ΄μ¬νμ§ μμ΅λλ€. μ»΄νμΌλ¬λ μΌλ°μ μΌλ‘ `fs.watch`λ₯Ό μ¬μ©νμ¬ λλ ν°λ¦¬λ₯Ό κ°μν©λλ€. (μ: μ€μ νμΌμ ν¬ν¨λ μμ€ λλ ν°λ¦¬, λͺ¨λ νμΈμ μ€ν¨ν λλ ν°λ¦¬ ... λ±) λ³κ²½ μ¬νμ λν μλ¦Όμμ λλ½λ μ λ°λλ₯Ό μ²λ¦¬ν μ μμ΅λλ€. κ·Έλ¬λ μ¬κ· κ°μ κΈ°λ₯μ Windowsμ OSXμμλ§ μ§μλ©λλ€. μ¦, λ€λ₯Έ OSλ€μ μ¬κ·μ νΉμ±μ λ체ν 무μΈκ°κ° νμν©λλ€. |
29 | 29 |
|
30 |
| -`fs.watchFile` uses polling and thus involves CPU cycles. But this is the most reliable mechanism to get the update on the status of file/directory. Compiler typically uses `fs.watchFile` to watch source files, config files and missing files (missing file references) that means the CPU usage depends on number of files in the program. |
| 30 | +`fs.watchFile`μ ν΄λ§μ μ¬μ©νλ―λ‘ CPU μ£ΌκΈ°λ₯Ό ν¬ν¨ν©λλ€. νμ§λ§ μ΄λ νμΌ/λλ ν°λ¦¬ μνμ λν μ
λ°μ΄νΈλ₯Ό λ°μ μ μλ κ°μ₯ μ λ’°ν μ μλ λ©μ»€λμ¦μ
λλ€. μ»΄νμΌλ¬λ μΌλ°μ μΌλ‘ `fs.watchFile`μ μ¬μ©νμ¬ μμ€ νμΌ, κ΅¬μ± νμΌ λ° λλ½λ νμΌ(λλ½λ νμΌ μ°Έμ‘°)μ κ°μνλλ° μ΄λ CPU μ¬μ©λμ΄ νλ‘κ·Έλ¨μ νμΌ μμ λ°λΌ λ¬λΌμ§λ€λ κ²μ μλ―Έν©λλ€. |
0 commit comments