hundreds-breakfast-49010
03/31/2020, 1:39 AMhundreds-breakfast-49010
03/31/2020, 1:40 AMtokio and using async syntaxhundreds-breakfast-49010
03/31/2020, 1:41 AMhundreds-breakfast-49010
03/31/2020, 1:43 AMhundreds-breakfast-49010
03/31/2020, 1:43 AMNodeKey::run, we grab std::time::SystemTime::now() and make a StartedWorkunit from thathundreds-breakfast-49010
03/31/2020, 1:44 AMasync move blockhundreds-breakfast-49010
03/31/2020, 1:46 AM.await calls, we inspect the StartedWorkunit again, and transform it into a Workunit we put into the storehundreds-breakfast-49010
03/31/2020, 1:47 AMfinish method: https://github.com/pantsbuild/pants/blob/master/src/rust/engine/workunit_store/src/lib.rs#L54, which computes TimeSpan::since(start_time)hundreds-breakfast-49010
03/31/2020, 1:47 AMhundreds-breakfast-49010
03/31/2020, 1:49 AM.await methods have been called in the async move block is happening some amount of real time after the code earlier in run where we originally computed start_time, so the time_span is measuring something that takes a human-noticeable amount of time to runhundreds-breakfast-49010
03/31/2020, 1:49 AMhundreds-breakfast-49010
03/31/2020, 2:02 AMhundreds-breakfast-49010
03/31/2020, 2:03 AMNodeKey::run code computes a start time outside of an async block, then computes an end time within that block, but after an .await call, and then subtracts themhundreds-breakfast-49010
03/31/2020, 2:05 AMprocess_execution (maybe process_execution/local.rs::run_and_capture_workdir?) to use async/await syntax, and insert time-recording and time-difference-recording amidst that syntax in those files, and get a useful time difference?hundreds-breakfast-49010
03/31/2020, 2:06 AMwitty-crayon-22786
03/31/2020, 2:07 AMwitty-crayon-22786
03/31/2020, 2:10 AMwitty-crayon-22786
03/31/2020, 2:12 AMaloof-angle-91616
03/31/2020, 2:13 AMhundreds-breakfast-49010
03/31/2020, 2:16 AMhundreds-breakfast-49010
03/31/2020, 2:19 AMhundreds-breakfast-49010
03/31/2020, 2:20 AMhundreds-breakfast-49010
03/31/2020, 2:21 AM.await syntax the code that computed the end time was in an .inspect future that was placed after that main future that delegated to each variant of `NodeKey`'s run methodwitty-crayon-22786
03/31/2020, 2:24 AMwitty-crayon-22786
03/31/2020, 2:26 AMwitty-crayon-22786
03/31/2020, 2:26 AMwitty-crayon-22786
03/31/2020, 2:27 AMwitty-crayon-22786
03/31/2020, 2:27 AMhundreds-breakfast-49010
03/31/2020, 2:30 AMhundreds-breakfast-49010
03/31/2020, 2:31 AMCommand data structurewitty-crayon-22786
03/31/2020, 2:31 AMhundreds-breakfast-49010
03/31/2020, 2:35 AMAsyncSempahore::with_acquired ?witty-crayon-22786
03/31/2020, 2:36 AMhundreds-breakfast-49010
03/31/2020, 2:37 AMwitty-crayon-22786
03/31/2020, 2:37 AMhundreds-breakfast-49010
03/31/2020, 2:42 AM///
/// Runs the given Future-creating function (and the Future it returns) under the semaphore.
///
pub async fn with_acquired<F, B, O>(self, f: F) -> O
where
F: FnOnce() -> B + Send + 'static,
B: Future<Output = O> + Send + 'static,
{
let permit = self.acquire().await;
let start_time = std::time::SystemTime::now();
let res = f().await;
drop(permit);
let end_time = std::time::SystemTime::now();
let duration = end_time.since(start_time);
res
}
?witty-crayon-22786
03/31/2020, 2:50 AMwitty-crayon-22786
03/31/2020, 2:51 AMhundreds-breakfast-49010
03/31/2020, 2:51 AM.await calls like that meaningful?witty-crayon-22786
03/31/2020, 2:51 AMwitty-crayon-22786
03/31/2020, 2:52 AMhundreds-breakfast-49010
03/31/2020, 2:55 AM.await expression, right? so for instance in that block I proposed above, the execution thread would record the current start time, then wait on let res = f().await; until that had taken some amount of real time to complete, and then we'd drop the lock immediately and let end_time = std::time::SystemTime::now(); would be a new timestamp sometime meaningfully in the future from start_time?witty-crayon-22786
03/31/2020, 2:56 AM