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
[pantsd] Repair end to end runtracker timing for pantsd runs. #5526
Conversation
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.
Thanks Kris.
src/python/pants/goal/run_tracker.py
Outdated
"""Creates a synthetic workunit with a pre-computed timing. | ||
|
||
- name: A short name for this work. E.g., 'resolve', 'compile', 'scala', 'zinc'. | ||
- timing: The pre-compted timing for this workunit. |
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.
computed
@@ -53,6 +54,7 @@ def _setup_pailgun(self): | |||
"""Sets up a PailgunServer instance.""" | |||
# Constructs and returns a runnable PantsRunner. | |||
def runner_factory(sock, arguments, environment): | |||
start_time = time.time() |
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 add a comment indicating how you chose this location for start_time
: basically, it's as close to the connection arriving off the socket as we can get?
nit: Could use
pants/src/python/pants/util/contextutil.py
Line 269 in 6d87acd
class Timer(object): |
src/python/pants/base/workunit.py
Outdated
@@ -119,6 +119,7 @@ def __init__(self, run_info_dir, parent, name, labels=None, cmd='', log_config=N | |||
# In seconds since the epoch. Doubles, to account for fractional seconds. | |||
self.start_time = 0 | |||
self.end_time = 0 |
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.
Because these properties are public, it would be good to defend against people accessing them directly rather than consuming def duration
. Perhaps you could convert them into @property
s that fail if _synthetic_duration
is set? Or convert to @property
s and then deprecate the properties?
@@ -75,6 +79,7 @@ def _run(self): | |||
repro.capture(run_tracker.run_info.get_as_dict()) | |||
|
|||
# Record the preceding product graph size. | |||
run_tracker.new_pre_timed_workunit('graph_warmth', self._graph_warmth_timing) |
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.
Will this render under main
? I think it would need to to actually be counted toward cumulative timings for main
. Should be able to check easily in ./pants server --open
.
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.
apparently not: the self_timings show up implicitly as main:graph_warmth, but tests reveal that the cumulative_timings for main < self_timings for main:graph_warmth..
Actually, sorry to do this now, but I have another potential approach here that I didn't think of until after posting. How would you feel about having a native "startup" workunit created by Anyway, don't feel strongly about it... but i think it is a minor change, and the upside would be that we would have a guarantee that all work between |
makes sense to me, but I see them as two different things we'd want to time. i.e. I think we should probably do both? |
Maybe... I think that the other way to look at it would be that we want to create the Perhaps a better lens to look at this through is: what will we want to do when a lot more work is happening in the daemon pre-fork? ... thinking about it from that angle, it would almost seem like we want to create the RunTracker itself pre-fork...? |
totally makes sense down the road - I was thinking we'd probably want to port a "v2" |
I agree that it seems unlikely that we'll be able to use the
Agreed. If you want to push forward with an approach that assumes muiltiple synthetic workunits created pre-fork and then recorded post-fork, that would be fine with me. |
bdb64a4
to
5748152
Compare
@stuhood revised the approach - PTAL. |
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.
I like it.
@@ -41,6 +41,10 @@ def run(self): | |||
with hard_exit_handler(), maybe_profiled(profile_path): | |||
self._run() | |||
|
|||
def _maybe_get_client_start_time_from_env(self): | |||
client_start_time = self._env.pop('PANTSD_RUNTRACKER_CLIENT_START_TIME', None) |
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.
Neat.
Oh, sorry again: one more thing before merging. I'm guessing that we're failing to capture some time even when running without pantsd: Can we use this same |
I assumed this was just a few seconds at most, but added - how's that look? |
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.
Thanks!
Fixes #5522