Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(compiler-cli): minimize filesystem calls when generating shims #47682

Closed
wants to merge 1 commit into from

Conversation

clydin
Copy link
Member

@clydin clydin commented Oct 6, 2022

Previously when a file was being analyzed to determine if a shim should be generated, up to two calls to the host fileExists function per file per generator were made. In the default host, each fileExists call made two underlying file system calls. Following these calls, the file was then read via getSourceFile. However, getSourceFile will return undefined if the requested file does not exist. As a result, getSourceFile can be used directly to request both potential file names and leverage the return value to determine if the file does not exist. This avoids the need to call fileExists at all.

Previously when a file was being analyzed to determine if a shim should
be generated, up to two calls to the host `fileExists` function per file
per generator were made. In the default host, each `fileExists` call made
two underlying file system calls. Following these calls, the file was then
read via `getSourceFile`. However, `getSourceFile` will return `undefined`
if the requested file does not exist. As a result, `getSourceFile` can be
used directly to request both potential file names and leverage the return
value to determine if the file does not exist. This avoids the need to call
`fileExists` at all.
@clydin clydin added area: compiler Issues related to `ngc`, Angular's template compiler target: minor This PR is targeted for the next minor release labels Oct 6, 2022
@ngbot ngbot bot added this to the Backlog milestone Oct 6, 2022
@clydin clydin marked this pull request as ready for review October 6, 2022 20:43
Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I think this can go into patch instead of minor, can't it?

@clydin clydin added target: patch This PR is targeted for the next patch release and removed target: minor This PR is targeted for the next minor release labels Oct 7, 2022
@clydin clydin removed the request for review from AndrewKushnir October 7, 2022 15:01
@clydin clydin added the action: merge The PR is ready for merge by the caretaker label Oct 7, 2022
@jessicajaniuk
Copy link
Contributor

This PR was merged into the repository by commit a792bf1.

jessicajaniuk pushed a commit that referenced this pull request Oct 7, 2022
…47682)

Previously when a file was being analyzed to determine if a shim should
be generated, up to two calls to the host `fileExists` function per file
per generator were made. In the default host, each `fileExists` call made
two underlying file system calls. Following these calls, the file was then
read via `getSourceFile`. However, `getSourceFile` will return `undefined`
if the requested file does not exist. As a result, `getSourceFile` can be
used directly to request both potential file names and leverage the return
value to determine if the file does not exist. This avoids the need to call
`fileExists` at all.

PR Close #47682
@clydin clydin deleted the compiler/avoid-extra-fs-calls-2 branch October 7, 2022 16:10
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Oct 13, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@angular/animations](https://github.com/angular/angular) | dependencies | patch | [`14.2.5` -> `14.2.6`](https://renovatebot.com/diffs/npm/@angular%2fanimations/14.2.5/14.2.6) |
| [@angular/common](https://github.com/angular/angular) | dependencies | patch | [`14.2.5` -> `14.2.6`](https://renovatebot.com/diffs/npm/@angular%2fcommon/14.2.5/14.2.6) |
| [@angular/compiler](https://github.com/angular/angular) | dependencies | patch | [`14.2.5` -> `14.2.6`](https://renovatebot.com/diffs/npm/@angular%2fcompiler/14.2.5/14.2.6) |
| [@angular/compiler-cli](https://github.com/angular/angular/tree/main/packages/compiler-cli) ([source](https://github.com/angular/angular)) | devDependencies | patch | [`14.2.5` -> `14.2.6`](https://renovatebot.com/diffs/npm/@angular%2fcompiler-cli/14.2.5/14.2.6) |
| [@angular/core](https://github.com/angular/angular) | dependencies | patch | [`14.2.5` -> `14.2.6`](https://renovatebot.com/diffs/npm/@angular%2fcore/14.2.5/14.2.6) |
| [@angular/forms](https://github.com/angular/angular) | dependencies | patch | [`14.2.5` -> `14.2.6`](https://renovatebot.com/diffs/npm/@angular%2fforms/14.2.5/14.2.6) |
| [@angular/platform-browser](https://github.com/angular/angular) | dependencies | patch | [`14.2.5` -> `14.2.6`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser/14.2.5/14.2.6) |
| [@angular/platform-browser-dynamic](https://github.com/angular/angular) | dependencies | patch | [`14.2.5` -> `14.2.6`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser-dynamic/14.2.5/14.2.6) |

---

### Release Notes

<details>
<summary>angular/angular</summary>

### [`v14.2.6`](https://github.com/angular/angular/blob/HEAD/CHANGELOG.md#&#8203;1426-2022-10-12)

[Compare Source](angular/angular@14.2.5...14.2.6)

##### compiler-cli

| Commit | Type | Description |
| -- | -- | -- |
| [3fd176a905](angular/angular@3fd176a) | fix | add missing period to error message ([#&#8203;47744](angular/angular#47744)) |
| [c3821f5ab5](angular/angular@c3821f5) | perf | minimize filesystem calls when generating shims ([#&#8203;47682](angular/angular#47682)) |

#### Special Thanks

Alan Agius, Andrew Kushnir, Andrew Scott, Aristeidis Bampakos, Bob Watson, Charles Lyding, Joey Perrott, Joshua Morony, Mathew Berg, Paul Gschwendtner, Peter Dickten, Renan Ferro, Sri Ram, WD Snoeijer, markostanimirovic and Álvaro Martínez

<!-- CHANGELOG SPLIT MARKER -->

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMzQuMiIsInVwZGF0ZWRJblZlciI6IjMyLjIzNi4xIn0=-->

Co-authored-by: cabr2-bot <[email protected]>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1582
Reviewed-by: Epsilon_02 <[email protected]>
Co-authored-by: Calciumdibromid Bot <[email protected]>
Co-committed-by: Calciumdibromid Bot <[email protected]>
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants