Skip to content

Commit 05aefb9

Browse files
author
bumkeyy
committed
translate 'Performance Improvements'
1 parent e3cd858 commit 05aefb9

1 file changed

Lines changed: 20 additions & 21 deletions

File tree

β€Ždocs/documentation/ko/release-notes/TypeScript 4.9.mdβ€Ž

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -388,22 +388,21 @@ We expect TypeScript will expand this functionality to more keywords [such as `a
388388

389389
[This feature was implemented](https://github.com/microsoft/TypeScript/pull/51227) thanks to [Oleksandr Tarasiuk](https://github.com/a-tarasyuk).
390390

391-
## Performance Improvements
391+
## μ„±λŠ₯ κ°œμ„ 
392392

393-
TypeScript has a few small, but notable, performance improvements.
393+
TypeScriptμ—λŠ” λͺ‡ κ°€μ§€ μž‘μ§€λ§Œ μ£Όλͺ©ν•  λ§Œν•œ μ„±λŠ₯ κ°œμ„ μ΄ μžˆμŠ΅λ‹ˆλ‹€.
394394

395-
First, TypeScript's `forEachChild` function has been rewritten to use a function table lookup instead of a `switch` statement across all syntax nodes.
396-
`forEachChild` is a workhorse for traversing syntax nodes in the compiler, and is used heavily in the binding stage of our compiler, along with parts of the language service.
397-
The refactoring of `forEachChild` yielded up to a 20% reduction of time spent in our binding phase and across language service operations.
395+
첫째, λͺ¨λ“  ꡬ문 λ…Έλ“œμ—μ„œ `switch` λ¬Έ λŒ€μ‹  ν•¨μˆ˜ ν…Œμ΄λΈ” 쑰회λ₯Ό μ‚¬μš©ν•˜λ„λ‘ TypeScript의 `forEachChild` ν•¨μˆ˜κ°€ λ¦¬νŒ©ν„°λ§λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
396+
`forEachChild`λŠ” μ»΄νŒŒμΌλŸ¬μ—μ„œ ꡬ문 λ…Έλ“œλ₯Ό μˆœνšŒν•˜κΈ° μœ„ν•œ μž‘μ—… 도ꡬ이며 μ–Έμ–΄ μ„œλΉ„μŠ€μ˜ 일뢀와 ν•¨κ»˜ 컴파일러의 바인딩 λ‹¨κ³„μ—μ„œ 많이 μ‚¬μš©λ©λ‹ˆλ‹€. `forEachChild` λ¦¬νŒ©ν„°λ§μ€ 바인딩 단계와 μ–Έμ–΄ μ„œλΉ„μŠ€ μž‘μ—… μ „λ°˜μ— μ†Œμš”λ˜λŠ” μ‹œκ°„μ„ μ΅œλŒ€ 20% λ‹¨μΆ•ν–ˆμŠ΅λ‹ˆλ‹€.
398397

399-
Once we discovered this performance win for `forEachChild`, we tried it out on `visitEachChild`, a function we use for transforming nodes in the compiler and language service.
400-
The same refactoring yielded up to a 3% reduction in time spent in generating project output.
398+
`forEachChild`에 λŒ€ν•œ μ„±λŠ₯ ν–₯상을 ν™•μΈν•œ ν›„ 컴파일러 및 μ–Έμ–΄ μ„œλΉ„μŠ€μ—μ„œ λ…Έλ“œλ₯Ό λ³€ν™˜ν•˜λŠ” 데 μ‚¬μš©ν•˜λŠ” ν•¨μˆ˜μΈ `visitEachChild`μ—μ„œ λ¦¬νŒ©ν„°λ§μ„ μ‹œλ„ν–ˆμŠ΅λ‹ˆλ‹€.
399+
λ™μΌν•œ λ¦¬νŒ©ν„°λ§μœΌλ‘œ ν”„λ‘œμ νŠΈ κ²°κ³Όλ₯Ό μƒμ„±ν•˜λŠ” 데 μ†Œμš”λ˜λŠ” μ‹œκ°„μ΄ μ΅œλŒ€ 3% κ°μ†Œν–ˆμŠ΅λ‹ˆλ‹€.
401400

402-
The initial exploration in `forEachChild` was [inspired by a blog post](https://artemis.sh/2022/08/07/emulating-calculators-fast-in-js.html) by [Artemis Everfree](https://artemis.sh/).
403-
While we have some reason to believe the root cause of our speed-up might have more to do with function size/complexity than the issues described in the blog post, we're grateful that we were able to learn from the experience and try out a relatively quick refactoring that made TypeScript faster.
401+
`forEachChild`의 초기 탐색은 [Artemis Everfree](https://artemis.sh/)의 [λΈ”λ‘œκ·Έ κ²Œμ‹œλ¬Όμ—μ„œ 영감](https://artemis.sh/2022/08/07/emulating-calculators-fast-in-js.html)을 λ°›μ•˜μŠ΅λ‹ˆλ‹€.
402+
속도 ν–₯μƒμ˜ κ·Όλ³Έ 원인이 λΈ”λ‘œκ·Έ κ²Œμ‹œλ¬Όμ— μ„€λͺ…λœ λ¬Έμ œλ³΄λ‹€ κΈ°λŠ₯ 크기/λ³΅μž‘μ„±κ³Ό 더 관련이 μžˆλ‹€κ³  λ―Ώμ„λ§Œν•œ μ΄μœ κ°€ μžˆμ§€λ§Œ κ²½ν—˜μ„ 톡해 배우고 TypeScriptλ₯Ό 더 λΉ λ₯΄κ²Œ λ§Œλ“  μƒλŒ€μ μœΌλ‘œ λΉ λ₯Έ λ¦¬νŒ©ν† λ§μ„ μ‹œν—˜ν•΄ λ³Ό 수 μžˆμ—ˆλ˜ 것에 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€.
404403

405-
Finally, the way TypeScript preserves the information about a type in the true branch of a conditional type has been optimized.
406-
In a type like
404+
λ§ˆμ§€λ§‰μœΌλ‘œ TypeScriptκ°€ 쑰건뢀 μœ ν˜•μ˜ μ‹€μ œ λΆ„κΈ°μ—μ„œ νƒ€μž…μ— λŒ€ν•œ 정보λ₯Ό λ³΄μ‘΄ν•˜λŠ” 방식이 μ΅œμ ν™”λ˜μ—ˆμŠ΅λ‹ˆλ‹€.
405+
λ‹€μŒκ³Ό 같은 νƒ€μž…μ—μ„œ
407406

408407
```ts
409408
interface Zoo<T extends Animal> {
@@ -413,18 +412,18 @@ interface Zoo<T extends Animal> {
413412
type MakeZoo<A> = A extends Animal ? Zoo<A> : never;
414413
```
415414

416-
TypeScript has to "remember" that `A` must also be an `Animal` when checking if `Zoo<A>` is valid.
417-
This is basically done by creating a special type that used to hold the intersection of `A` with `Animal`;
418-
however, TypeScript previously did this eagerly which isn't always necessary.
419-
Furthermore, some faulty code in our type-checker prevented these special types from being simplified.
420-
TypeScript now defers intersecting these types until it's necessary.
421-
For codebases with heavy use of conditional types, you might witness significant speed-ups with TypeScript, but in our performance testing suite, we saw a more modest 3% reduction in type-checking time.
415+
TypeScriptλŠ” `Zoo<A>`κ°€ μœ νš¨ν•œμ§€ 확인할 λ•Œ `A`도 `Animal`이어야 ν•œλ‹€λŠ” 것을 "κΈ°μ–΅"ν•΄μ•Ό ν•©λ‹ˆλ‹€.
416+
기본적으둜 `A`와 `Animal`의 ꡐ차점을 μœ μ§€ν•˜λŠ” 데 μ‚¬μš©λ˜λŠ” 특수 νƒ€μž…μ„ μƒμ„±ν•˜μ—¬ μˆ˜ν–‰λ©λ‹ˆλ‹€.
417+
κ·ΈλŸ¬λ‚˜ TypeScriptλŠ” 이전에 이 μž‘μ—…μ„ μ—΄μ‹¬νžˆ μˆ˜ν–‰ν–ˆμœΌλ©° 항상 ν•„μš”ν•œ 것은 μ•„λ‹™λ‹ˆλ‹€.
418+
λ˜ν•œ νƒ€μž… κ²€μ‚¬κΈ°μ˜ 일뢀 잘λͺ»λœ μ½”λ“œλ‘œ 인해 μ΄λŸ¬ν•œ 특수 νƒ€μž…μ΄ λ‹¨μˆœν™”λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.
419+
TypeScriptλŠ” 이제 ν•„μš”ν•  λ•ŒκΉŒμ§€ μ΄λŸ¬ν•œ νƒ€μž…μ˜ ꡐ차λ₯Ό μ—°κΈ°ν•©λ‹ˆλ‹€.
420+
쑰건뢀 νƒ€μž…μ„ 많이 μ‚¬μš©ν•˜λŠ” μ½”λ“œλ² μ΄μŠ€μ˜ 경우 TypeScriptλ₯Ό μ‚¬μš©ν•˜μ—¬ μƒλ‹Ήν•œ 속도 ν–₯상을 λͺ©κ²©ν•  수 μžˆμ§€λ§Œ μ„±λŠ₯ ν…ŒμŠ€νŠΈ μ œν’ˆκ΅°μ—μ„œλŠ” μœ ν˜• 검사 μ‹œκ°„μ΄ 3% 더 μ™„λ§Œν•˜κ²Œ κ°μ†Œν–ˆμŠ΅λ‹ˆλ‹€.
422421

423-
You can read up more on these optimizations on their respective pull requests:
422+
각각의 ν’€ λ¦¬ν€˜μŠ€νŠΈμ—μ„œ 더 μžμ„Ένžˆ μ•Œμ•„λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€.
424423

425-
* [`forEachChild` as a jump-table](https://github.com/microsoft/TypeScript/pull/50225)
426-
* [`visitEachChild` as a jump-table](https://github.com/microsoft/TypeScript/pull/50266)
427-
* [Optimize substitition types](https://github.com/microsoft/TypeScript/pull/50397)
424+
* [`forEachChild` 점프 ν…Œμ΄λΈ”](https://github.com/microsoft/TypeScript/pull/50225)
425+
* [`visitEachChild` 점프 ν…Œμ΄λΈ”](https://github.com/microsoft/TypeScript/pull/50266)
426+
* [λŒ€μ²΄ νƒ€μž… μ΅œμ ν™”](https://github.com/microsoft/TypeScript/pull/50397)
428427

429428
## Correctness Fixes and Breaking Changes
430429

0 commit comments

Comments
Β (0)