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

Performance boost by lifting some global lookups #92

Merged
merged 1 commit into from
Jul 14, 2023
Merged

Conversation

TwitchBronBron
Copy link
Member

Fixes a bug in the varTracking logic that was re-calculating the globals too frequently (for each file for each scope). Since the globals are shared across every file in that scope, we can lift that calculation.

Here's some pseudocode of what changed.
Before:

for (const scope of scopes) {
    for (const file of scope.files) {
        const globals = getAllGlobalNamesInScope(scope);
        validateFile(scope, file, globals);
    }
}

After:

for (const scope of scopes) {
    const globals = getAllGlobalNamesInScope(scope);
    for (const file of scope.files) {
        validateFile(scope, file, globals);
    }
}

This shaved off 1,300ms from the validation cycle of a large internal project

Before:

Validating project finished. (6s531.186ms)

After:

Validating project finished. (5s224.474ms)

@TwitchBronBron TwitchBronBron merged commit d5c4a88 into master Jul 14, 2023
@TwitchBronBron TwitchBronBron deleted the perf-fix branch July 14, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant