https://pantsbuild.org/ logo
#development
Title
# development
f

fast-nail-55400

12/20/2020, 4:56 AM
what is the best way in the Rust engine for code running in a
CommandRunner
impl to gain access to the current
Session
?
Session
owns a
Core
which owns the
CommandRunner
impls, so it would be a cycle to give
Core
or a
CommandRuner
impl access to
Session
. Context is putting some session-level metric collection code (for time-series metrics) on
Session
. Thoughts?
One solution would be to pass down some sort of proxy object that refers back weakly to the Session via a
Weak
. Are there any better solutions?
a

average-vr-56795

12/20/2020, 10:34 AM
Are the things you want to pass scoped more to the lifetime of a
CommandRunner
or a
Process
?
f

fast-nail-55400

12/20/2020, 11:22 PM
to the Session actually, this is for the collection of time histograms for timing stats that are not easy to collect via work unit timings. when a Session completes, the goal is to upload the timings just as counters are uploaded via work units.
I have an open PR to add the timing data collection to work units in https://github.com/pantsbuild/pants/pull/11185, but full fidelity of timing stats is too much data, better to collect a histogram. (I’m looking at https://github.com/HdrHistogram/HdrHistogram_rust for the histogram code.)
so with histogram, better to do it at the session level for particular pants runs than at work unit level.
w

witty-crayon-22786

12/21/2020, 6:02 PM
aren’t the metrics on the WorkunitStore?
could break the cycle by pushing it onto another sub-struct like that
f

fast-nail-55400

12/21/2020, 6:05 PM
the counters are on the WorkunitStore. good point, I can just attach the histograms on the workunit store and not individual work units.
and that would still be “session level”
w

witty-crayon-22786

12/21/2020, 6:05 PM
yep