-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
Allow processes to occupy more than one slot in the execution semaphore #21960
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -9,11 +9,11 @@ use deepsize::DeepSizeOf; | |
use fs::RelativePath; | ||
use graph::CompoundNode; | ||
use process_execution::{ | ||
self, CacheName, InputDigests, Process, ProcessCacheScope, ProcessExecutionStrategy, | ||
ProcessResultSource, | ||
self, CacheName, InputDigests, Process, ProcessCacheScope, ProcessConcurrency, ProcessExecutionStrategy, ProcessResultSource | ||
}; | ||
use pyo3::prelude::{PyAny, Python}; | ||
use pyo3::pybacked::PyBackedStr; | ||
use pyo3::types::{PyAnyMethods, PyStringMethods, PyTypeMethods}; | ||
use pyo3::Bound; | ||
use store::{self, Store, StoreError}; | ||
use workunit_store::{ | ||
|
@@ -124,6 +124,27 @@ impl ExecuteProcess { | |
.map_err(|e| format!("Failed to get `execution_slot_variable` for field: {e}"))?; | ||
|
||
let concurrency_available: usize = externs::getattr(value, "concurrency_available")?; | ||
|
||
let concurrency_value: Option<Bound<'_, PyAny>> = externs::getattr(value, "concurrency")?; | ||
let concurrency: Option<ProcessConcurrency> = match concurrency_value { | ||
None => Ok(None), | ||
Some(conc) => { | ||
let py_type = conc.get_type(); | ||
let py_name = py_type.name().unwrap(); | ||
let type_name = py_name.to_str().unwrap(); | ||
match type_name { | ||
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. Clunky, but I don't see a better way to model a rust enum in Python, so this is fine. 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. The current pass at the python api feels clunky to use too though, I could use some perspective there in how we'd want plugin authors to define this (and eventually how it could trickle down into the fields of targets if necessary) |
||
"ProcessConcurrencyRange" => { | ||
let min: Option<usize> = externs::getattr(&conc, "min")?; | ||
let max: Option<usize> = externs::getattr(&conc, "max")?; | ||
Ok(Some(ProcessConcurrency::Range { min, max })) | ||
} | ||
"ProcessConcurrencyExclusive" => Ok(Some(ProcessConcurrency::Exclusive)), | ||
_ => Err(format!("Unknown ProcessConcurrency type: {}", type_name)), | ||
} | ||
} | ||
}?; | ||
|
||
log::debug!("Parsed concurrency: {:?}", concurrency); | ||
|
||
let cache_scope: ProcessCacheScope = { | ||
let cache_scope_enum: Bound<'_, PyAny> = externs::getattr(value, "cache_scope")?; | ||
|
@@ -151,6 +172,7 @@ impl ExecuteProcess { | |
jdk_home, | ||
execution_slot_variable, | ||
concurrency_available, | ||
concurrency, | ||
cache_scope, | ||
execution_environment: process_config.environment, | ||
remote_cache_speculation_delay, | ||
|
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.
Would be good to figure this out...