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

Record how long a process takes to run #11594

Merged

Conversation

Eric-Arellano
Copy link
Contributor

@Eric-Arellano Eric-Arellano commented Feb 24, 2021

This will allow us to answer questions like how much time caching (both local and remote) is saving vs. running the process again. For example, we can compare the cache time vs. the original recorded execution time.

To preserve the execution time, we must store the metadata both on FallibleProcessResultWithPlatform and ActionResult, which is what we serialize to for the local and remote caches. This introduces ProcessResultMetadata, which is a sibling to REAPI's ExecutedActionMetadata.

For remote execution, it's up to them to correctly set the ExecutedActionMetadata, which we then convert into ProcessResultMetadata. But for local execution, we can ensure we set up both types correctly.

The timings match what we see with the dynamic UI:

12:43:46.35 [INFO] Starting: Building pytest.pex with 5 requirements: ipdb, pygments, pytest-cov>=2.10.1,<2.12, pytest-icdiff, pytest>=6.0.1,<6.3
12:43:50.92 [INFO] Completed: Building pytest.pex with 5 requirements: ipdb, pygments, pytest-cov>=2.10.1,<2.12, pytest-icdiff, pytest>=6.0.1,<6.3
12:43:50.92 [INFO] Some(Duration { secs: 4, nanos: 565505208 })

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@Eric-Arellano Eric-Arellano force-pushed the process-execution-duration branch from 8116445 to 6185203 Compare February 24, 2021 03:44
Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Looks good!

While lossy, this is much easier to get working correctly with local.rs

[ci skip-build-wheels]
[ci skip-build-wheels]
@Eric-Arellano Eric-Arellano changed the title WIP: Record how long a process takes to run Record how long a process takes to run Feb 24, 2021
@Eric-Arellano Eric-Arellano marked this pull request as ready for review February 24, 2021 19:11
metadata.execution_start_timestamp,
metadata.execution_completed_timestamp,
) {
(Some(started), Some(completed)) => TimeSpan::from_start_and_end(&started, &completed, "")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The string is used for Err, but we then throw that away with .ok() so I left it empty.

Copy link
Member

Choose a reason for hiding this comment

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

That's a weird API... ideally it would return a non-allocated error type with a Debug/Display impl, rather than passing in a string to format. But yea, this is fine for now.

We might consider logging at debug for negative times though...

Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks!

@Eric-Arellano Eric-Arellano merged commit 7de376d into pantsbuild:master Feb 24, 2021
@Eric-Arellano Eric-Arellano deleted the process-execution-duration branch February 24, 2021 20:58
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.

3 participants