-
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
perf(app,robot-server): Download analyses as raw JSON documents #13425
perf(app,robot-server): Download analyses as raw JSON documents #13425
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## chore_release-7.0.0 #13425 +/- ##
=======================================================
- Coverage 71.52% 71.42% -0.11%
=======================================================
Files 2431 2435 +4
Lines 67807 67844 +37
Branches 7865 7883 +18
=======================================================
- Hits 48501 48455 -46
- Misses 17463 17549 +86
+ Partials 1843 1840 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…as_opaque_documents Resolve conflicts in: * robot-server/robot_server/protocols/completed_analysis_store.py
@@ -6,6 +6,7 @@ import { | |||
import { TakeoverModal } from './TakeoverModal' | |||
import { TakeoverModalContext } from './TakeoverModalContext' | |||
|
|||
const MAINTENANCE_RUN_POLL_MS = 10000 |
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.
Backing off this refetch interval to a slower poll. There are separate interval instantiated within wizards where we need more up to date info
Separate the schema migration from the data migration. Do the data part unconditionally.
Add unit tests for AnalysisStore.
the machine understands `make format-js` as an expression of love.
Sweet! |
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.
Reviewed part of PR in live review, Python side looks good to me.
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.
All of the JS code changes look sound to me. I put this branch on app&ui bot and everything loaded very quickly!
Co-authored-by: Brian Cooper <[email protected]>
Co-authored-by: Brian Cooper <[email protected]>
Overview
This dramatically improves the load time for certain views in the Opentrons App and Flex on-device display.
For example, under the circumstances described in RSS-328, it reduces load time of the Flex's home page from ~5 minutes to <5 seconds.
This closes RSS-328 and RSS-160. It probably closes some other performance-related tickets. It also helps a little bit with RSS-98.
Architecture
Protocol analysis on the robot is a major known compute bottleneck for us. One of the problems is the overhead of storing the completed analyses in the database and then extracting them. It goes through several layers of translation:
This scheme adds a lot of overhead. Creating Pydantic objects is especially slow. (This scheme is also very brittle—see RSS-98.)
To improve this, this PR adds a second path that's basically a direct read from the database:
We expose this through an experimental new HTTP endpoint,
GET /protocols/:id/analyses/:id/asDocument
. We leave the existing endpoints, such asGET /protocols/:id/analyses/:id
, untouched for now.This requires a database migration to add a new column for the JSON string, so we do that.
Detailed changelog
Server
analysis
table:completed_analysis_as_document
, which stores the serialized JSON as aVARCHAR
.NULL
.GET /health
and on the endpoints that need the database.Desktop app and ODD
@b-cooper can provide more details, but roughly, we're switching a bunch of stuff to query the new fast endpoint and avoid querying the old slow endpoints.
Helpers for the new
GET /protocols/:protocolId/analyses/:analysisId/asDocument
endpoint have been addedapi-client
andreact-api-client
. The newuseProtocolAnalysisAsDocumentQuery
has been substituted across all locations in the Desktop and ODD where we were formerly requestingGET /protocols/:protocolId/analyses
(old non-performant un-pickling path) and picking the latest entry.Test Plan
@SyntaxColoring tested on an OT-2 and Flex:
Review requests
Architecturally, is there anything you think we need to do now in order to make this less risky, or avoid headaches in the long run?
Risk assessment
Medium.
Supporting both strategies simultaneously adds complexity to the server, which will be bug-prone if we let it linger.
Any kind of robot-server database migration with our homegrown system is inherently kind of scary, and this is the first real one that we're doing in production.
We have good automated tests for it (e.g. test_tables.py and test_persistence.py), but things can still sneak in. Examples: