-
Notifications
You must be signed in to change notification settings - Fork 64
Optimize the /list fetching code to not round-trip to UUID. #848
Conversation
a87ebee
to
ce1212f
Compare
scheduler/src/cook/mesos/api.clj
Outdated
(histograms/update! list-response-job-count (count job-ents)) | ||
job-ents))) | ||
|
||
(defn list-jobs |
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.
After this change, does anything call list-jobs
?
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.
Yes; Line 1300, jobs-list-exists?
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.
Shouldn't that path also switch to using list-jobents
?
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.
Its a lot messier/riskier because the result of list-jobs is just stuffed into ::jobs in the context, and being a global, we have to trace the context through all of the code paths; pretty much, refactor the entire /jobs endpoint dataflow (individual UUID's, /job search parameters, etc). Now, the dataflow is entirely wired to generating, and consuming uuid's. If we push entities further down, we'd have to rewire the whole /jobs set of endpoints thing to entities, or clone chunks of it.
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.
Sure, but /list
is the deprecated endpoint, and /jobs
is the "new" endpoint. It seems like if we're choosing to improve one but not the other, we should choose /jobs
This PR partially addresses issue #617. |
@dposada Is there a unit test /jobs/#UUID that exeercises this codepath for https://github.com/twosigma/Cook/pull/848/files#diff-6611b39b65ff49438a4d940b51c85cc0R2549 ? |
@scrosby The Cook/integration/tests/cook/util.py Lines 521 to 523 in 204ddc8
/jobs/UUID ; let me know if that's what you're looking for.
|
…ext for /jobs endpoint. Avoids the same from-uuid to-uuid round-trip in the /jobs endpoint. Stored in ::jobs-entities.
a9b04b3
to
4cbd228
Compare
@@ -891,6 +890,10 @@ | |||
progress-regex-string (assoc :progress-regex-string progress-regex-string) | |||
pool (assoc :pool (:pool/name pool)))))) | |||
|
|||
(defn fetch-job-map | |||
[db framework-id job-uuid] | |||
(fetch-job-map-from-entity db framework-id (d/entity db [:job/uuid job-uuid]))) |
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.
Does anything still use fetch-job-map
after this change?
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.
Over a dozen uses.
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.
What are they? Should they switch over to using the new function?
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.
render-jobs-for-response-deprecated -- /rawscheduler handler
render-instances-for-response
11 times as a convenience function in unit tests.
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.
Should we have render-jobs-for-response-deprecated
and render-instances-for-response
use the new way?
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.
Thats a scope question..
If we do that, then effectively we're effectively rescoping this PR to do all of #617. Do we want to do that?
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 would vote to either do that in this PR or do it immediately after this in a follow-up PR. Basically, I wouldn't want the two functions to stay around for very long.
@@ -1116,22 +1119,31 @@ | |||
(mapv (partial fetch-job-map (db conn) framework-id) (::jobs ctx))) | |||
|
|||
(defn render-jobs-for-response | |||
"This rendes for response. Fills in in :group UUID's and names as well as map-ifies jobs | |||
It will examine the ctx for ::jobs (containing UUID's) or ::job-entities (containing | |||
datomic job entities) and return the merged set." |
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.
Why do we need both ::jobs
and ::job-entities
?
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.
::jobs has UUID's (coming from the /job/ and from /job&uuid=XXXX&uuid=XXXX) and ::job-entities has entities. Both have different logic as they filter through read-jobs-handler, so are separated until the very end.
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.
Is it possible to have them work the same way so that we don't need both entries in the context map?
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.
Yes, if we refactor the /jobs API endpoint implementation. It'll take time for me to get up to speed on liberator's semantics, because I'm going to have to face the ::params ::query-params, etc. All of the filtering and other functions in the &uuid=XXXX are all wired to UUID's. And if we're going to do that, we could greatly simplify it the implementation & semantics with a small API change. IMO, the current code is fighting with liberator, which is a sign that the API we're implementing isn't an appropriate match for it. Thus the proposal for a change.
Do we want to rescope this PR that much?
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.
Thus the proposal for a change.
It's not clear to me what the change is that you're proposing.
@scrosby Do we want to keep this PR open? |
@scrosby Can we close this PR? |
Changes proposed in this PR
Why are we making these changes?