- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.7k
 
Scalable jobserver for rustc #7731
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
Changes from all commits
ec80cf9
              4a8237f
              877fe69
              cdcd9ad
              494b3c0
              f7c6d04
              e2f4ce1
              90ef289
              f07fbb2
              f6deb98
              445de0e
              0d722a4
              b448d92
              ae7aba2
              c5f4690
              78afa06
              1d9fdee
              5a9af54
              1988dd9
              50a6083
              ec4cce9
              4bd074e
              25bf99b
              1204a52
              6117f52
              7e3e1b1
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -69,6 +69,11 @@ pub struct Context<'a, 'cfg> { | |
| /// metadata files in addition to the rlib itself. This is only filled in | ||
| /// when `pipelining` above is enabled. | ||
| rmeta_required: HashSet<Unit<'a>>, | ||
| 
     | 
||
| /// When we're in jobserver-per-rustc process mode, this keeps those | ||
| /// jobserver clients for each Unit (which eventually becomes a rustc | ||
| /// process). | ||
| pub rustc_clients: HashMap<Unit<'a>, Client>, | ||
| } | ||
| 
     | 
||
| impl<'a, 'cfg> Context<'a, 'cfg> { | ||
| 
          
            
          
           | 
    @@ -112,6 +117,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { | |
| unit_dependencies, | ||
| files: None, | ||
| rmeta_required: HashSet::new(), | ||
| rustc_clients: HashMap::new(), | ||
| pipelining, | ||
| }) | ||
| } | ||
| 
          
            
          
           | 
    @@ -491,4 +497,23 @@ impl<'a, 'cfg> Context<'a, 'cfg> { | |
| pub fn rmeta_required(&self, unit: &Unit<'a>) -> bool { | ||
| self.rmeta_required.contains(unit) || self.bcx.config.cli_unstable().timings.is_some() | ||
| } | ||
| 
     | 
||
| pub fn new_jobserver(&mut self) -> CargoResult<Client> { | ||
| let tokens = self.bcx.build_config.jobs as usize; | ||
| let client = Client::new(tokens).chain_err(|| "failed to create jobserver")?; | ||
| 
     | 
||
| // Drain the client fully | ||
| for i in 0..tokens { | ||
| while let Err(e) = client.acquire_raw() { | ||
| anyhow::bail!( | ||
| "failed to fully drain {}/{} token from jobserver at startup: {:?}", | ||
| i, | ||
| tokens, | ||
| e, | ||
| ); | ||
| } | ||
| 
         
      Comment on lines
    
      +507
     to 
      +514
    
   
  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the intent of this loop? Should it maybe be something like this? client.acquire_raw().chain_err(|| {
    format!(
        "failed to fully drain {}/{} token from jobserver at startup",
        i, tokens
    )
})?;There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I think so -- it doesn't really make any difference (bail! returns from the method anyway), but I'll send a PR cleaning it up. I suspect I had intended this as "loop until you error" but that's clearly not what this does :)  | 
||
| } | ||
| 
     | 
||
| Ok(client) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind throwing a comment on this field about what it holds?