-
Notifications
You must be signed in to change notification settings - Fork 178
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
feat(robot-server, api, performance-metrics): get performance metrics to work on robot #15008
Conversation
As is high risk, l would like this to not merge to edge until 5/2 post code freeze for 7.3.0. |
Nope, will mark do not merge. |
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.
Okay, I see what we're going for here and accept that you want to change it soon, but I really think we should start as we mean to go on: just don't have store_each
, and have the analysis tracker explicitly store once in a finally
after the analysis ends. store_each
would mean a disk hit after every tracked function call and totally kill perf, and I think it's equally clear to just have it at the end of the analyze call.
performance-metrics/src/performance_metrics/robot_context_tracker.py
Outdated
Show resolved
Hide resolved
http://$(host):31950/settings/log_level/local | jq | ||
|
||
.PHONY: add-performance-metrics-ff | ||
add-performance-metrics-ff: |
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.
Nitpick, feel free to ignore: I might call this set-performance-metrics-ff
or enable-performance-metrics-ff
.
# Enable tracking for the RobotContextTracker | ||
# This must come before the import of the analyze CLI | ||
context_tracker = _get_robot_context_tracker() | ||
|
||
# Ignore the type error for the next line, as we're setting a private attribute for testing purposes | ||
context_tracker._should_track = True # type: ignore[attr-defined] |
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.
Okay, so as far as I can tell:
- Our performance tracking code is global, for the same reason that logging is global: ease of access.
- Our performance tracking code has import-time logic, for performance reasons. (To avoid having to check
if running_on_robot: ...
every time it's called.) - As we're beginning to see here, both of the above are going to make it very annoying and icky to test that the code under measurement calls the performance tracking code correctly,
To "fix" this, I would support just not having unit tests like this. We just won't check that the code under measurement emits metrics. By analogy, we're also okay with not checking that the code under test emits logs. It's not worthwhile to test because it's noncritical and also not error-prone. And we want it to be cheap and easy to move measurements around as we hone in on good targets.
Closing in favor of, #15289 |
Overview
Will close https://opentrons.atlassian.net/browse/EXEC-413
Various fixes to get performance metrics working on the robot
Test Plan
Test Instructions
performance-metrics
dir(cd ../api && make term)
/data
directorycd /data
performance_metrics_data
directory exists -ls -l
cd performance_metrics_data
performance_metrics_data
there should be 2 files:robot_context_data
robot_context_data_headers
robot_context_data
should contain a single line something like,2, a big number, another big number
robot_context_data_headers
should contain a single linestate_id,function_start_time,duration
robot_context_data_headers
should be the same.robot_context_data
should have another line something like,2, a big number, another big number
TESTS
Changelog
Fixes
There are a lot of little issues that I found while trying to get this to work
tracker.store()
inside oftrack_analysis
for sure will not work because the underlying decorated function has not finished running when this is called. This must be deferred to RobotContextTracker to handle. This is the reasoning for removing the conditional store and instead passing theSTORE_EACH
var to RobotContextTrackerTesting Changes
Utility Changes
Review requests
Risk assessment
Medium to High: This is the first time performance-metrics is going to actually be able to interact with a robot and its file system.