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

[move-compiler] Remove WarningFiltersScope from CompilationEnv #20065

Merged
merged 23 commits into from
Oct 29, 2024

Conversation

tnowacki
Copy link
Contributor

Description

  • To make the compiler more parallel friendly, the warning filter scope needs to be local to the environment it is in
  • Conceptually, CompilationEnv was always the wrong place for this, and trying to add parallelism just exposed this
  • Added a RwLock around Diagnostics to help with linters. It was a bit hard to tie the knot without doing this as a part of this PR

Test plan

  • Ran tests

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

Copy link

vercel bot commented Oct 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 29, 2024 8:38pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Oct 29, 2024 8:38pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Oct 29, 2024 8:38pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Oct 29, 2024 8:38pm

Comment on lines 61 to 77
pub fn add_diag(&self, diag: Diagnostic) {
self.env.add_diag(&self.warning_filters_scope, diag);
}

#[allow(unused)]
pub fn add_diags(&self, diags: Diagnostics) {
self.env.add_diags(&self.warning_filters_scope, diags);
}

pub fn add_warning_filter_scope(&mut self, filters: WarningFilters) {
self.warning_filters_scope.push(filters)
}

pub fn pop_warning_filter_scope(&mut self) {
self.warning_filters_scope.pop()
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of repeating this pattern several places, what about something like:

struct DiagnosticReporter {
  diags: Arc<RwLock<Diagnostics>>,
  warning_filters: ...
}

impl DiagnosticReporter {
    pub fn add_diag(&self, diag: Diagnostic) {
        self.env.add_diag(&self.warning_filters_scope, diag);
    }

    #[allow(unused)]
    pub fn add_diags(&self, diags: Diagnostics) {
        self.env.add_diags(&self.warning_filters_scope, diags);
    }

    pub fn add_warning_filter_scope(&mut self, filters: WarningFilters) {
        self.warning_filters_scope.push(filters)
    }

    pub fn pop_warning_filter_scope(&mut self) {
        self.warning_filters_scope.pop()
    }
}

And tne for the env:

impl CompilationEnv {
  fn diag_reporter() -> { 
    DiagnosticReporter {
      diags: Arc::clone(self.diags),
      warning_filters: self.top_level_warning_filter_scope().clone(),
    }
  }
}

Then we can hold/reuse this in local scopes, easing the pressure of the rewrite and simplifying some of the changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's make some progress on this offline. I think it would make this large PR a bit too large.
I'm fine making iterative progress here, even if eventually this entire PR is undone

Copy link
Contributor

@cgswords cgswords left a comment

Choose a reason for hiding this comment

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

LGTM modulo hemming and hawwing over the general approach.

@tnowacki tnowacki merged commit 29cb03e into MystenLabs:main Oct 29, 2024
48 checks passed
@tnowacki tnowacki deleted the ctx branch October 29, 2024 23:03
tnowacki added a commit that referenced this pull request Nov 1, 2024
## Description 

- Followup to #20065
- Better encapsulates warning filter scopes with diagnostic reporting

## Test plan 

- ran tests

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
lxfind pushed a commit that referenced this pull request Nov 5, 2024
## Description 

- Followup to #20065
- Better encapsulates warning filter scopes with diagnostic reporting

## Test plan 

- ran tests

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
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.

2 participants