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

Delay snapshotting of desugaring environment #3585

Merged
merged 2 commits into from
Oct 18, 2024
Merged

Conversation

nikswamy
Copy link
Collaborator

Snapshotting a desugaring environment is linear in the number of definitions in scope

We currently snapshot the environment before processing any declaration, which leads to quadratic behavior for desugaring modules with a large number of definitions. Thanks @LukeXuan for noting this!

The snapshotting is needed to properly handle definitions marked with an "expect_failure" attribute. This PR snapshots the environment only when processing such a decorated definition, rather than unconditionally snapshotting it. This avoids the quadratic behavior in the common case of definitions that are not decorated with expect_failure

A better long-term solution would be to move to the use of persistent maps in desugaring, making such snapshots constant time.

(Note, there is still some quadratic behavior left in the desugaring phase, as name resolutions involve a linear scan---working on fixing that in a separate PR)

@nikswamy nikswamy merged commit 02ad8e3 into master Oct 18, 2024
3 checks passed
@nikswamy nikswamy deleted the nik_delay_dsenv_snapshot branch October 18, 2024 18:29
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