- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Speed up tidy quite a lot #108772
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
          
     Merged
      
      
    
                
     Merged
            
            Speed up tidy quite a lot #108772
Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    
    
  matthiaskrgr 
      added a commit
        to matthiaskrgr/rust
      that referenced
      this pull request
    
      Mar 5, 2023 
    
    
      
  
    
      
    
  
…rsan68 x fmt: Only check modified files locally Previously, `x fmt` would only format modified files, while `x fmt .` and `x fmt --check` would still look at all files. After this change, `x fmt --check` only looks at modified files locally. I feel pretty confident in this change - other than rust-lang#106261, no one has reported bugs in `get_modified_rs_files` since it was added in rust-lang#105702. Combined with the changes in rust-lang#108772, this brings the time for me to run `x t tidy` with a hot FS cache down from 5 to 2 seconds (and moves the majority of the time spent back to `tidy check`, which means it can be sped up more in the future).
219be2d    to
    deef3fa      
    Compare
  
    
              
                    the8472
  
              
              reviewed
              
                  
                    Mar 10, 2023 
                  
              
              
            
            
              
                    jyn514
  
              
              commented
              
                  
                    Mar 10, 2023 
                  
              
              
            
            
              
                    the8472
  
              
              reviewed
              
                  
                    Mar 11, 2023 
                  
              
              
            
            
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
This makes it easier to profile.
- Skip files in `skip` wherever possible to avoid reading their contents - Don't look for `tidy-alphabetic-start` in tests. It's never currently used and slows the check down a lot. - Add new `filter_not_rust` helper function
Previously, it would walk each directory twice: once in the main `Walk` iterator, and once to count the number of entries in the directory. Now it only walks each directory once.
This has a significant speedup for me locally, from about 1.3 seconds to .9 seconds.
| 
           @bors r+ rollup  | 
    
    
  bors 
      added a commit
        to rust-lang-ci/rust
      that referenced
      this pull request
    
      Mar 18, 2023 
    
    
      
  
    
      
    
  
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#107416 (Error code E0794 for late-bound lifetime parameter error.) - rust-lang#108772 (Speed up tidy quite a lot) - rust-lang#109193 (Add revisions for -Zlower-impl-trait-in-trait-to-assoc-ty fixed tests) - rust-lang#109234 (Tweak implementation of overflow checking assertions) - rust-lang#109238 (Fix generics mismatch errors for RPITITs on -Zlower-impl-trait-in-trait-to-assoc-ty) - rust-lang#109283 (rustdoc: reduce allocations in `visibility_to_src_with_space`) - rust-lang#109287 (Use `size_of_val` instead of manual calculation) - rust-lang#109288 (Stabilise `unix_socket_abstract`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
    
  matthiaskrgr 
      added a commit
        to matthiaskrgr/rust
      that referenced
      this pull request
    
      Mar 23, 2023 
    
    
      
  
    
      
    
  
…yn514,ozkanonur Don't skip all directories when tidy-checking This fixes a regression from rust-lang#108772 which basically made it that tidy style checks only `README.md` and `COMPILER_TESTS.md`.
    
  bors 
      added a commit
        to rust-lang-ci/rust
      that referenced
      this pull request
    
      Mar 27, 2023 
    
    
      
  
    
      
    
  
Don't skip all directories when tidy-checking This fixes a regression from rust-lang#108772 which basically made it that tidy style checks only `README.md` and `COMPILER_TESTS.md`.
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      Labels
      
    A-testsuite
  Area: The testsuite used to check the correctness of rustc 
  
    S-waiting-on-bors
  Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 
  
    T-bootstrap
  Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
I highly recommend reviewing this commit-by-commit. Based on #106440 for convenience.
Timings
These were collected by running
x test tidy -vto copy paste the command, then usingsamply record.before (8 threads)

after (8 threads)
before (64 threads)

after (64 threads)
The last commit makes tidy use more threads, so comparing "before (8 threads)" to "after (64 threads)" is IMO the most realistic comparison. Locally, that brings the time for me to run tidy down from 4 to .9 seconds, i.e. the majority of the time for
x test tidyis now spend runningfmt --check.r? @the8472