what is the best way in the Rust engine for code r...
# development
f
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
Are the things you want to pass scoped more to the lifetime of a
CommandRunner
or a
Process
?
f
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
aren’t the metrics on the WorkunitStore?
could break the cycle by pushing it onto another sub-struct like that
f
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
yep